[FFmpeg-devel] [PATCH] skip leading zeroes in mp3_read_probe() (was "Re: Crash on an MP3 fle")

Gabriel Forté gforte
Mon Dec 3 02:31:16 CET 2007

On Tue, Oct 16, 2007 at 09:48:07PM +0200, Gabriel Fort? wrote:
> On Sat, Oct 13, 2007 at 05:55:23PM +0100, M?ns Rullg?rd wrote:
> > Ronen Mizrahi <ronen at tversity.com> writes:
> > > ffmpeg should not crash.
> > 
> > My FFmpeg doesn't crash, although it does misdetect the file as MPEGPS.
> Hi,
> I've already encountered several MP3 files like this (most notably, but
> not limited to, files generated by some windows program called "EasyCD Creator").
> it's apparently because they're containing around 300 to 400 null bytes
> at the start before any actual ID3 or frame, which makes mp3_read_probe()
> fail to detect the file properly.

attached patch solves this by skipping any zero bytes at the beginning
of the probe data.

as the originally posted sample now returns 404, here's another one:


in this case, the leading zeroes make mp3_read_probe() return a weaker score than
mpegps_probe(), which finds a PACK_START_CODE at offset 0x7ca in the file,
leading to the MPEG PS misdetection.

unpatched result:

Input #0, mpeg, from 'O-MP3-5.mp3':
  Duration: N/A, start: 15362.315944, bitrate: N/A
    Stream #0.0[0x1d0]: Audio: mp2, 48000 Hz, stereo, 80 kb/s
    Stream #0.1[0x1de]: Audio: mp2

with the patch:

Input #0, mp3, from '/tmp/O-MP3-5.mp3':
  Duration: 00:01:05.0, start: 0.000000, bitrate: 80 kb/s
    Stream #0.0: Audio: mp3, 48000 Hz, stereo, 80 kb/s

Gabriel Fort? <gforte at wyplay.com>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: mp3-probe.diff
Type: text/x-diff
Size: 1261 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20071203/5545f7b6/attachment.diff>

More information about the ffmpeg-devel mailing list