[Libav-user] avcodec_decode_audio4 yields silence (zero data)
Misha Penkov
misha.penkov at gmail.com
Fri Jun 15 13:50:01 CEST 2012
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tutorial03.c
Type: text/x-csrc
Size: 16502 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20120615/7c9da69f/attachment.bin>
More information about the Libav-user
mailing list