好不容易从stackoverflow网站找到通过gstreamer从rtp抓包文件中提取视频的方法,命令如下:
gst-launch-1.0.exe filesrc location=183.215.100.4_send_h264_rtp2.pcap ! pcapparse dst-port=3002 ! application/x-rtp,media=video,clock-rate=90000,payload=109,encoding-name=H264 ! rtpjitterbuffer ! rtph264depay ! capsfilter caps="video/x-h264,width=1280,height=720,framerate=(fraction)25/1" ! h264parse ! mp4mux name=muxer ! filesink location=./test1.mp4
参数说明:
location=183.215.100.4_send_h264_rtp2.pcap为WireShark抓的网络包,包含有rtp流。
rtp端口为:pcapparse dst-port=3002
rtp流的参数为:application/x-rtp,media=video,clock-rate=90000,payload=109,encoding-name=H264
本地文件格式为mp4:mp4mux name=muxer
保存本地文件为./test1.mp4
通过gstreamer从rtp抓包pcap文件中提取H265的视频,保存为mp4文件:
gst-launch-1.0.exe filesrc location=H:\nvrScale.pcap ! pcapparse dst-port=58442 ! application/x-rtp,media=video,clock-rate=90000,payload=96,encoding-name=H265 ! rtph265depay ! h265parse ! mpegtsmux ! filesink location=./nvrH265.ts
通过gstreamer从rtp抓包pcap文件中提取AMR-WB的音频频,保存为原始的pcm文件, 如果执行命令报很多错误,请放弃用以下方法(是参数不匹配引起,gstreamer的arm插件兼容有bug):
gst-launch-1.0 filesrc location=/home/hzb/capGB.pcap ! pcapparse dst-port=4010 ! "application/x-rtp,media=audio,clock-rate=16000,payload=102,encoding-name=(string)AMR-WB" ! rtpamrdepay ! decodebin name=decoder ! audioconvert ! audioresample ! audio/x-raw, rate=16000, channels=1, format=S16LE ! filesink location=./tamr.pcm
通过gstreamer从rtp抓包pcap文件中提取OPUS的音频频,保存为原始的opus文件:
gst-launch-1.0 filesrc location=/home/hzb/capGB.pcap ! pcapparse dst-port=4010 ! "application/x-rtp,media=audio,clock-rate=48000,encoding-params=2,payload=120,encoding-name=(string)OPUS" ! rtpopusdepay ! decodebin name=decoder ! audioconvert ! audioresample ! audio/x-raw, format=S16LE ! filesink location=./tamr.pcm
ffmpeg -f s16le -ar 48k -ac 2 -i ./tamr.pcm tarm.mp3
ubuntu linux下安装gstreamer
apt-get install libgstreamer1.0-0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-doc gstreamer1.0-tools
gst-inspect-1.0 | grep opus
其他TS, aac用法参考
https://blog.csdn.net/u010312436/article/details/53335579