<div dir="ltr"><div><div><div>Hi!<br><br></div>I have made following sample program:<br><br><br>int main(int argc, char **argv)<br>{<br>    /* register all formats and codecs */<br>    av_register_all();<br>    avcodec_register_all();<br>
    avformat_network_init();<br>    avdevice_register_all();<br><br>    AVFormatContext* fmt = NULL;<br>    avformat_open_input( &fmt, "mp3.mp3", NULL, NULL );<br>    int fcount = 0;<br>    while(1)<br>    {<br>
        int rv = av_read_frame(fmt, &input_packet);<br>        if ( rv <0 ) <br>        {<br>            break;<br>        }<br>        fcount ++;<br>    }<br>}<br><br></div>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.<br>
<br>My simple question is: why does this happen?<br><br></div>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.<br>
<br>Can anyone raise the curtain from this mystery?<br><br>Thanks for your time!<br><div><br><br></div></div>