GStreamer-RTSP到HLS/mp4 [英] GStreamer - RTSP to HLS / mp4
问题描述
我尝试将RTSP h.264流保存到HLS mp4文件:
I try to save RTSP h.264 stream to HLS mp4 files:
gst-launch-1.0 rtspsrc location="rtsp://....." ! rtph264depay ! h264parse ! matroskamux ! hlssink max-files=0 playlist-length=0 location="/home/user/ch%05d.mp4" playlist-location="/home/user/list.m3u8" target-duration=15
结果-只有一个文件ch00000.mp4,其中包括整个视频流(目标持续时间"为3分钟而不是15秒).
As a result - there is only one file ch00000.mp4, which includes the whole videostream (3min instead of 15sec in "target-duration").
如果我保存到mpegtsmux/ts文件-对于同一命令,一切正常.
If I save to mpegtsmux / ts files - all is ok for the same command.
怎么了?预先感谢.
推荐答案
HLS由MPEG传输流段组成.所以首先: matroskamux
在这里没有意义.您将需要 mpegtsmux
.为了表明实际上是什么,通常使用扩展名为 .ts
的文件来命名.GStreamer只是一个文件名,它可能仍适用于GStreamer-播放器可能会拒绝播放它,因为期望使用另一种文件格式.
HLS consists of MPEG transport stream segments. So first: matroskamux
does not make sense here. You will need mpegtsmux
instead. To indicate what it really is you normally would name the files with a .ts
extension. It may still work for GStreamer as it is just a file name - players may reject playing it because the expect another sort of file format.
例如
gst-launch-1.0 rtspsrc location="rtsp://....." ! rtph264depay ! h264parse ! \
mpegtsmux ! hlssink max-files=0 playlist-length=0 location="/home/user/ch%05d.ts" \
playlist-location="/home/user/list.m3u8" target-duration=15
这篇关于GStreamer-RTSP到HLS/mp4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!