在rk3588平台快速使用硬件编解码功能
在rv1126/rv1109等平台,rk提供的是使用rkmedia来进行视频硬件编解码的功能,它会使用到底层的rkmpp和rga来实现对硬件编解码加速,而在rk3588平台(rk3568应该也支持)则没有这个rkmedia这套框架,如果我们要使用硬件编解码、图像处理加速等功能就需要从rkmpp、rga等来实现,对于不熟悉这一套的人来说会比较麻烦,学习成本也比较高,好在rk原厂在ffmpeg和gstreamer这两个上面做了支持,我们可以通过这两个开源的音视频处理库来实现对硬件编解码的调用,今天我要介绍的就是在rk3588平台通过gstreamer来实现硬件编解码的使用。
GStreamer是一个开源的多媒体框架,用于构建流媒体应用程序和处理音频、视频、图像和其他媒体数据。它提供了一组库和插件,可以用来创建、编辑、播放和流式传输多媒体内容。GStreamer支持多种编解码器、容器格式和协议,可以在不同的平台上运行,包括Linux、Windows和macOS。它是一个灵活且功能丰富的工具,被广泛用于视频编辑、音频处理、流媒体服务器和嵌入式设备等领域。
rk官方也提供了参考文档, 《Rockchip_User_Guide_Linux_Gstreamer_CN.pdf》
关于rv平台没有对gstreamer支持我个人感觉可能是gstreamer的包本身比较大吧,在rv平台本身更精简一点,所以直接用了rkmedia这一套来讲效率更高,而rk3588平台cpu足够强悍,这点问题来讲就不是问题了,也方便用户快速验证开发,有需要的再转到mpp去,减少调用。
一般我们拿到手的rk3588板子里面文件系统就已经预装了gstreamer以及rk的插件的,没有的话可以去sdk里面找,这一部分rk也开源了源码在sdk里面有。
rk3588平台在gstreamer上面主要做了如下几个插件。
orangepi@orangepi5:~$ gst-inspect-1.0 | grep mpp
rockchipmpp: mppjpegdec: Rockchip's MPP JPEG image decoder
rockchipmpp: mppvideodec: Rockchip's MPP video decoder
rockchipmpp: mppjpegenc: Rockchip Mpp JPEG Encoder
rockchipmpp: mppvp8enc: Rockchip Mpp VP8 Encoder
rockchipmpp: mpph265enc: Rockchip Mpp H265 Encoder
rockchipmpp: mpph264enc: Rockchip Mpp H264 Encoder
typefindfunctions: audio/x-musepack: mpc, mpp, mp+
我们通过 gst-inspect-1.0
命令来查阅使用手册
orangepi@orangepi5:~$ gst-inspect-1.0 mpph264enc
mpp_info: mpp version: unknown mpp version for missing VCS info
mpp_info: mpp version: unknown mpp version for missing VCS info
mpp_info: mpp version: unknown mpp version for missing VCS info
mpp_info: mpp version: unknown mpp version for missing VCS info
Factory Details:
Rank primary + 1 (257)
Long-name Rockchip Mpp H264 Encoder
Klass Codec/Encoder/Video
Description Encode video streams via Rockchip Mpp
Author Randy Li <randy.li@rock-chips.com>, Jeffy Chen <jeffy.chen@rock-chips.com>
Plugin Details:
Name rockchipmpp
Description Rockchip Mpp Video Plugin
Filename /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstrockchipmpp.so
Version 1.14.4
License LGPL
Source module gst-rockchip
Binary package GStreamer Rockchip Plug-ins
Origin URL Unknown package origin
GObject
+----GInitiallyUnowned
+----GstObject
+----GstElement
+----GstVideoEncoder
+----GstMppEnc
+----GstMppH264Enc
Implemented Interfaces:
GstPreset
Pad Templates:
SINK template: 'sink'
Availability: Always
Capabilities:
video/x-raw
format: { (string)NV12, (string)I420, (string)YUY2, (string)UYVY, (string)BGR16, (string)RGB16, (string)ABGR, (string)ARGB, (string)BGRA, (string)RGBA, (string)xBGR, (string)xRGB, (string)BGRx, (string)RGBx, (string)NV12, (string)NV21, (string)I420, (string)YV12, (string)NV16, (string)NV61, (string)BGR16, (string)RGB, (string)BGR, (string)RGBA, (string)BGRA, (string)RGBx, (string)BGRx }
width: [ 96, 2147483647 ]
height: [ 64, 2147483647 ]
SRC template: 'src'
Availability: Always
Capabilities:
video/x-h264
width: [ 96, 2147483647 ]
height: [ 64, 2147483647 ]
stream-format: { (string)byte-stream }
alignment: { (string)au }
profile: { (string)baseline, (string)main, (string)high }
Element has no clocking capabilities.
Element has no URI handling capabilities.
Pads:
SINK: 'sink'
Pad Template: 'sink'
SRC: 'src'
Pad Template: 'src'
Element Properties:
bps : Target BPS (0 = auto calculate)
flags: readable, writable
Unsigned Integer. Range: 0 - 2147483647 Default: 0
bps-max : Max BPS (0 = auto calculate)
flags: readable, writable
Unsigned Integer. Range: 0 - 2147483647 Default: 0
bps-min : Min BPS (0 = auto calculate)
flags: readable, writable
Unsigned Integer. Range: 0 - 2147483647 Default: 0
gop : Group of pictures starting with I frame (-1 = FPS, 1 = all I frames)
flags: readable, writable
Integer. Range: -1 - 2147483647 Default: -1
header-mode : Header mode
flags: readable, writable
Enum "MppEncHeaderMode" Default: 0, "first-frame"
(0): first-frame - Only in the first frame
(1): each-idr - In every IDR frames
level : H264 level (40~41 = 1080p@30fps, 42 = 1080p60fps, 50~52 = 4K@30fps)
flags: readable, writable
Enum "GstMppH264Level" Default: 40, "4"
(10): 1 - 1
(99): 1b - 1b
(11): 1.1 - 1.1
(12): 1.2 - 1.2
(13): 1.3 - 1.3
(20): 2 - 2
(21): 2.1 - 2.1
(22): 2.2 - 2.2
(30): 3 - 3
(31): 3.1 - 3.1
(32): 3.2 - 3.2
(40): 4 - 4
(41): 4.1 - 4.1
(42): 4.2 - 4.2
(50): 5 - 5
(51): 5.1 - 5.1
(52): 5.2 - 5.2
(60): 6 - 6
(61): 6.1 - 6.1
(62): 6.2 - 6.2
max-reenc : Max re-encode times for one frame
flags: readable, writable
Unsigned Integer. Range: 0 - 3 Default: 1
name : The name of the object
flags: readable, writable
String. Default: "mpph264enc0"
parent : The parent of the object
flags: readable, writable
Object of type "GstObject"
profile : H264 profile
flags: readable, writable
Enum "GstMppH264Profile" Default: 100, "high"
(66): baseline - Baseline
(77): main - Main
(100): high - High
qos : Handle Quality-of-Service events from downstream
flags: readable, writable
Boolean. Default: false
qp-init : Initial QP (lower value means higher quality)
flags: readable, writable
Unsigned Integer. Range: 0 - 51 Default: 26
qp-max : Max QP (0 = default)
flags: readable, writable
Unsigned Integer. Range: 0 - 51 Default: 0
qp-max-step : Max delta QP step between two frames (-1 = default)
flags: readable, writable
Integer. Range: -1 - 51 Default: -1
qp-min : Min QP (0 = default)
flags: readable, writable
Unsigned Integer. Range: 0 - 51 Default: 0
rc-mode : RC mode
flags: readable, writable
Enum "GstMppEncRcMode" Default: 1, "cbr"
(0): vbr - Variable bitrate
(1): cbr - Constant bitrate
(2): fixqp - Fixed QP
sei-mode : SEI mode
flags: readable, writable
Enum "GstMppEncSeiMode" Default: 0, "disable"
(0): disable - SEI disabled
(1): one-seq - One SEI per sequence
(2): one-frame - One SEI per frame(if changed)
zero-copy-pkt : Zero-copy encoded packet
flags: readable, writable
Boolean. Default: true
接下来演示一下如何使用。
gst-launch-1.0 videotestsrc ! x264enc ! filesink location=2.h264
gst-launch-1.0 videotestsrc ! mpph264enc ! filesink location=1.h264
可以看到,我们使用mpph264enc
来进行硬件编码时会比使用x264enc
软件编码时对cpu的占用率低很多。
好啦,这篇就讲到这里,点到即止,更多的使用方法大家可以看rk的文档还有gstreamer官方的教程。
gstreamer官方教程:https://gstreamer.freedesktop.org/documentation/tutorials/index.html?gi-language=c
- 分享
- 举报
-
浏览量:3045次2023-12-28 17:46:27
-
浏览量:3972次2021-04-02 09:47:41
-
浏览量:2321次2023-11-17 09:00:06
-
浏览量:3469次2022-09-03 09:03:36
-
浏览量:2115次2023-04-19 09:08:35
-
浏览量:2456次2023-12-21 11:18:25
-
浏览量:32873次2022-06-11 11:06:24
-
浏览量:8827次2022-06-11 10:47:27
-
浏览量:1028次2024-02-18 16:38:33
-
浏览量:1474次2023-11-14 13:55:50
-
浏览量:2259次2020-08-17 11:44:38
-
浏览量:1157次2024-01-26 15:15:36
-
浏览量:4961次2022-05-10 11:01:46
-
浏览量:2706次2024-02-26 14:13:38
-
浏览量:1820次2024-01-02 22:42:19
-
浏览量:2399次2023-11-01 20:42:22
-
浏览量:3230次2022-05-17 09:01:02
-
浏览量:3975次2022-05-11 09:11:45
-
浏览量:1516次2024-02-05 10:41:25
-
广告/SPAM
-
恶意灌水
-
违规内容
-
文不对题
-
重复发帖
毛巾卷
感谢您的打赏,如若您也想被打赏,可前往 发表专栏 哦~
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明