What is Fragmented MP4?

Fragmented MP4 divides an ISO base media file into initialization data and separately deliverable media fragments. Fragments commonly contain moof metadata followed by mdat media data.

Encoded audio and video tracks
Initialization segment plus moof and mdat fragments
Fragmenting moves per-sample metadata out of one central index and into each fragment.

How Fragmented MP4 works

A fragmented MP4 separates stable track initialization from a sequence of separately written runs of timed samples. The initialization portion declares tracks and sample formats and, in the form HLS and Media Source Extensions require, holds no samples, while each fragment carries the run metadata needed to locate and timestamp its adjacent media payload. This differs from a conventional finalized MP4, whose central sample tables describe the complete presentation. Fragmentation supports incremental generation, segmented distribution, and browser append workflows without waiting for a final global index. It changes the container layout, not the codec, and CMAF builds on the same layout so that HLS playlists and DASH manifests can reference one set of segments.

Key facts

  1. For HLS and Media Source Extensions, the initialization segment is an ftyp box followed by a moov box that declares tracks and sample descriptions but holds no samples, and an mvex box inside moov signals that fragments follow. Media then arrives as moof boxes, each describing samples whose bytes sit in the mdat box or boxes after it.
  2. A regular MP4 cannot be appended to a Media Source Extensions SourceBuffer unchanged: the W3C ISO BMFF byte stream format requires an append error when the moov box contains samples or lacks mvex. It is not a valid HLS media segment either: RFC 8216 requires every segment to use a format it describes, and its only MP4 format is fragmented MP4, whose initialization section must have a sample count of zero and contain mvex. Fragmenting is a repackaging step, so FFmpeg can copy existing streams into a fragmented file without re-encoding when the browser already supports the codecs and the existing keyframes fall where segments need to start.
  3. Every track fragment needs a tfdt box carrying its base decode time: HLS requires one in each traf, and the Media Source Extensions byte stream format requires an append error without it. HLS timestamps must continue from the previous segment unless the playlist marks a discontinuity, and the HLS specification warns that unmarked discontinuities can trigger playback errors. Apple’s authoring specification states the rule for fMP4: the track fragment decode time must be consistent with the decode time and duration of the previous segment. In Media Source Extensions, a coded frame whose decode timestamp falls before the previous frame’s, or more than twice the last frame duration after it, makes every track buffer wait for a new random access point. HLS and the byte stream format also both require movie-fragment-relative addressing instead of absolute byte offsets, which FFmpeg writes with its default_base_moof flag.
  4. Start video segments at a random access point. HLS says a segment containing H.264 should include an IDR frame and that frames before the first IDR may be downloaded but discarded; Apple’s authoring specification requires video segments to start with an IDR frame, and DASH-IF guidelines place an IDR-like stream access point at the start of each segment for simple switching. After an initialization segment, a Media Source Extensions track buffer drops coded frames until a random access point arrives.

When Fragmented MP4 matters

Developers choose fragmented MP4 for HLS or DASH segments, for media appended through Media Source Extensions, and for recordings that must stay readable if writing stops early. For a single file that arbitrary players and editors must open, a regular MP4 is usually the safer layout: FFmpeg’s documentation notes that fragmented files are less compatible with other applications.

Common use cases for Fragmented MP4

  • HLS delivery of HEVC or AV1 video to Apple devices, where Apple’s authoring specification requires fMP4; H.264 video may use either fMP4 or MPEG transport stream segments.
  • One set of CMAF segments referenced by both an HLS playlist and a DASH manifest, which Apple describes as allowing efficient caching when delivering to multiple platforms.
  • Custom browser players that append initialization and media segments through Media Source Extensions.
  • Long or live recordings: FFmpeg notes that a fragmented file stays decodable if writing is interrupted and needs less memory when writing very long files.

Working with Fragmented MP4

In FFmpeg, fragmentation is a muxer setting on the mov, mp4, and ismv muxers rather than an encoder setting. The frag_keyframe flag starts a new fragment at each video keyframe, so with that flag the encoder’s keyframe interval decides where fragments begin. Stream copy passes packets through without decoding or encoding them, so copied video keeps its existing keyframes and changing their spacing requires re-encoding. Separate cmaf and dash flags write fragmented output compatible with those formats.

In HLS, fragmented MP4 changes the playlist as well as the media. Every fMP4 segment must have an EXT-X-MAP tag that points to its initialization section, and using that tag in a regular media playlist requires protocol version 6 or higher. Apple notes that HLS defined fragmented MPEG-4 segments in September 2016 and that clients based on earlier revisions will likely not handle CMAF content.

What it costs

  • FFmpeg’s documentation describes fragmented files as less compatible with other applications than regular MP4 files, and says its faststart option does not work with fragmented output.
  • MDN reports that a fragmented file is slightly larger than the original, usually by 1 percent or less, because metadata is spread throughout the file.

How Transloadit helps with Fragmented MP4

Transloadit’s /video/adaptive Robot documents a cmaf value for its technique parameter that produces FFmpeg-based CMAF output, with MPEG-DASH and HLS manifests that reference the same fMP4 segments.

The Robot documentation names fMP4 segments only for technique: cmaf; it does not state the segment container for the hls or dash techniques. It also says CMAF output puts all audio in one adaptation set and points to technique: hls with audio_group for multi-language audio.

Explore Transloadit’s file formats & compression capabilities

Sources

Turn media knowledge into a working pipeline

Connect uploads, processing, AI, storage, and delivery through one declarative API — with the encoding stack, scaling, and format churn handled for you.

Try Transloadit for free