MP4

On this page 7

MP4, formally MPEG-4 Part 14 (ISO/IEC 14496-14), is a digital multimedia container format that stores compressed video, audio, subtitles, chapter markers and metadata in a single file, usually with the .mp4 extension. MP4 does not compress anything itself: it packages streams produced by codecs such as H.264, H.265, AV1 and AAC and records the timing information that lets a player present them in sync.

MP4 is built on the ISO base media file format (ISOBMFF), ISO/IEC 14496-12, which in turn was derived from Apple’s QuickTime MOV structure. Because it is an open international standard with near-universal playback support, MP4 is the default delivery container for web video, mobile devices, social platforms and most streaming systems.

How an MP4 file is structured

An MP4 file is a tree of boxes, also called atoms. Each box begins with a 32-bit size and a four-character type code, followed by its payload, which may contain further boxes. A parser can therefore skip any box it does not understand, which makes the format extensible and robust.

The essential separation is between media data and the index that describes it. The mdat box holds the raw encoded samples, while the moov box holds the tracks, timing tables and sample offsets that tell a player where each frame lives and when to show it.

BoxContentsRole
ftypBrand and compatible brandsIdentifies the file variant
moovMovie header and all track metadataGlobal index of the presentation
trakOne track with its media descriptionDefines one video, audio or text stream
stblSample tables for timing, size and locationMaps samples to time and byte offsets
mdatEncoded audio and video samplesCarries the actual media payload
moof and mfraFragment headers and random-access indexEnable fragmented MP4 streaming
Key MP4 boxes

Timing uses a per-track timescale, for example 90,000 ticks per second for video. Decode timestamps and composition offsets allow B-frames to be decoded in one order and displayed in another, and an edit list can trim or shift a track without rewriting the media.

Codecs and streams that MP4 can carry

MP4 supports a registered list of codecs, each identified by a sample-entry code such as avc1 or hvc1. Players rely on this registration, so a stream that is technically storable may still be unplayable on devices that do not recognize its sample entry.

Stream typeTypical codecsNotes
VideoH.264, H.265, AV1, VP9H.264 offers the widest compatibility
AudioAAC, AC-3, E-AC-3, Opus, ALACAAC-LC is the safe default
SubtitlesMPEG-4 Timed Text, WebVTTLimited styling compared with MKV
MetadataChapters, cover art, HDR and rotation dataSupport varies by player
Common streams in MP4

Some codecs are poorly suited to MP4. Professional intermediates such as ProRes are normally stored in MOV, and lossless PCM audio is unevenly supported in MP4 players, so editors often keep masters in MOV or MXF and use MP4 only for delivery.

MP4 compared with other containers

Each container balances compatibility, flexibility and resilience differently. MP4 wins on playback reach, MKV on flexibility, and MPEG-TS on resilience over lossy broadcast links.

ContainerStandard basisStrengthWeakness
MP4ISOBMFF, ISO/IEC 14496-14Universal playback, web and mobileRestricted codec and subtitle list
MOVApple QuickTimeProfessional codecs and timecodeWeaker support outside editing tools
MKVMatroska, EBMLAlmost any codec, rich subtitlesLimited browser and device support
MPEG-TSISO/IEC 13818-1Error resilience in broadcastHigher overhead of about 5-10%
MP4 and related containers

Moving streams between these containers is muxing and demuxing, which copies the encoded data unchanged. Changing the codec itself is transcoding, which decodes and re-encodes and therefore costs time and quality.

Progressive, fast-start and fragmented MP4

The position of the moov box decides how quickly playback can begin. Many encoders write mdat first and append moov at the end, which forces a web player to download the whole index before showing a frame.

VariantLayoutBest use
Standard MP4moov after mdatLocal playback and archiving
Fast-start MP4moov moved before mdatProgressive download on the web
Fragmented MP4 (fMP4)Short moof and mdat pairsDASH, HLS and live streaming
CMAFConstrained fMP4 segmentsOne set of segments for HLS and DASH
MP4 layout variants

Fragmented MP4 splits the presentation into self-describing fragments of typically 2 to 6 seconds. This allows live recording without a final index, adaptive bitrate switching and Common Encryption for DRM, and it is the basis of the CMAF format used by modern streaming services.

Limitations and common mistakes

Most MP4 problems come from the index, the codec choice or confusion between codec and container, not from the format itself.

  • An interrupted recording without a written moov box leaves an unplayable file; fragmented recording prevents this.
  • Forgetting fast-start delays web playback until the full file is downloaded.
  • Treating MP4 as a quality setting is a misconception; quality depends on the codec and bitrate inside.
  • Packing unsupported codecs such as PCM or ProRes produces files that many players refuse.
  • Re-encoding to change containers wastes quality; a remux is lossless and nearly instant.

A plain-language summary

An MP4 file is like a shipping box for video. The pictures and sound are packed inside separately. A packing list tells the player what is in the box and when each part should play.

The box itself does not decide the quality. Quality comes from the codec and the bitrate inside. MP4 is popular because almost every phone, browser and television knows how to open this particular box.

An example from practice

A university media team records a three-hour lecture series and needs it to play in a web learning portal. The recording software produces MKV files with H.264 video and AAC audio, but the portal’s browser player rejects MKV.

Instead of re-encoding, the technician remuxes each file to MP4 with fast-start enabled, copying the existing streams into a new container. Each three-hour file takes under a minute to convert, keeps its original quality bit for bit, and starts playing in the browser within about two seconds because the index sits at the front of the file. For the live sessions, the team switches to fragmented MP4 recording, so a crashed laptop no longer leaves an unreadable file.