gstreamer(三) 常用命令集锦
在gstreamer开发中,关键是要知道命令行实现,如果命令验证没有问题,再将命令集成代码工程化,或者找找对应的API来实现。本文总结工作常用命令行实现(测试环境windows)。
1.YUV编码
gst-launch-1.0 filesrc location=/root/share/test.yuv blocksize=3110400 ! video/x-raw,format=I420, framerate=25/1,width=1920,height=1080,interlace-mode=progressive ! nvh264enc ! filesink location=nvenc.264
采用nvh2464编码器将一个1080P的YUV420p文件编成h264文件.
2.解码h264播放
自动探测解码器播放
gst-launch-1.0 filesrc location=D:\\videos\\20190302_0x70000000mux.h264 ! decodebin ! d3dvideosink
指定解码器播放
gst-launch-1.0 filesrc location=D:\\videos\\20190302_0x70000000mux.h264 ! video/x-h264 ! h264parse !avdec_h264 ! d3dvideosink
3.解码h264写raw文件
写YUV
gst-launch-1.0 filesrc location=D:\\videos\\20190302_0x70000000mux.h264 ! video/x-h264 ! h264parse !avdec_h264 ! filesink location=D:\\videos\\20190302_0x70000000mux.yuv
写RGB
gst-launch-1.0 filesrc location=D:\\videos\\20190302_0x70000000mux.h264 ! video/x-h264 ! h264parse !avdec_h264 !videoconvert !video/x-raw,format=BGRA ! filesink location=D:\\videos\\20190302_0x70000000mux.rgb
4.转码
gst-launch-1.0 filesrc location=D:\\videos\\test.h265 ! video/x-h265 ! h265parse !avdec_h265 !openh264enc complexity=high bitrate=10000000 !filesink location=D:\\videos\\test.h264
将h265转码成h264
5.播放MP4
1)万能播放器播放
gst-play-1.0.exe D:\\videos\\CCTV-2-dszg-1.mp4
2)自动插件播放
gst-launch-1.0 filesrc location=D:\\videos\\CCTV-2-dszg-1.mp4 ! qtdemux name=demux demux. ! queue ! decodebin ! autovideosink demux. ! queue ! decodebin ! audioconvert ! audioresample ! autoaudiosink
6 采集屏幕录像
采集并播放
gst-launch-1.0 dx9screencapsrc ! d3dvideosink
采集并保存RGB文件
gst-launch-1.0 dx9screencapsrc ! filesink location=D:\\videos\\capture.bgr
采集并保存YUV文件
gst-launch-1.0 dx9screencapsrc !videoconvert !video/x-raw,format=I420 !filesink location=D:\\videos\\capture.yuv
7.采集摄像头
gst-launch-1.0 ksvideosrc
devicepath="\\\\\?\\usb\#vid_04f2\&pid_b604\&mi_00\#6\&31e07f50\&0\&0000\#\{6994ad05-93ef-11d0-a3cc-00a0c9223196\}\\global" ! d3dvideosink
Linux上采集设备为v4l2src。
8.摄像头采集并RTP串流
gst-launch-1.0 wrappercamerabinsrc !videoconvert !video/x-raw,format=I420 !openh264enc usage-type=camera complexity=high bitrate=10000000 ! rtph264pay config-interval=3 ssrc=12345 !queue !udpsink host="127.0.0.1" port=60002
接收RTP流并播放https://blog.****.net/fengliang191/article/details/105102495
更多更详细请关注公众号:AV_Chat