A container, not a codec.
An MP4 file doesn't compress video itself. It's a box that holds separately compressed streams: typically H.264 or H.265 video and AAC audio - and keeps them in sync. That's why two MP4s can behave differently: one plays everywhere, another stutters, not because of the .mp4 wrapper but because of the codec inside.
MP4 · MKV · WebM · MOVaddcodec
H.264 · H.265 · AV1
Boxes, and why “fast start” matters.
MP4 is built on the ISO Base Media File Format: everything lives in nested boxes (atoms). moov holds the metadata and the table mapping timestamps to byte positions; mdat holds the compressed media. Where moov sits changes how fast a video starts on the web.
Compatibility, above everything.
H.264 + AAC, the pair MP4 usually carries, is hardware-accelerated on virtually every phone, computer, smart TV and browser made in the last fifteen years. It's what cameras record, phones export, social platforms accept and streaming services deliver. H.265 roughly halves the size again, at the cost of slightly less universal support.
Pros, cons and limitations.
MP4 vs other video formats.
MP4 has the widest device compatibility; MKV is more flexible for many tracks; WebM targets open web streaming.
How to open an MP4 file.
Pick by what you need: just watching, a quick edit, or professional work, and what it costs.
“video/mp4” isn’t enough. The codecs string says what’s inside.
Browsers, HLS playlists and DASH manifests describe an MP4 with a codecs parameter defined in RFC 6381, such as avc1.640028. Each part encodes the codec’s profile and level, and a player uses it to decide whether it can decode the file before downloading any video. Build one below; the result is checked live against this browser.
Fragmented MP4: how streaming services cut a film into pieces.
A regular MP4 has one big moov index for the whole file. A fragmented MP4 keeps only the track setup in an init segment, then repeats small moof + mdat pairs, each indexing just a few seconds. HLS and DASH serve those pieces separately, and CMAF standardises the format so one set of files works for both. Pick a segment length for a 10-minute, 5 Mbit/s video.
#EXTM3U#EXT-X-VERSION:7#EXT-X-TARGETDURATION:6#EXT-X-MAP:URI="init.mp4"#EXTINF:6.000,seg-1.m4s#EXTINF:6.000,seg-2.m4s…#EXT-X-ENDLIST
Will it start fast, seek fast and stream? Open an MP4 and measure.
This page reads every track’s sample table and works out where each frame’s bytes sit in the file. From that it measures how much has to download before playback can start, how much a seek costs, how evenly audio and video are interleaved, and how the bitrate moves. Then it remuxes the file into fragmented MP4 without re-encoding, plays the result through your browser’s Media Source Extensions, and writes the HLS playlist for it. Everything happens on your device. Both samples are encoded in your browser with WebCodecs, from the same frames: one written the way cameras do, one written for streaming.
#EXTM3U#EXT-X-VERSION:7#EXT-X-TARGETDURATION:2#EXT-X-PLAYLIST-TYPE:VOD#EXT-X-INDEPENDENT-SEGMENTS#EXT-X-MAP:URI="camera-layout-fragmented.mp4",BYTERANGE="1112@0"#EXTINF:2.000,#EXT-X-BYTERANGE:142978@1112camera-layout-fragmented.mp4#EXTINF:2.000,#EXT-X-BYTERANGE:140744@144090camera-layout-fragmented.mp4#EXTINF:2.000,#EXT-X-BYTERANGE:147743@284834camera-layout-fragmented.mp4#EXT-X-ENDLIST