[Libav-user] Reading from mp3 files ends pre-maturely

Taha Ansari mtaha.ansari at gmail.com
Wed Jun 26 13:57:10 CEST 2013


Hi!

I have made following sample program:


int main(int argc, char **argv)
{
    /* register all formats and codecs */
    av_register_all();
    avcodec_register_all();
    avformat_network_init();
    avdevice_register_all();

    AVFormatContext* fmt = NULL;
    avformat_open_input( &fmt, "mp3.mp3", NULL, NULL );
    int fcount = 0;
    while(1)
    {
        int rv = av_read_frame(fmt, &input_packet);
        if ( rv <0 )
        {
            break;
        }
        fcount ++;
    }
}

It reads from an mp3 file, and counts total frames read. If I supply an mp3
file as input, I read lesser frames (810 total in my case), and if I
specify an mp4 audio file (mp4.mp4 - which is same as mp3 file, converted
by FFmpeg command line), I read total 912 frames. So in case of mp3, I read
about 1-(810/912)*100  = 11.18% less than original duration.

My simple question is: why does this happen?

It is necessary I understand this part because while converting between
different audio formats, converting mp3 to mp4 (aac) actually writes about
11% lesser frames. So if the total duration of input mp3 file is about
21.16 seconds, only 18.83 seconds of output file is generated (which is
fine till that mark), but afterwards it ends abruptly.

Can anyone raise the curtain from this mystery?

Thanks for your time!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20130626/06420cc6/attachment.html>


More information about the Libav-user mailing list