[Libav-user] # of audio samples, calculated vs. codec context
Brad O'Hearne
brado at bighillsoftware.com
Tue May 21 19:36:06 CEST 2013
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).
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20130521/35dee530/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screen Shot 2013-05-21 at 10.30.52 AM.png
Type: image/png
Size: 16642 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20130521/35dee530/attachment.png>
More information about the Libav-user
mailing list