ffmpeg - 将实时视频流保存到本地存储

标签 ffmpeg directshow rtsp

问题:

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/

相关文章:

c# - 如何检查ffmpeg何时完成视频片段?

Python 对管道和大文件的子处理

java Runtime.exec() 编程并将字符传递给 getch()

c# - 如何从具有组件输出的设备获取高清信号并将其显示在 C# 应用程序的窗口中?

C++ RTSP视频采集实现

audio - 在 ffmpeg 中使用 -filter_complex 和批量连接数组

c++ - 从资源文件中使用directshow播放音频

c++ - 如何使用 Media Foundation 或 DirectShow 等 Windows 媒体 API 检测相机帧丢失?

http - 通过 HTTP .NET 获取 RTSP

c++ - 使用 FFmpeg 从 IP 摄像机 (RTSP) 读取会导致 5xx 服务器错误