[Libav-user] # of audio samples, calculated vs. codec context

Paul B Mahol onemda at gmail.com
Tue May 21 20:02:54 CEST 2013

On 5/21/13, Brad O'Hearne <brado at bighillsoftware.com> wrote:
> On May 21, 2013, at 9:28 AM, Paul B Mahol <onemda at gmail.com> wrote:
>> I don't see any problem, ffmpeg can resample and encode at same time.
> I didn't see any problem in principle either. In practice, it all works fine
> until encountering an audio device with a lower sample rate that pushes the
> resampled frame size above the codec's max frame size, then it blows up.
> Here's the problem:
> source sample rate = 16000
> source number of samples = 512
> destination sample rate = 44100
> (using libmp3lame, which sets its frame size to 1152).

You told that already, you enjoy repeating yourself, do you?

> if you resample prior to encoding, av_encode_audio2 fails with error -22,
> due to libavcodec's utils.c line 1208 as the result of this check in the
> preceding line failing:
>            if (frame->nb_samples > avctx->frame_size) {
> If you do it your suggested way, letting av_encode_audio2 handle both the
> resampling and encoding, FFmpeg crashes outright.

You are spreading false claims yet again. Where I suggested that way?

The only one who sugested such nonsense (multiple times) is you.

> However, if you use a source sample rate of 44100, or 48000 (no other
> changes to above data) everything works fine. That's the problem.

You still fail to see the real problem.

Send exact number of samples that encoder wants, if there is samples
left put them in fifo list and use them later.

> Brad

More information about the Libav-user mailing list