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.
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:
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
| MP4 | WebM | |
|---|---|---|
| Origin | MPEG-4 Part 14 (2001), based on QuickTime | Google (2010), a Matroska subset |
| Structure | ISO BMFF boxes | EBML elements (Segment, Cluster, Block) |
| Codecs | Practically anything: H.264, HEVC, AV1, AAC, MP3 | Spec-limited: VP8/VP9/AV1 + Vorbis/Opus |
| Licensing | Container free; common codecs patented | Fully royalty-free end to end |
| Browser support | Universal, including Safari/iOS | Chrome, Firefox, Edge; partial Safari |
| Best for | Maximum compatibility, delivery default | Royalty-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
- Container— Container format
The file structure that wraps encoded media streams and metadata — the box, not the contents.
- Codec— Coder-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.
- Muxing— Multiplexing
Packing encoded streams into a container. Demuxing unpacks them. Remuxing between compatible containers is lossless and fast.
- Fragmented MP4— fMP4
An MP4 layout of independent moof/mdat fragments — the basis of CMAF and modern adaptive streaming.
- EBML— Extensible Binary Meta Language
The binary element format behind Matroska and WebM; self-describing and skip-safe for forward compatibility.
- moov— Movie Box
MP4's index box. Its position in the file (front vs. back — "faststart") determines how quickly web playback can start.
What is Opus? The Open Audio Codec Explained
What is Opus? How the royalty-free IETF audio codec combines SILK and CELT, its 5 ms latency and WebRTC role, and how Videospan uses it for browser recording.
What is MP4? MPEG-4 Container Format Explained
Learn what the MP4 container format (MPEG-4 Part 14) is, how MP4 files work, which codecs MP4 supports, and how Videospan uses MP4 for web delivery today.