gstream 命令行使用整理
gst-inspect-1.0 可以用来查询有哪些插件可用
gst-inspect-1.0 + name 可以查看插件详情接口信息
gst-launch-1.0 可拼接插件,执行命令
gstream 部分插件介绍
filesrc,rtspsrc 用于打开文件或者视频流
matroskademux, flvdemux 解封装
matroskamux, flvmux 封装
nvv4l2decoder, nvv4l2decoder jetson上面的硬件解码器
nvvidconv 格式转换控件
使用示例:
下面以flv视频流格式为例,列举一些常用的指令
从rtsp流中保存视频
gst-launch-1.0 rtspsrc location=rtsp://admin:[email protected]/h264/ch1/main/av_stream ! rtph264depay ! queue ! nvv4l2decoder ! nvvidconv ! video/x-raw, width=1280, height=720 ! nvvidconv ! nvv4l2h264enc profile=4 iframeinterval=30 bitrate=1500000 ! h264parse ! flvmux ! queue ! filesink location=output1.flv
gst-launch-1.0 rtspsrc location=rtsp://admin:[email protected]/h264/ch1/main/av_stream name=src \
flvmux name=mux ! filesink name=file location=test.flv \
src. ! rtph264depay ! nvv4l2decoder ! nvv4l2h264enc ! h264parse ! queue ! mux.video \
src. ! rtpmp4gdepay ! aacparse ! avdec_aac ! queue ! audiorate ! audioconvert ! voaacenc ! mux.audio
视频格式转换
gst-launch-1.0 filesrc location=/opt/tmpmedia/234_1595904505.mkv ! matroskademux ! h264parse ! nvv4l2decoder ! nvvidconv ! video/x-raw, width=720, height=480 ! nvvidconv ! nvv4l2h264enc ! filesink location=output1.flv
rtsp流转rtmp流
gst-launch-1.0 rtspsrc latency=8 location=rtsp://admin:[email protected]/h264/ch1/main/av_stream ! rtph264depay ! queue ! nvv4l2decoder ! nvvidconv ! video/x-raw, width=720, height=480 ! nvvidconv ! nvv4l2h264enc ! h264parse ! flvmux ! rtmpsink location="rtmp://pili-publish.ps.qiniucdn.com/NIU7PS/UID1382264358"
gst-launch-1.0 rtspsrc location=rtsp://admin:[email protected]/h264/ch1/main/av_stream name=src \
flvmux name=mux ! queue ! rtmpsink name=rtmp location="rtmp://localhost/myapp/live_133_101_23" \
src. ! rtph264depay ! mux.video
子码流保存视频
gst-launch-1.0 rtspsrc location=rtsp://admin:[email protected]/h264/ch1/main/av_stream ! rtph264depay ! flvmux ! filesink location=output1.flv
子码流推流
gst-launch-1.0 rtspsrc location=rtsp://admin:[email protected]/h264/ch1/main/av_stream name=src \
flvmux name=mux ! queue ! rtmpsink name=rtmp location="rtmp://live.retaildev.lenovo.com/intelligent-retail/live_133_101_23" \
src. ! rtph264depay ! mux.video \
src. ! rtpmp4gdepay ! aacparse ! avdec_aac ! queue ! audiorate ! audioconvert ! voaacenc ! mux.audio
视频流的重编码融合(rtspsrc可以整合成一个)
gst-launch-1.0 flvmux name=mux ! filesink name=file location=test.flv \
rtspsrc location=rtsp://admin:[email protected]/h264/ch1/main/av_stream ! rtph264depay ! nvv4l2decoder ! nvv4l2h264enc profile=4 iframeinterval=30 bitrate=4000000 ! h264parse ! mux.video \
rtspsrc location=rtsp://admin:[email protected]/h264/ch1/main/av_stream ! audiorate ! audioconvert ! voaacenc ! mux.audio
本地流生成rtmp地址
gst-launch-1.0 filesrc location="./output1.mp4" ! -v videotestsrc ! ffenc_flv ! flvmux ! rtmpsink location="rtmp://pili-publish.live.qiniu.pursue.show/pursue-online/ForTest"
[扩展ffmpeg]
推送命令[ffmpeg]
ffmpeg -buffer_size 1024000 -stimeout 3000000 -rtsp_transport tcp -i -vcodec libx264 -s 1280x720 -r 20 -preset superfast -vb 1M -tune zerolatency -g 20 -async 1 -vsync 1 -f flv rtmp://live.retaildev.lenovo.com/intelligent-retail/live_code3_733_1
本地推送命令(带音频)[ffmpeg]
ffmpeg -buffer_size 1024000 -flags low_delay -stimeout 3000000 -rtsp_transport tcp -i rtsp://admin:[email protected]/h264/ch1/main/av_stream -vcodec libx264 -acodec aac -s 1280x720 -r 20 -preset superfast -vb 1M -tune zerolatency -g 20 -async 1 -vsync 1 -f flv rtmp://192.168.2.15:1935/myapp/test1
ffmpeg -buffer_size 1024000 -fflags nobuffer -fflags discardcorrupt -flags low_delay -framedrop -avioflags direct -stimeout 3000000 -rtsp_transport tcp -i rtsp://admin:[email protected]/h264/ch1/main/av_stream -vcodec libx264 -acodec aac -s 1280x720 -r 20 -preset superfast -vb 1M -tune zerolatency -g 20 -async 1 -vsync 1 -f flv rtmp://192.168.2.15:1935/myapp/test1
推送本地视频(音频) [ffmpeg]
ffmpeg -re -ss 00:00:01 -i /mnt/media/code3_731_1597638913_1597638943.mkv -vcodec libx264 -acodec aac -s 720x480 -r 20 -vb 500k -preset superfast -tune zerolatency -async 1 -vsync 1 -f flv rtmp://live.retaildev.lenovo.com/intelligent-retail/live_code3_733_0_1
定时录制视频
ffmpeg -i 'rtsp://192.168.2.117:554/user=admin&password=aIlab1234&channel=1&stream=0.sdp?real_stream' -t 1800 -c copy -f flv 2.flv
-i + 视频流地址
-t + 定时时间(秒),
-c copy 保持视频原质量
-f flv 保存为flv格式视频
2.flv 保存的文件名