Hi,
I have a problem when decoding the audio from MPEG videos. I have the following
2 videos (I paste here the ffmpeg info I get when running ffmpeh -i video):
Input #0, mpeg, from 'video1.mpg':
Duration: 00:06:58.32, start: 0.373378, bitrate: 1395 kb/s
Stream #0.0[0x1e0]: Video: mpeg1video, yuv420p, 352x288 [PAR 178:163 DAR
1958:1467], 1150 kb/s, 25 tbr, 90k tbn, 25 tbc
Stream #0.1[0x1c0]: Audio: mp2, 44100 Hz, 2 channels, s16, 224 kb/s
Input #0, mpeg, from 'video2.mpg':
Duration: 00:14:53.96, start: 0.693300, bitrate: 1394 kb/s
Stream #0.0[0x1e0]: Video: mpeg1video, yuv420p, 352x288 [PAR 178:163 DAR
1958:1467], 1150 kb/s, 25 tbr, 90k tbn, 25 tbc
Stream #0.1[0x1c0]: Audio: mp2, 44100 Hz, 2 channels, s16, 224 kb/s
Which, except for their length, they are identical.
Then, I try getting and decoding a packet of their audio using the following
code:
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 the first video I am getting the data without a glitch, but in the second
video I am getting all 0'os as an output (it does not crash, but it is all 0,
and the video DOES HAVE audio).
By the way, in both videos I am getting always an initial message: "[mp2 @
0x10302de00]Header missing" but both videos seem to continue processing after
that.
Any ideas will be most appreciated
Xavier Anguera
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user