MP4 file breaks MP4 Spec
AnsweredI downloaded an MP4 file from the /media/<cameraId>.mp4 endpoint but noticed I was getting an error from our MP4 Reader that it was failing to parse one of the boxes in the file. Digging into the bytes, here is what I found:
After the Movie Fragment Random Access Box (mfra) there appears to be some extra data that was appended to the end of the file. It appears to be a kind of signature so that the file can be traced back to the device that created it. However, this extra data does not take the form of a box, but rather seems to be just a raw string. In my case, there were 137 bytes that gives the following string:
"29b5406f33174153aa5b3a63938507fe 86a360fed91db31db7aba52fe24ee605\Hanwha Media Server v4.0.0.0\054173c808591c5ff9e96ed75e3dcc7441\hanwha\"
Per the ISO/IEC 14496-12 document for ISO base media file format under section 4.1 File Structure: "Files are formed as a series of objects, called boxes in this specification. All data is contained in boxes; there is no other data within the file."
This also is less than ideal since the Movie Fragment Random Access Box (mfra) is usually placed at the end of the file, and finishes with the Movie Fragment Random Access Offset Box (mfro). That way the file can be scanned backwards by examining the last 32 bits of the file.
This signature does not need to be removed from the MP4, instead I would suggest it be contained with a Free Space Box (free) and placed before the Movie Fragment Random Access Box (mfra). The Free Space Box (free) is defined in the same document under section 8.1.2 Free Space Box.
The MP4 Spec is rather large, so it's possible I may have missed something.
-
Hi @..., that's a good catch! Thank you for doing all this investigation, we really appreciate your feedback.
We confirm the problem and we are determined to fix this in version 4.2 of our software.
Thanks again.
0 -
Hi @...,
Just wanted to let you know that we decided to include a quick fix for that into the upcoming version 4.1. It will be possible to specify an optional GET request parameter "signature" that enables the signature in discussion. The default value of this parameter is set to "false", so you won't have any signature in your exported files unless you explicitly ask your Mediaserver to add it.
And a full-scale fix is coming in 4.2.
Hope you'll find it helpful.
0 -
Hi Matt, the fix is done, starting the next beta version, we will be not sending the signature by default, so the mp4 file is supposed to be correct.
0
Please sign in to leave a comment.
Comments
3 comments