Gstreamer管道命令记录

概述

本文作为笔者使用Gstreamer的笔记,会长期维护,不断丰富使用场景。

Mp4转Avi

【平台通用】

gst-launch-1.0 filesrc location=SampleVideo_1280x720_5mb.mp4 ! qtdemux name=demux ! queue ! avdec_h264 ! video/x-raw ! avimux name=mux ! filesink location=flc.avi demux. ! queue ! avdec_aac ! audioconvert ! mux.

【RK3399平台】

gst-launch-1.0 filesrc location=/oem/SampleVideo_1280x720_5mb.mp4 ! qtdemux 
! h264parse ! mppvideodec ! video/x-raw,formate=NV12 ! mpph264enc !
 avimux ! filesink location=/userdata/flc.avi

【RK3399平台】边播边保存文件:

gst-launch-1.0 filesrc location=/oem/SampleVideo_1280x720_5mb.mp4 ! qtdemux 
! h264parse ! mppvideodec ! tee name=t ! queue ! video/x-raw,formate=NV12 ! mpph
264enc ! avimux ! filesink location=/userdata/flc.avi t. ! queue ! kmssink

播放RTSP流

【RK3399平台】

gst-launch-1.0 rtspsrc location="rtsp://b1.dnsdojo.com:1935/live/sys3.stream" ! queue ! rtph264depay ! video/x-h264, stream-format=avc ! h264parse ! mppvideodec ! queue ! video/x-raw,formate=NV12,width=1280,height=720 ! videoconvert ! kmssink

叠加时间戳

【平台通用】

gst-launch-1.0 videotestsrc ! clockoverlay halignment=right valignment=bottom shaded-background=true time-format="%Y.%m.%D" ! videoconvert ! ximagesink

动态控制文件是否保存 & 分割多个文件保存视频

gst-launch-1.0 videotestsrc do-timestamp="TRUE"  ! tee name=t t. ! queue ! videoconvert ! autovideosink async="FALSE" t. ! queue ! identity drop-probability=1 ! videoconvert name=conv2 ! x264enc ! h264parse ! avimux ! multifilesink async="FALSE" post-messages=true next-file=4 max-file-size=2097152 location=/home/xlr/Videos/aaaa%d

通过控制identity 的属性drop-probability来选择文件是否开始保存。=1,数据丢弃;=0,文件开始保存。
通过指定multifilesink的属性next-file=4 max-file-size=2097152设置每个文件的大小(Bytes),next-file=4表示以max-file-size为文件上限,到达该上限就重新保存文件。location=/home/xlr/Videos/aaaa%d表示存储文件的位置和名称,将会以aaaa0,aaaa1等形式存储,每个文件大小为max-file-size

UDP传输视频

推流端:gst-launch-1.0 videotestsrc ! video/x-raw,width=1280,height=720 ! mpph264enc ! rtph264pay ! udpsink host=127.0.0.1 port=8888

收流端:gst-launch-1.0 udpsrc port=8888 ! application/x-rtp ! rtph264depay ! video/x-h264, stream-format=avc ! rtpjitterbuffer latency=1000 ! h264parse ! avdec_h264 ! video/x-raw,formate=NV12,width=1280,height=720 ! videoconvert ! autovideosink

注:没有使用rtpjitterbuffer元素时,会报“A lot of buffers are being dropped”错误。
增加latency=1000可避免卡顿现象。

编码生成TS流:

【RK3399平台】

gst-launch-1.0 videotestsrc num-buffers=512 ! video/x-raw,format=NV12,width=1920,height= 1080,framerate=30/1 ! queue ! mpph264enc ! queue ! h264parse ! mpegtsmux ! filesink location=/home/linaro/2k.ts

RGA Convert

【RK3399平台】

gst-launch-1.0 -v videotestsrc ! "video/x-raw,format=BGRA,width=1920,height=1080,framerate=30/1" ! rgaconvert hflip=false vflip=false rotation=90 input-crop=0x0x1920x1080 output-crop=0x0x640x360 output-io-mode=dmabuf capture-io-mode=dmabuf !  "video/x-raw,format=NV12, width=640,height=640x360,framerate=30/1" ! kmssink

export GST_VIDEO_CONVERT_USE_RGA=1

查看帧率

export GST_VIDEO_CONVERT_USE_RGA=1
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/gstreamer-1.0
GST_DEBUG=fpsdisplaysink:6  gst-launch-1.0 v4l2src device=/dev/video10 ! image/jpeg, width=1920, height=1080, framerate=30/1 !jpegparse ! mppjpegdec ! videoconvert ! fpsdisplaysink video-sink=kmssink sync=false signal-fps-measurements=true text-overlay=false

RockChip平台启用Waylandsink

export QT_QPA_PLATFORM=wayland
export WESTON_DRM_MIRROR=1
export WESTON_DRM_KEEP_RATIO=0
export QT_GSTREAMER_WINDOW_VIDEOSINK=waylandsink
mkdir -p /tmp/.xdg &&  chmod 0700 /tmp/.xdg
export XDG_RUNTIME_DIR=/tmp/.xdg
weston --tty=2 --idle-time=0&
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值