[Libav-user] warning of "[libmp3lame @ 00CAB020] frame_size is too large" while calling avcodec_encode_audio2()

jettoblack jettoblack at gmail.com
Thu Sep 27 02:53:20 CEST 2012

zhao0130 wrote
> I am using ffmpeg api to transcode a movie (.mp4 -> .mov). I got a warning 
> while calling avcodec_encode_audio2(): "[libmp3lame @ 00CAB020] frame_size 
> is too large". I believe this should be due to that the frame size of 
> decoding AVCodecContext, 1024, is different from that of encoding 
> AVCodecContext, 1152. The audio codec of the mp4 file is AAC and that of 
> the mov file is MP3. The default of frame size of MP3 seems 1152 and I can 
> not force it to be 1024. I set other parameters such as sample_rate, 
> bit_rate, sample_fmt and channels of encoding AVCodecContext same as those 
> of decoding AVCodecContext. Help will be really appreciated!

You need to use a FIFO for the audio samples.  Each time you get samples
from the decoder, push them into the FIFO.  Whenever the FIFO size is at
least the encoder's frame_size, pull one frame's worth of samples out of the
FIFO into the encoder.  There is audio FIFO code already built into ffmpeg:

Some audio codecs like PCM have a frame_size of 0.  I use 1024 samples for

View this message in context: http://libav-users.943685.n4.nabble.com/Libav-user-warning-of-libmp3lame-00CAB020-frame-size-is-too-large-while-calling-avcodec-encode-audio-tp4655745p4655749.html
Sent from the libav-users mailing list archive at Nabble.com.

More information about the Libav-user mailing list