[Libav-user] Audio quality loss while encoding

Brad O'Hearne brado at bighillsoftware.com
Wed Apr 24 19:43:42 CEST 2013

On Apr 24, 2013, at 8:30 AM, Claudio Freire <klaussfreire at gmail.com> wrote:

> On Wed, Apr 24, 2013 at 8:21 AM, Pradeep Karosiya <praks411 at gmail.com> wrote:
>> The codec id used is AV_CODEC_ID_AAC. The encoding goes fine but I'm getting
>> some noise is the final audio output. The quality is getting degraded.
>> However if the number of channels is 1 then I'm getting same quality as the
>> input file
> I also experienced this when encoding AAC, so I stopped using AAC.
> I'm not using the very latest ffmpeg, so I didn't bother reporting the
> issue, and it's been on my To-Do to check the latest version for a
> while. Been busy and all. Anyway, I thought I'd say "me too", and add
> that it does seem related to the AAC encoder, because it only happens
> with AAC.

This seems like some level of vindication / relief for this mortal -- as is probably apparent from my other thread, this is the exact problem I am having too. I am heavily suspecting weirdness in either resampling, or the nature of the expected data buffer to the encoder -- that's actually contained within a frame, so the data filling occurs within this function call: 

                                                     (const uint8_t *)destinationData[0],

To revisit this, my destinationData variable is declared as: 

                uint8_t **destinationData = NULL;

It is populated with data from resampling as in: 

                returnVal = swr_convert(resamplerCtx,
                                        (const uint8_t **)sourceData,

from a source data array declared similarly as: 

                uint8_t **sourceData = NULL;

My questions revolve around this parameter in the avcodec_fill_audio_frame function: 

                 (const uint8_t *)destinationData[0],

1. Is that the proper pointer to be passing? It works (to the degree that the return code is success). I've tried sending: 

		(const uint8_t *)destinationData,


		(const uint8_t *)&destinationData,


                 (const uint8_t *)&destinationData[0],

and all three of those blow up. I wouldn't otherwise doubt the original line (as it produced good audio with another sample format), but I've got little in the equation here that can be changed, so I'm reconsidering everything. 

2. For planar data, what exactly is the expected structure of the data array? 

is it: 

data[0] -> plane 1
data[1] -> plane 2

or is it

data[0] -> plane 1
data[0 + plane_size] -> plane 2

or something else? 



More information about the Libav-user mailing list