[FFmpeg-user] mp3 duration is not correct

Oliver Fromme oliver at fromme.com
Thu Jul 17 19:37:05 CEST 2014

Nicolas George wrote:
 > Le nonidi 29 messidor, an CCXXII, Oliver Fromme a écrit :
 > > The solution is rather simple:  The Xing header contains a
 > > field that holds the length of the file in bytes.  Just
 > > seek to that position and check if there's another header
 > > (instead of EOF that should normally be there).  If there
 > > is, then a concatenated file follows.  This procedure has
 > > to be repeated, in case that more than two files were
 > > concatenated.
 > That could be dangerous, a crafted file may trick lavf into reading much
 > more of the file than reasonable, leading to a possible DoS, especially if
 > the file is accessed by network. If someone implements it, this must be kept
 > in mind in order to avoid it.

Yes, of course, that can always happen when parsing a non-trivial
file structure.  It might make sense to implement a limit for the
number of sections to look for, and print a warning if that limit
is exceeded.

 > A much easier (but also much less accurate, of course) solution would be to
 > compare the size in the Xing header and the size of the file reported by the
 > OS or protocol, and if they do not match, print a warning and/or extrapolate
 > the duration.

A warning won't help users much, except that it confirms that
the length printed by ffmpeg is probably wrong.  Interpolating
will display an incorrect length, too, unless the sections all
have the same bitrate (and don't have a variable bitrate).

Best regards

``We are all but compressed light'' (Albert Einstein)

Donations: http://www.amazon.de/wishlist/A0LHFK68RV8S

More information about the ffmpeg-user mailing list