I'm trying to decode the audio track from an mp4 file that can play
audio in other media players. However, when I look at the audio in the
frame that I decode, it's all set to 0 (or sometimes -0. The format type
is AV_SAMPLE_FMT_FLTP).

I've been using decode_audio.c to help guild me
in writing the code. My packet decoding looks like:

 int err =
avcodec_send_packet(aCodecCtx, &packet);
 if (err < 0)
 {
 qDebug() =
0)
 {
 err = avcodec_receive_frame(aCodecCtx, aFrame);
 if (err ==
AVERROR(EAGAIN) || err == AVERROR_EOF)
 return;

 if (err < 0)
 {

qDebug() nb_samples; i++)
 for (int ch = 0; ch < aCodecCtx->channels;
ch++)
 {
 float val = 0;
 switch (aCodecCtx->sample_fmt)
 {
 ...
 case
AV_SAMPLE_FMT_FLT:
 case AV_SAMPLE_FMT_FLTP:
 {
 uint8_t *byteBuffer =
aFrame->data[ch];
 float* buffer = (float *)byteBuffer;
 val =
buffer[i];
 break;
 }
 ...
 }

 _audioBuffer.write((const char *)&val,
sizeof(float));
 }
 }

Basically I'm trying to write the audio data as a
series of floats to an output file. I'm not getting any error codes, but
the data is all 0 or values with small exponents. 

The nm_samples is
1024, the data format is AV_SAMPLE_FMT_FLTP and there are 2 channels. Is
there something I'm doing wrong here?
_______________________________________________
Libav-user mailing list
[email protected]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[email protected] with subject "unsubscribe".

Reply via email to