Incorrectly parsing SIDX box
benjamintoofer opened this issue · comments
Hi, there seems to be a bug with parsing the SIDX
box from the mp4. I looked into the function that parses the SIDX and I believe this is where the bug exists.
mux.js/lib/tools/mp4-inspector.js
Line 390 in b8df0af
The issue seems to be the way the
earliestPresentationTime
and firstOffset
are being parsed. In the ISO/IEC 14496-12:2012
spec, in section 8.16.3.2
, the syntax dictates that the properties earliestPresentationTime
and firstOffset
are 64 bit values if the version is set to the value of 1
. They are 32 bit values if the version is 0
. It looks like in your code, it assumes that those properties are always parsed as 32 bit values. I know it's not possible to represent a 64 bit integer in Javascript since it is limited to 53 bits. Our solution was to just parse 53 bits and move the index 8 bytes. We also log a warning message that only 53 bits of the value are being parsed.Shaka Player had to do this as well. Here's our sidx parser, which builds on top of a more general box parser, and checks the version number before extracting either 32 or 64 bits:
And here's how we deal with 53-bit precision in a 64-bit field, by reading two 32-bit fields and throwing an exception based on the high bits:
Apache 2 license, same as mux.js. I hope that helps!
Should be fixed in 5.7.0
Thanks for the detailed write up @joeyparrish I created a new story to fix the 64 bit issues that we likely have.