[FFmpeg-devel] [PATCH] mkv 0-byte integer parsing

Sebastian Hagen sebastian_hagen
Sun Sep 5 16:22:43 CEST 2010


Hello *,

ffmpeg's Matroska demuxer has a bug preventing it from parsing mkv uints 
with a length of 0 bytes correctly, even though those are valid 
according to the Matroska specs[1] and mkv files containing them can be 
demuxed correctly by other software. This bug will manifest in any 
ffmpeg binaries attempting to parse problematic mkv files (e.g. ffmpeg 
and ffplay) as well as any non-ffmpeg software using libavf for mkv 
demuxing, notably mplayer.

I am attaching a small media file that demonstrates this bug, as well as 
a patch that fixes it for me.

Sebastian Hagen


[1] <http://www.matroska.org/technical/specs/rfc/index.html>, section 2.4.

---------- bug reproduction:
$ ./ffmpeg -i ~/tmp/0byte_uint_2.mkv
FFmpeg version SVN-r25042, Copyright (c) 2000-2010 the FFmpeg developers
   built on Sep  5 2010 16:05:27 with gcc 4.4.5 20100816 (prerelease)
   configuration:
   libavutil     50.25. 0 / 50.25. 0
   libavcore      0. 6. 0 /  0. 6. 0
   libavcodec    52.87. 1 / 52.87. 1
   libavformat   52.78. 3 / 52.78. 3
   libavdevice   52. 2. 1 / 52. 2. 1
   libavfilter    1.38. 1 /  1.38. 1
   libswscale     0.11. 0 /  0.11. 0
[matroska,webm @ 0x11dd470] Invalid element
/home/sebastian/tmp/0byte_uint_2.mkv: Invalid data found when processing 
input

---------- after applying ffmpeg_0byte_uints_try1.diff:
$ ./ffmpeg -i 0byte_uint_2.mkv
FFmpeg version SVN-r25042, Copyright (c) 2000-2010 the FFmpeg developers
   built on Sep  5 2010 14:31:25 with gcc 4.4.5 20100816 (prerelease)
   configuration:
   libavutil     50.25. 0 / 50.25. 0
   libavcore      0. 6. 0 /  0. 6. 0
   libavcodec    52.87. 1 / 52.87. 1
   libavformat   52.78. 3 / 52.78. 3
   libavdevice   52. 2. 1 / 52. 2. 1
   libavfilter    1.38. 1 /  1.38. 1
   libswscale     0.11. 0 /  0.11. 0
[matroska,webm @ 0x11dd470] Estimating duration from bitrate, this may 
be inaccurate
Input #0, matroska,webm, from '0byte_uint_2.mkv': 
 

   Duration: 00:00:00.21, start: 0.000000, bitrate: 64 kb/s
     Stream #0.0: Audio: mp2, 16000 Hz, 1 channels, s16, 64 kb/s
At least one output file must be specified
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ffmpeg_0byte_uints_try1.diff
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100905/915918cf/attachment.txt>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0byte_uint_2.mkv
Type: video/x-matroska
Size: 2022 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100905/915918cf/attachment.mpv>



More information about the ffmpeg-devel mailing list