赞
踩
本文作为笔者使用Gstreamer的笔记,会长期维护,不断丰富使用场景。
【平台通用】
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
【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
。
推流端: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
可避免卡顿现象。
【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
【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
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&
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。