ffmpeg (libavcodec) 警告:编码帧太大
我正在尝试使用 libavcodec (ffmpeg) 将原始像素数据编码为 mp4 格式。一切都很顺利,我得到了质量不错的 .avi 文件,但有时编解码器会发出“编码帧太大”警告。当它这样做时,某些框架的一部分(通常是框架的底部)看起来乱码或全部混合在一起。谁能告诉我这个警告是什么时候发出的?以下是我用于编码器的设置:
qmax = 6;
qmin = 2;
bit_rate = 200000; // if I increase this, I get more warnings.
width = 1360;
height = 768;
time_base.den = 15; // frames per second
time_base.num = 1;
gop_size = 48;
pix_fmt = PIX_FMT_YUV420P;
问候,
I'm trying to use libavcodec (ffmpeg) to encode raw pixel data to mp4 format. Every thing goes well and I'm getting .avi file with decent quality but some times the codec gives "encoded frame too large" warning. And when ever it does that, a part of some frames (usually bottom portion of the frame) look garbled or all mixed up. Can any one tell me when this warning is given. Following are the settings I'm using for encoder:
qmax = 6;
qmin = 2;
bit_rate = 200000; // if I increase this, I get more warnings.
width = 1360;
height = 768;
time_base.den = 15; // frames per second
time_base.num = 1;
gop_size = 48;
pix_fmt = PIX_FMT_YUV420P;
Regards,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
据我所知,ffmpeg 分配一个 2MB 的恒定缓冲区大小来保存压缩的
框架。例如,1080p 未压缩时为 3MB,编解码器无法始终将大帧压缩为小于 2MB。
您可以通过增加缓冲区大小和/或使其动态来解决此问题。
From what I can gather ffmpeg allocates a constant buffer size of 2MB to hold a compressed
frame. 1080p is 3MB uncompressed for example, and the codec can't always compress a large frame into less than 2MB.
You can possibly fix this by increasing the buffer size, and/or making it dynamic.
很可能编解码器的缓冲区不够大。尝试更改 rc_buffer_size。或者,您可以尝试以下设置:
Very probably that codec's buffer is not big enough. Try to change rc_buffer_size. Alternatively, you can try this settings:
在示例代码中,我发现类似以下内容:
将
outbuf_size
推得更大可以解决问题。In the example code I found something like:
Pushing
outbuf_size
to be larger resolved the issue.