On May 21, 2013, at 9:28 AM, Paul B Mahol <[email protected]> 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). 

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. 


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. 

Brad
_______________________________________________
Libav-user mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/libav-user

Reply via email to