MP4 files with multiple moov boxes should be rejected as invalid
Categories
(Core :: Audio/Video: Playback, defect, P3)
Tracking
()
People
(Reporter: jbauman, Unassigned)
References
Details
Per the MP4 spec ISOBMFF (ISO 14496-12:2015) § 8.2.1.1 (publicly available here), a file should contain "Exactly one" moov box. However, at least since the test case for bug 1185230 was added, we've supported files which contain multiple moov boxes by merging them. It's not clear this was intentional, so unless such invalid files are prevalent in the wild, we should fix the test and update the code to properly reject such files as invalid.
This was accidentally discovered when the mp4parse-rust library was updated in PR #252. See also PR #263 which (potentially temporarily) restores the previous behavior.
I tested this a little and Chrome appear to (somewhat parse the file), but do eventually error (you can look at chrome://media-internals to see the logs).
It would be nice to not accept invalid files, but I don't have strong feelings about dealing with this. I see the primary downside of us allowing this as an ongoing dev burden to remember that actual parsing is different than the spec, and in the immediate term I'm not sure that's going to hurt too badly.
I can think of two approaches for getting a better handle on if we can remove this:
- Telemetry - are any sites in the wild actually giving us files malformed in this way?
- Crafting a malformed file that requires this behaviour to play. I can't get
test_case_1185230.mp4play anywhere, maybe at some point it did? I'm also not sure exactly how it was produced. A simpler case, which strikes me as maybe workable is if we took a mp4 file with an audio and video track and split that audio and video track info over 2moovs. In order to play the file parsers would need to parse both to understand both tracks. This would probably be a pain to do, but the resulting file could be useful for testing.
As a follow up to case 2 above, a even simpler case is having a redundant moov. e.g. take a file that plays and add a dummy moov and see if that still plays in various things.
Description
•