[FFmpeg-devel] [PATCH] avformat/mp3: skip junk at the beginning of mp3 files

Michael Niedermayer michaelni at gmx.at
Wed May 27 17:05:46 CEST 2015

On Wed, May 27, 2015 at 02:48:10PM +0200, wm4 wrote:
> Apparently it can happen that a mp3 file has junk data between id3 tag
> and actual mp3 data. Skip this to avoid outputting nonsense timestamps.
> (Two packets had the same timestamps, because the mp3 parser failed to
> compute a frame duration.)
> In this case, the junk consisted of 1044 bytes of zero, which
> incidentally is the same size as normal mp3 frames in this stream. I
> suspect the mp3 was edited with some tool which wiped the Xing/LAME
> headers. Data near the end of the file suggests it was encoded with
> "LAME3.97", but the normal Xing/LAME headers are missing. So this could
> be "normal". mpg123 also attempts to skip at least 64KB of junk data by
> scanning for headers.
> ---
> This assumes the stream buffer is not smaller than 64KB + max. mp3 frame
> size, or the seeks could turn into a problem.
> ---
>  libavformat/mp3dec.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)



Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The educated differ from the uneducated as much as the living from the
dead. -- Aristotle 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150527/33353d58/attachment.asc>

More information about the ffmpeg-devel mailing list