Skip to content

isomp4: fragmented mp4 and finalise

commit f73d7d80

isomp4/mux: add a fragment mode for initial moov with data

Used by some proprietary software for their fragmented files.

Adds some support for multi-stream fragmented files

Flow is as follows.
1. The first 'fragment' is written as a self-contained fragmented
   mdat+moov complete with an edit list and durations, tags, etc.
2. Subsequent fragments are written with a mdat+moof and each stream is
   interleaved as data arrives (currently ignoring the interleave-*
   properties).  data-offsets in both the traf and the trun ensure
   data is read from the correct place on demuxing.  Data/chunk offsets
   are also kept for writing out the final moov.
3. On finalisation, the initial moov is invalidated to a hoov and the
   size of the first mdat is extended to cover the entire file contents.
   Then a moov is written as regularly would in moov-at-end mode (the
   default).

This results in a file that is playable throughout while leaving a
finalised file on completion for players that do not understand
fragmented mp4.

commit 0c42f1c3

qtdemux: increase some logging on streams and sample parsing

commit da3981ba

qtdemux: bail out when encountering an atom with a size of 0

A size 0 atom means the atom extends to the end of the file.  No further
valid atoms will ever follow.  Avoids a subsequent scan for an atom from
one byte earlier after encountering a size 0 atom.

commit 17479cd6

qtdemux: fix subsequent moof parsing after moov with valid samples

reset the moof_offset back to its original value like is done in the
error case just before.

Fixes subsequent parsing of a moof following a moov that contains valid
samples in a non-streaming fragmented mp4.

commit 3258f63d

qtdemux: extend edit list when fragmented

When we are fragmented, the edit list may only refer to the portion of
the media that is in the moov.  Extend the edit list stop time when we
if there is only one qt segment and we are reading a fragmented file.

Fixes playback of some fragmented mp4 files generated by proprietary
programs.
Edited by Matthew Waters

Merge request reports