在 FFmpeg/LibAV 中设置 RTSP/UDP 缓冲区大小 [英] Set RTSP/UDP buffer size in FFmpeg/LibAV

查看:187
本文介绍了在 FFmpeg/LibAV 中设置 RTSP/UDP 缓冲区大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注意:我知道 ffmpeg 和 libav 是不同的库.这是两者的共同问题.

Note: I'm aware ffmpeg and libav are different libraries. This is a problem common to both.

免责声明:SO 问题的重复 标记为已回答但实际上没有给出正确的解决方案.

Disclaimer: Duplicate of SO question marked as answered but actually didn't give a proper solution.

UDP 缓冲区大小不足会导致多个高分辨率视频流的流中断.在 LibAV/FFMPEG 中,可以通过附加一些 选项(缓冲区大小).

Insufficient UDP buffer size causes broken streams for several high resolution video streams. In LibAV/FFMPEG it's possible to set the udp buffer size for udp urls (udp://...) by appending some options (buffer_size) to it.

但是,对于 RTSP 网址,这是不支持.

However, for RTSP urls this is not supported.

这些是我找到的唯一解决方案:

These are the only solutions I've found:

  • Rebuilding ffmpeg/libav changing the UDP_MAX_PKT_SIZE in the udp.c source file.
  • Using a nasty hack to find and modify the required value, by casting some private structs.
  • Using a different decoding library (proposed solution to aforementioned related SO question).

这些实际上都不是解决方案.从我发现应该可以使用 API 的 AVOptions 查找并设置此值.或者,AVDictionary.

None of these is actually a solution. From what I found it should be possible to use the API's AVOptions to find and set this value. Or else, the AVDictionary.

在 libav 或 ffmpeg 的整个文档中很难找到如何设置这些.

It's very difficult to find how to set these throughout the documentation of either libav or ffmpeg.

更新:

感谢 Libav 开发者 @lu_zero :

The following patches have been submited to Libav tackling this topic, thanks to Libav developer @lu_zero :

哪些应该提供有关如何实现这些的提示,但这些仍然无法通过官方稳定 API 获得.

Which should offer a hint on how to implement those, still these are not yet available through the official stable API.

推荐答案

自从 this 提交足以将 buffer_size 作为选项传递,并通过 rtp 转发到 udp 协议协议.

Since this commit it is enough to pass buffer_size as option and it gets forwarded to the udp protocol through the rtp protocol.

我测试过,它按预期工作.

I tested and it works as intended.

这篇关于在 FFmpeg/LibAV 中设置 RTSP/UDP 缓冲区大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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