Global Brand, Local Voices: A Practical Guide
Container Formats

Video Container Formats Explained: MP4 & WebM

Learn what video container formats are, how they differ from codecs, and when to use MP4 vs WebM — including fragmented MP4, the basis of CMAF streaming.

A container format is the file structure that bundles encoded video, audio, subtitles, and metadata into one deliverable package. Think of it as a box and its contents: the box (MP4, WebM) holds the contents (an H.264 video stream, an AAC audio track), but the box is not the contents. The same encoded stream can be packed into different containers — moved from an MKV to an MP4 in seconds, with zero re-encoding and zero quality loss.

This is why "the file is MP4, but it won't play" is a real problem: the player supports the container, not necessarily the codec inside it.

Containers are also where our rendering pipeline meets the real world. On the way in, contributors record in their browsers, so we ingest what browsers natively produce — WebM. On the way out, every video we render ships as faststart MP4, and our streaming delivery is built on fragmented MP4. This section documents the container layer the way we actually run it.

How containers are structured

Containers interleave encoded media with an index that maps every frame to its byte offset and timestamp. In MP4, that structure is a tree of boxes: ftyp declares the file type, moov holds the index and metadata, and mdat holds the media itself.

video.mp4
ftyp
file type & compatibility
moov
metadata, duration, tracks
trak
video track
trak
audio track
mdat
all media data (interleaved samples)

A regular MP4 works well for file download and progressive playback, but streaming needs more. Fragmented MP4 splits the file into an init segment plus a sequence of independent moof/mdat fragments:

stream.m4s / CMAF
ftyp
file type & compatibility
moov
metadata, duration, tracks
trak
video track
trak
audio track
moof
fragment 1 header
mdat
fragment 1 media
moof
fragment 2 header
mdat
fragment 2 media
⋯ repeating moof + mdat pairs

Fragmentation matters because each fragment can be generated, delivered, and cached on its own — which is exactly what adaptive streaming protocols need. Fragmented MP4 is the basis of CMAF, letting one set of segments serve both HLS and DASH players. WebM takes a different route to the same goal: its EBML structure groups frames into independent clusters with a seek index.

MP4 vs WebM at a glance

MP4WebM
OriginMPEG-4 Part 14 (2001), based on QuickTimeGoogle (2010), a Matroska subset
StructureISO BMFF boxesEBML elements (Segment, Cluster, Block)
CodecsPractically anything: H.264, HEVC, AV1, AAC, MP3Spec-limited: VP8/VP9/AV1 + Vorbis/Opus
LicensingContainer free; common codecs patentedFully royalty-free end to end
Browser supportUniversal, including Safari/iOSChrome, Firefox, Edge; partial Safari
Best forMaximum compatibility, delivery defaultRoyalty-free pipelines, AV1/VP9 delivery

MP4 (MPEG-4 Part 14)

MP4 is the industry's default container: every browser, phone, TV, and editing tool plays it, and its fragmented variant underpins modern streaming. If you publish video and can only ship one format, it's MP4 — typically with H.264 or AV1 video and AAC audio. See the full breakdown in What is MP4?.

WebM

WebM is Google's open, royalty-free container for the web: a strict subset of Matroska restricted to VP8, VP9, and AV1 video with Vorbis or Opus audio. It's the format browsers' MediaRecorder API produces natively and the one to reach for when patent licensing is a concern — with an MP4 fallback for Safari. Details in What is WebM?.

Other containers you'll encounter

MP4 and WebM cover most web delivery, but a few others still matter: MKV (Matroska) is the flexible superset WebM is cut from, popular for archiving and ripping; MOV is Apple's QuickTime container, common in camera and editing workflows; and MPEG-TS is the broadcast-era transport stream still used for HLS segments in older streaming pipelines.

Glossary

ContainerContainer format

The file structure that wraps encoded media streams and metadata — the box, not the contents.

CodecCoder-decoder

The algorithm that compresses and decompresses video or audio (H.264, AV1, AAC). The codec determines quality and compatibility; the container just carries it.

MuxingMultiplexing

Packing encoded streams into a container. Demuxing unpacks them. Remuxing between compatible containers is lossless and fast.

Fragmented MP4fMP4

An MP4 layout of independent moof/mdat fragments — the basis of CMAF and modern adaptive streaming.

EBMLExtensible Binary Meta Language

The binary element format behind Matroska and WebM; self-describing and skip-safe for forward compatibility.

moovMovie Box

MP4's index box. Its position in the file (front vs. back — "faststart") determines how quickly web playback can start.