[Libav-user] avcodec_decode_audio4 yields silence (zero data)
Misha Penkov
misha.penkov at gmail.com
Fri Jun 15 14:18:35 CEST 2012
I've solved my problem. I wasn't updating the packet correctly in
between calls to decode. Please disregard my previous message.
Michael
On 15 June 2012 20:50, Misha Penkov <misha.penkov at gmail.com> wrote:
> Hi,
>
> I'm playing around with the FFmpeg tutorials at
> (http://dranger.com/ffmpeg/) and trying to update them to the most
> recent version of FFmpeg. I'm having problems decoding audio. In
> particular, the entire data array of the AVFrame I pass in is zero
> after decoding.
>
> Here's the code around the problem area:
>
> int bytes_consumed;
> int got_frame;
> bytes_consumed =
> avcodec_decode_audio4
> (
> aCodecCtx,
> frame,
> &got_frame,
> &pkt
> );
> if (got_frame)
> {
> int bytes_decoded =
> av_samples_get_buffer_size
> (
> NULL,
> aCodecCtx->channels,
> frame->nb_samples,
> aCodecCtx->sample_fmt,
> 1
> );
> int sum = 0;
> int i = 0;
> for (i = i; i < bytes_decoded; ++i)
> sum += abs(frame->data[0][i]);
> fprintf(stderr, "sum: %d\n", sum);
> return bytes_decoded;
> }
>
> The whole data array sums to zero every time, and I get silence as
> output. I'm attaching my full source for reference.
>
> Why does this happen? What am I doing wrong?
>
> ffmpeg version N-41103-g67b7631
> built on Jun 4 2012 17:00:05 with gcc 4.4.3
>
> Thank you in advance for your help.
>
> Cheers,
> Michael
More information about the Libav-user
mailing list