Search code examples
cffmpegvideo-encodinglibavcodeclibavformat

ffmpeg (libavcodec) warning: encoded frame too large


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,


Solution

  • 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.