[FFmpeg-trac] #3937(avformat:new): Inaccurate MP3 seek

FFmpeg trac at avcodec.org
Tue Sep 9 18:33:33 CEST 2014


#3937: Inaccurate MP3 seek
-------------------------------------+-------------------------------------
             Reporter:  sssr33       |                     Type:  defect
               Status:  new          |                 Priority:  normal
            Component:  avformat     |                  Version:  2.3
             Keywords:  mp3          |               Blocked By:
  avformat seek                      |  Reproduced by developer:  0
             Blocking:               |
Analyzed by developer:  0            |
-------------------------------------+-------------------------------------
 '''Summary of the bug:'''
 Seeks to incorrect position inside of avformat/mp3dec.c/mp3_seek()

 This function have next code:

 {{{
 duration = av_rescale(st->duration, filesize, mp3->header_filesize -
 s->data_offset);
 }}}

 I will change it for more convenience:
 {{{
 int64_t headerDataSize = mp3->header_filesize - s->data_offset;
 duration = av_rescale(st->duration, filesize, headerDataSize);
 }}}

 Here is file
 https://mega.co.nz/#!mtwQXSbJ!D7CDinj63ePIZWQuXe_9td8zjpySsH0sPZA2Joh3IF4

 Original code will have (filesize / headerDataSize) > 1.0 on test file.
 And after that duration will be much greater than st->duration and I think
 this will cause inaccurate seek.

 Have tried on ffplay from Zeranoe. And also have this bug in ffmpeg 2.3.3

 '''How to reproduce:'''
 {{{
 % ffplay 05._Du_hast.mp3
 }}}
 And then seek to end and you will see that playback not stops.

 '''Possible fix:'''

 {{{
 // at begining
 int64_t headerDataSize = mp3->header_filesize - s->data_offset;

 // original code...

 // change duration = av_rescale(st->duration, filesize,
 mp3->header_filesize - s->data_offset); to this:
 if (filesize <= headerDataSize)
 {
     duration = av_rescale(st->duration, filesize, headerDataSize);
 }
 else
 {
     duration = st->duration;
 }
 }}}

--
Ticket URL: <https://trac.ffmpeg.org/ticket/3937>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list