Hi,
I am trying to obtain the audio stream from a set of videos. I am using the
following function to decode the audio:
int Video::getAudioPacket(short*& audio_out)
{
AVPacket packet;
//read into the video looking for the next stream
while(av_read_frame(m_pFormatCtx, &packet)>=0)
{
//is this packet from the audio stream?
if(packet.stream_index == m_audioStream)
{
int outsize = AVCODEC_MAX_AUDIO_FRAME_SIZE;
int decoded = avcodec_decode_audio3(m_pACodecCtx, audio_out,
&outsize, &packet);
av_free_packet(&packet);
if(decoded < 0)
{
/* error */
printf("Error decoding the audio(return value: %d)\n", decoded);
continue;
}
//obtain the number of samples from the number of decoded bytes
outsize /= sizeof(short);
av_free_packet(&packet);
return(outsize);
}
av_free_packet(&packet);
}
//at the end of the file we do not read anything
return(0);
}
In some videos I am getting the right data, but in others I just get 0'os. The
videos I am getting 0'os for have been edited by other people, but ffmpeg does
not crash when decoding them, not complains (except for an initial message
"[mp2 @ 0x10302de00]Header missing" which I am not sure whether I have to
ignore or not).
The funny thing is that ffmpeg in command line does decode these videos and I
do get non-zero oputputs.
What am I doing wrong?
Thanks for your help
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user