保存 H.264 RTP 流而不重新编码?
我的 C++ 应用程序接收 H.264 RTP 视频流。
现在它对流进行解码,将其保存到 YUV 文件中,稍后我使用 ffmpeg 将文件重新编码为适合在 Windows PC 上观看的内容(例如 Mpeg4 AVI)。
是否应该可以将 H.264 流保存到 AVI(或类似)容器中而无需对其进行解码和重新编码?这需要在 PC 上安装 H.264 解码器才能观看,但效率应该要高得多。
这怎么可能呢?有任何库支持吗?
My C++ application receives a H.264 RTP video stream.
Right now it decodes the stream, saves it into a YUV file and later I use ffmpeg to re-ecode the file into something suitable to watch on a Windows PC (eg. Mpeg4 AVI).
Shouldn't it be possible to save the H.264 stream into a AVI (or similar) container without having to decode and re-encode it ? That would require some H.264 decoder on the PC to watch, but it should be much more efficient.
How could that be done ? Are there any libraries supporting that ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 ffmpeg 是正确的,但到目前为止发布的答案对我来说看起来不正确。
正确的开关应该是:
using ffmpeg is correct but the answers posted so far dont look right to me.
the correct switch should be:
您的程序可以通过
ffmpeg
传输 rtp 本身 - 甚至使用 < 调用它代码>popen3()。看来您需要使用 中间 SDP 文件 - 我推测您可以将创建的文件指定为 命名管道 或使用
tmpfile()
您的应用程序写入的内容 - 使用文件作为中介。命令行将类似于:
我相信在这种情况下 ffmpeg 足够聪明,可以重新打包容器(rtp 流与 AVI),而无需对视频和音频进行转码(这是
- vcodec复制开关);因此,您不会有任何质量损失,而且速度会非常快。
Your program could pipe the rtp itself through
ffmpeg
- even invoking it usingpopen3()
.It seems that you need to use an intermediate SDP file - I speculate that you can specify a file you created as a named pipe or with
tmpfile()
which your application writes to - using the file as an intermediary.The command-line would be something like:
I believe that in this circumstance ffmpeg is clever enough to repackage the container (rtp stream vs AVI) without transcoding the video and audio (this is the
-vcodec copy
switch); therefore, you'd have no loss of quality and it'd be blazingly fast.