MediaArea / MediaInfoLib

Convenient unified display of the most relevant technical and tag data for video and audio files.
https://mediaarea.net/MediaInfo
BSD 2-Clause "Simplified" License
636 stars 175 forks source link

Segment size incoherency #181

Open dericed opened 8 years ago

dericed commented 8 years ago

Referenced file http://samples.ffmpeg.org/A-codecs/AAC/faad2-fail.mkv"

<block offset="24" name="Segment" size="1470033">
  <block offset="24" name="Header" size="12">
    <data offset="24" name="Name">139690087</data>
    <data offset="28" name="Size">245070180</data>
  </block>
  <block offset="36" name="SeekHead" size="69">
    <block offset="36" name="Header" size="5">
      <data offset="36" name="Name">21863284</data>
      <data offset="40" name="Size">64</data>
    </block>

For most elements the block can follow this equation

block[@name='Header']/@size + block[@name='Header']/data[@name='Size'] = @size

That is: the declared size of the element's header plus the stored size of the data should equal MediaInfoLib's size that it reports about the entire block. In the above this is true for the SeekHead element but not true for the Segment element.

I haven't tested this widely but see it does work out with some files. I think this test is useful to find a truncated file, but not yet possible. I'm not sure what the block's size of 1470033 refers to.

dericed commented 8 years ago

For reference here's a file where the Segment size is less than its declared size (truncated file), http://samples.ffmpeg.org/archive/all/matroska+h264+vorbis++COLORS.mkv

JeromeMartinez commented 8 years ago

I'm not sure what the block's size of 1470033 refers to.

It is the real size of the physical file. Said in other word, if

block[@name='Header']/@size + block[@name='Header']/data[@name='Size'] > @size

That means that the file is truncated.

dericed commented 8 years ago

Here's an example with test1.mkv from the mkv sample pack

mediaconch -v MediaConch Command Line Interface 16.04.20160530

includes in the result:

    <block offset="24" name="Segment" size="14237">
        <block offset="24" name="Header" size="8">
            <data offset="24" name="Name">139690087</data>
            <data offset="28" name="Size">23339305</data>
        </block>

The file size is 23339337 bytes.

But ...... when I do:

mediaconch -mt -fx --force --ParseSpeed=1 /Users/davidrice/Desktop/Dave/matroska_test_w1_1/test1.mkv then I get:

    <block offset="24" name="Segment" size="23339313">
        <block offset="24" name="Header" size="8">
            <data offset="24" name="Name">139690087</data>
            <data offset="28" name="Size">23339305</data>
        </block>

So perhaps this test should require the coverage attribute to know if it should run.