axiomatic-systems / Bento4

Full-featured MP4 format, MPEG DASH, HLS, CMAF SDK and tools
http://www.bento4.com
2.03k stars 483 forks source link

mp4dump decodes `senc` box incorrectly for non-constant IV #960

Open stevemayhew opened 6 months ago

stevemayhew commented 6 months ago

ISO/IEC 23001 spec section 7.2 specifies:

InitializationVector SHALL conform to the definition specified in 9.2. Only one Per_ Sample_IV_Size SHALL be used within a file or Per_Sample_IV_Size SHALL be zero when a sample is unencrypted or a Constant IV is in use. Selection of InitializationVector values SHOULD follow the recommendations of 9.2.

The value should be inherited from the tenc box:

[moov] size=8+911
  [mvhd] size=12+96
...
                [schi] size=8+32
                  [tenc] size=12+20
                    default_isProtected = 1
                    default_Per_Sample_IV_Size = 8

But later in the dump you see that the code guesses (incorrectly) that the value is 0:

[moof] size=8+9781 [mfhd] size=12+4 sequence number = 17494866 [traf] size=8+9757 ... ( 0) 3393 [senc] size=12+6400, flags=2 sample info count = 180 IV Size (inferred) = 0 sample info entries: ( 0) info = [] sub entries: ( 0) bytes_of_clear_data = 515, bytes_of_encrypted_data = 67438087 ( 1)



This leads to bogus values for the sample entry table