【GStreamer】MP4文件种提取H264 字节流数据保存

大家好,我是虎哥,简短的分享一个小技巧,也作为自己的记录留用。

        一般MP4文件和MKV文件都是我么从网络上比较容易获取的,但是我们用来做目标识别和检测的视频输入需要单纯的视频文件,下载到的文件都是和音频混流后的文件,所以我们解复用后,保存为单纯的byte-stream使用,下面是我自己使用和测试了解复用h264文件的技巧。

1、MP4文件解复用后播放

并非每个.mp4文件都具有h.264流。 MP4是一个容器,可能像MPEG-4一样具有不同的编码流。

解复用后显示

#matroskademux 解复用 MKV后缀
gst-launch-1.0 filesrc \
location=H264-Streat-1.mp4 ! matroskademux \
! h264parse ! avdec_h264 \
! videoconvert ! ximagesink
​
#qtdemux 解复用MP4
gst-launch-1.0 filesrc \
location=H264-Streat-1.mp4 ! qtdemux \
! h264parse ! avdec_h264 \
! videoconvert ! ximagesink
 
 

2、MP4文件解复用后保存h264流

gst-launch-1.0 filesrc \
location=H264-Streat-1.mp4 ! qtdemux \
! h264parse \
! video/x-h264,stream-format = byte-stream \
! filesink location=./H264-Streat-1.h264

3、deepstream-test1-app 测试推理识别

./deepstream-test1-app /home/nvidia/lsrobot_worksapce/Deepstream/mysamples_streams/H264-Streat-1.h264

 测试成功,说明保存h264流文件正确

gst-launch-1.0 filesrc \
location=H264-Streat-2.mp4 ! qtdemux \
! h264parse \
! video/x-h264,stream-format = byte-stream \
! filesink location=./H264-Streat-2.h264

以上就是我今天要分享的内容。纠错,疑问,交流: [email protected]

猜你喜欢

转载自blog.csdn.net/cau_weiyuhu/article/details/129116120
今日推荐