如何通过gstreamer将RTSP视频流保存到MP4文件? [英] How to save a RTSP video stream to MP4 file via gstreamer?

查看:2684
本文介绍了如何通过gstreamer将RTSP视频流保存到MP4文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要通过RTSP从摄像机获取视频流,并将其保存到文件中.所有这些都需要通过gstreamer完成.

I need to get a video stream from my camera via RTSP and save it to a file. All of this needs to be done via gstreamer.

经过Google的一些搜索,我尝试了以下操作:

After some google searching, I tried the following:

gst-launch-1.0 rtspsrc location=rtsp://192.168.1.184/live2.sdp ! queue ! rtph264depay ! avdec_h264 ! mp4mux ! filesink location=result3.mp4

但是它给出了错误: 错误的管道:无法将avdec_h264-0链接到mp4mux0"

but it gives the error: "Erroneous pipeline: could not link avdec_h264-0 to mp4mux0"

gst-launch-1.0 rtspsrc location=rtsp://192.168.1.184/live2.sdp ! queue ! rtph264depay ! h264parse ! mp4mux ! filesink location=result3.mp4

它开始工作,但结果文件无法通过VLC播放.

It starts doing work, but the result file is not playable via VLC.

正确的命令是什么? 如果您在h264parse和avdec_h264之间进行选择,请解释一下原因吗?

What is the right command to do? And if you choose between h264parse and avdec_h264, could you please explain why?

推荐答案

您需要添加-e标志(流结束),以便mp4mux可以终结文件,否则您将损坏无法播放的文件.

You need to add -e flag (end of stream) so that mp4mux can finalize file or else you'll get corrupted non playable file.

 gst-launch -e rtspsrc location=url ! decodebin ! x264enc ! mp4mux ! filesink location=file.mp4

这篇关于如何通过gstreamer将RTSP视频流保存到MP4文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆