[FFmpeg-devel] a small patch to work around some very corrupted VOB files

Avner Shapiro avner
Mon Oct 27 11:40:43 CET 2008

Hello ffmpeg-devel list.

Recently I tried ffmpeg on some DVDs from my parents' library.
These were recorded by their DVD machine.

When a DVD contained several movies on it, which were recorded on different sessions, that recorder adds a menu.
However, it stores the movies in unified-size 1G VOB files, so the new movie may start in the middle of a file.
Until now, everything is OK.
The problem is that it inserts some additional data between the movies - I did not manage to understand what exactly it is.

Now, ffplay plays the movie fine - it skips over the extra data and continues at the next movie.
So is my favorite player, xine.
But ffmpeg reads and processes until the end of the first movie and then exits.

I played around this a bit, and succeeded to fix that, by just changing libavformat/mpeg.c:
there is a line saying
#define MAX_SYNC_SIZE 100000
If I enlarge that number (e.g. to 2000000 - 2 million), ffmpeg rips the whole file as expected.

Also, sometimes the DVDs are broken further, and I need to dd the VOB file with some errors and skips.
Of course, the resulting file is a bit corrupted (sometimes missing over 10M !), but xine still plays it (showing distorted images for the damaged area and continues forward).
ffmpeg may behave the same, again, by just enlarging MAX_SYNC_SIZE even more (once I had to put there 20,000,000. but then it worked just fine).

I saw in other applications that a similar 100K limit is quite common (gopchop for example. but it still has mpegcat that runs over the whole file).
Is there any reason not to enlarge that number (apart of waiting a bit longer when ffmpeg determines it _is_ the end of the stream)?

My suggestion is, to add an (mpeg-only) option "--corrupt_file_factor" to multiply MAX_SYNC_SIZE at mpegps_read_pes_header() before calling find_next_start_code().
That way the user may perform what I did without recompiling the code.

Best regard,
Avner Shapiro

Software Developer, Jungo - R&D
email: avner at jungo.com
Web:   http://www.jungo.com
Phone: 1-877-514-0537(USA) +972-74-7212121(Worldwide), ext. 286
Fax:   1-877-514-0538(USA) +972-74-7212122(Worldwide)

More information about the ffmpeg-devel mailing list