[Libav-user] Audio quality loss while encoding

Alex Cohn alexcohn at netvision.net.il
Wed Apr 24 20:04:27 CEST 2013


On 24 Apr 2013 20:57, "Paul B Mahol" <onemda at gmail.com> wrote:
>
> On 4/24/13, Brad O'Hearne <brado at bighillsoftware.com> wrote:
> > 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:
> >
> > avcodec_fill_audio_frame(_streamAudioFrame,
> >
> > _streamAudioFrame->channels,
> >
> > _streamAudioFrame->format,
> >                                                      (const uint8_t
> > *)destinationData[0],
> >                                                      bufferSize,
> >                                                      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,
> >                                         destinationData,
> >                                         destinationNumberOfSamples,
> >                                         (const uint8_t **)sourceData,
> >                                         sourceNumberOfSamples);
> >
> > 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,
> >
> > and
> >
> >               (const uint8_t *)&destinationData,
> >
> > and
> >
> >                  (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
>
> For planar sample format, each channel is in separate array:
>
> channel left = data[0]
> channel right = data[1]
>
> If you use more than 8 channels, use extended_data instead.

And to set

data[1]=data[0] + plane_size;

is most likely not enough because both data[0] and data[1] must be aligned.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20130424/6d54cd63/attachment.html>


More information about the Libav-user mailing list