I had a similar problem, In my case, it was that the decoded audio
buffer size is different from the encoding audio buffer size. The
encoder was expecting a smaller buffer on its input.
The size of the encoder input buffer depends on the encoder setup, and
given by the AVCodecContext::frame_size and the number of channels.
Look into ffmpeg.c or the code snipped below. I hope it helps.
// Write audio to fifo. Reallocate fifo space if needed.
if (av_fifo_realloc2(&audioFifo, av_fifo_size(&audioFifo) +
frame.size) < 0) {
throw TRANSCODE_EXCEPTION("Can reallocate fifo");
}
av_fifo_generic_write(&audioFifo, frame.data, frame.size, NULL);
while (av_fifo_size(&audioFifo) >= frame_bytes) {
// Process audio frame.
av_fifo_read(&audioFifo, frameBuffer, frame_bytes);
int size = avcodec_encode_audio(ctx, bufferPtr, bufferSize,
(short*)frameBuffer);
bufferPtr += size;
bufferSize -= size;
pkt.size += size;
}
On Fri, Feb 27, 2009 at 9:09 AM, Arthur <[email protected]> wrote:
> Hello,
>
> Conversion of WAV and MP3 files to AAC causes problems. The output AAC file
> contains sound, but it is quite cracky.
> I keep channels, bit rate, sample format and frequency the same. Problem
> occurs when converting mono as well as stereo. I'm not sure if it helps to
> use audio_resample, since the code does nothing when they are the same.
> Self-generated audio, such as with output_example gives a perfect AAC file.
>
> When converting WAV to MP3 and vice versa I do not encounter problems. Does
> anyone have a suggestion on this?
>
> I am using the audio_convert.cpp sample, which is attached to this e-mail.
>
> Best regards,
>
> Arthur Roodenburg
>
> _______________________________________________
> libav-user mailing list
> [email protected]
> https://lists.mplayerhq.hu/mailman/listinfo/libav-user
>
>
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user