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.
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
- 1For HLS and Media Source Extensions, the initialization segment is an
ftypbox followed by amoovbox that declares tracks and sample descriptions but holds no samples, and anmvexbox insidemoovsignals that fragments follow. Media then arrives asmoofboxes, each describing samples whose bytes sit in themdatbox or boxes after it. - 2A regular MP4 cannot be appended to a Media Source Extensions
SourceBufferunchanged: the W3C ISO BMFF byte stream format requires an append error when themoovbox contains samples or lacksmvex. 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 containmvex. 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. - 3Every track fragment needs a
tfdtbox carrying its base decode time: HLS requires one in eachtraf, 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 itsdefault_base_moofflag. - 4Start 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
faststartoption 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
- W3C: ISO BMFF Byte Stream Format (initialization segments, media segments, random access points)
- RFC 8216: HTTP Live Streaming, sections 3 (Media Segments), 3.3 (Fragmented MPEG-4), and 4.3.2.5 (EXT-X-MAP)
- W3C: Media Source Extensions (coded frame processing and random access points)
- FFmpeg Formats Documentation: MOV/MPEG-4/ISOMBFF muxers, Fragmentation and movflags
- FFmpeg Documentation: section 3.1, Streamcopy
- MDN: Transcoding assets for Media Source Extensions
- Apple: HLS Authoring Specification for Apple Devices
- Apple: About the Common Media Application Format with HTTP Live Streaming (HLS)
- DASH-IF Interoperability Points v4.3, section 3.2.1 (segment format constraints)