membraneframework / membrane_core

The core of the Membrane Framework, advanced multimedia processing framework
https://membrane.stream
Apache License 2.0
1.22k stars 35 forks source link

MP4 plugin generates incorrect sequence numbers for `moof` boxes #765

Closed jerzywilczek closed 4 months ago

jerzywilczek commented 4 months ago

According to MPEG-4 part 12 section 8.8.5, sequence numbers from mfhd (movie fragment header or moof header) box should form an increasing sequence.

Currently, the mp4 plugin creates a series of moof boxes for each track in a file, and each of these sequences is monotonic, but the sequence of all moof sequence numbers is not monotonic.

An example:

What is produced:

  1. moof for track 1 with sequence number 6
  2. moof for track 2 with sequence number 6
  3. moof for track 2 with sequence number 7
  4. moof for track 1 with sequence number 7

What should be produced:

  1. moof for track 1 with sequence number 6
  2. moof for track 2 with sequence number 7
  3. moof for track 2 with sequence number 8
  4. moof for track 1 with sequence number 9

This is not a critical error, since according to the spec the sequence numbers are a safety check, which allows readers to verify integrity of the sequence, but it would be nice if this got fixed.

darthez commented 4 months ago

Since this is nice to have and does not seem to actually break anything we are not going to work on it. However feel free to contribute with a PR 🫠

jerzywilczek commented 4 months ago

This is a bit disappointing, since the spec states this should be a hard error, most players just ignore this section.