> 技术文档 > Gstreamer系列(6):Gstreamer在arm平台(瑞芯微Rockchip)使用硬编码对视频进行保存mp4,推拉流_gstreamer-rockchip

Gstreamer系列(6):Gstreamer在arm平台(瑞芯微Rockchip)使用硬编码对视频进行保存mp4,推拉流_gstreamer-rockchip

        由于某些行业只能使用国产芯片,所以在工程实践中也常常用到国产芯片,进行视频推拉流处理。瑞芯微(Rockchip)作为国产芯片的佼佼者,常备用在消费电子,智能家居,车载电子,工业控制等地方。 本文将介绍Gstreamer在瑞芯微Rockchip上的使用,适用于RK3568和RK3588,其他型号未测试。

1. Rockchip MPP安装

gstreamer安装参考一键安装gstreamer,安装gstreamer的瑞芯微硬件编解码插件命令如下:

添加仓库

sudo add-apt-repository ppa:george-coolpi/multimediasudo apt update

安装gstreamer1.0-rockchip

 sudo apt-get install gstreamer1.0-rockchip # 测试是否安装成功 gst-inspect-1.0 mppvideodec

2. Rockchip MPP插件

常使用的MPP编码插件mpph264enc,解码插件mppvideodec

编码支持的格式有:JPEG H264 H265 VP8

解码支持的格式有:JPEG, MPEG,VP8 VP9 H264 H265

2.1 mpph264enc插件

主要属性有:

width: 宽度, 默认为o, 不进行缩放
height:面度, 默认为o, 不进行缩放。
rc-mode: 码率控制模式可选VBR, CBR和Fixed QP。
bps: 目标码率, 在Fixed QP模式下忽略。
bps-max: 最高码率 , 在Fixed QP膜式下忽略。
bps-min:最低码率, 在Fixed QP模式下忽略。
gop: Group Of Picture, 即两I帧的间隔。 如0表示仅有一个1帧, 其余为P 帧, 1表示全为1帧, 2表示每两 帧为1帧, 即IPIPIP .形式。 默认为-1, 按帧率设詈, 即每秒有一个I帧。
level: 表示SPS中的level_idc参数。
profile: 表示SPS中的profile_idc参数。
rotation: 旋转输入buffer, 可选0°\'90°\'180°\'270°0 

2.2 mppvideodec插件

主要属性有:

rotation:旋转角度,默认为0°,可选0°,90°,180°,270°。

width: 宽度,默认为0,不进行缩放。

height:高度,默认为0,不进行缩放。

crop-rectangle:裁剪,使用方式,即裁剪源为起点,宽高为w*h的图像送至下级。

format:输出格式默认为0 \"auto\", 不进行格式转换。
fast-mode:开启MPPFast Mode,如在RK3588平台上可以使部分解码流程并行,提升解码效率。默认开 启。
ignore-error: 忽略MPP解码错误强制输出解码帧。 默认开启。

3. 命令示例

3.1 使用测试视频

#1. 保存mp4gst-launch-1.0 videotestsrc is-live=1 ! video/x-raw,width=1280,height=720 ! videoconvert ! mpph264enc ! h264parse ! qtmux ! filesink location=test.mp4 -e#2. rtp推流gst-launch-1.0 videotestsrc is-live=1 ! video/x-raw,width=1280,height=720 ! videoconvert ! mpph264enc ! h264parse ! rtph264pay ! udpsink host=127.0.0.1 port=1234

3.2  使用摄像头

#1. 保存mp4gst-launch-1.0 v4l2src device=/dev/video0 ! \"video/x-raw, format=YUY2,width=640,height=480,framerate=30/1\" ! videoconvert ! mpph264enc ! h264parse ! qtmux ! filesink location=test.mp4 -e#2. rtp推流gst-launch-1.0 v4l2src device=/dev/video0 ! \"video/x-raw, format=YUY2,width=640,height=480,framerate=30/1\" ! videoconvert ! mpph264enc ! h264parse ! rtph264pay ! udpsink host=127.0.0.1 port=1234

3.3  RTP拉流

gst-launch-1.0 udpsrc port=1234 buffer-size=60000000 caps=\"application/x-rtp,media=video, clock-rate=90000,payload=96, encoding-name=H264\" ! rtpjitterbuffer latency=7 ! rtph264depay ! h264parse ! mppvideodec ! videoconvert ! autovideosink 

4. 总结

        本文分享了在瑞芯微平台上使用Gstreamer的安装方式、编解码插件主要属性,和常使用的终端命令。

新昌苗木网