问题:
I have to save live video streams data which come as an RTP packets from RTSP Server.
The data come in two formats : MPEG4 and h264.
I do not want to encode/decode input stream.
Just write to a file which is playable with proper codecs.
有什么建议吗?
最好的祝愿
历史:
我的解决方案及其问题:
第一次尝试: FFmpeg
I use FFmpeg libary to get audio and video rtp packets.
But in order to write packets i have to use av_write_frame :
which seems that decode /encode takes place.
Also, when i give output format as mp4 ( av_guess_format("mp4", NULL, NULL)
the output file is unplayable.
[ any way ffmpeg has bad doc. hard to find what is wrong]
第二次尝试 : 直接秀
Then i decide to use DirectShow. I found a RTSP Source Filter.
Then a Mux and File Writer.
Cretae Single graph:
RTSP Source --> MPEG MUX ---> File Writer
It worked but the problem is that the output file is not playable
if graph is not stoped. If something happens, graph crashed for example
the output file is not playable
Also i can able to write H264 data, but the video is completely unplayable.
最佳答案
MP4 文件格式具有正确播放所需的索引,并且只有在完成录制后才能创建索引。因此,任何使用 MP4 容器文件(和其他索引文件)的解决方案都会遇到同样的问题。您需要停止录制以完成文件,否则将无法播放。
一种可能有帮助的解决方案是将图表分成两部分,以便您可以在停止当前文件的同时继续录制到新文件。在 www.gdcl.co.uk/gmfbridge 上有一个例子。
如果您尝试使用 GDCL MP4 多路复用器,并且遇到 H264 流问题,请参阅相关问题 GDCL Mpeg-4 Multiplexor Problem
关于ffmpeg - 将实时视频流保存到本地存储,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6225384/