The box and what is in it
MDN's definition: a media container is a file format that encapsulates one or more media streams, audio or video, along with metadata, so they can be stored and played together. A video file therefore has at least three parts that can each be chosen separately: the container (the extension you see), the video codec and the audio codec. MDN also warns that support for a container implies nothing about the codecs inside it; a browser that opens MP4 files still cannot play an MP4 whose video is in a codec it lacks.
The containers
| Container | Extension | Video codecs | Audio codecs | Where it fits |
|---|---|---|---|---|
| MP4 | .mp4, .m4v | H.264 (AVC), H.265 (HEVC), AV1, VP9 | AAC, MP3, Opus, FLAC | The industry standard; plays everywhere |
| WebM | .webm | VP8, VP9, AV1 | Opus, Vorbis | Open and royalty-free, built for the web; native in most browsers |
| QuickTime | .mov | H.264 and many older codecs | AAC, ALAC, MP3 | Apple's format; cameras and editing apps; limited browser support |
| 3GP | .3gp | H.264, H.263, MPEG-4 Part 2 | AAC, AMR | Older phones and slow networks |
| Ogg | .ogv, .ogg | Theora, VP8, VP9 | Vorbis, Opus, FLAC | Never widely enough supported to be a first choice |
Two of these do the work. MDN describes MP4 as the industry standard for video content, widely supported across devices and browsers, and WebM as an open, royalty-free container designed for modern web use with native support in most browsers. QuickTime, the MOV format, is what cameras and Apple's editing tools write; MDN says browser support for it is limited to older Safari versions and browsers that had the QuickTime plugin, which is why a MOV straight from the camera needs converting before it goes on a page.
The codecs
| Codec | Licensing | Browser support | Note |
|---|---|---|---|
| H.264 (AVC) | Patented, licensed | Every major browser | The safe fallback; free to stream when the video is free to viewers |
| H.265 (HEVC) | Patented, licensed | Depends on operating system, hardware and browser | Smaller files than H.264, but support is conditional |
| VP9 | Open, royalty-free | Every major browser | The WebM workhorse; no alpha in Safari |
| AV1 | Open, royalty-free | All browsers; Safari only on devices with a hardware decoder | Best compression of the five; MDN's first recommendation |
| VP8 | Open, royalty-free | Every major browser | Older; allows an alpha channel where supported |
Licensing explains the split. MDN describes H.264 as proprietary with patents held by several parties, though the patent pool charges no fee for streaming internet video that is free to viewers, and HEVC as proprietary with fees charged to developers. VP8, VP9 and AV1 are open and royalty-free. On support, H.264, VP8 and VP9 play in every major browser; AV1 plays everywhere but in Safari only on devices with a hardware decoder, which MDN lists as M3 Macs and later, the iPhone 15 Pro and the iPhone 16 onward.
What to export for a website
MDN's recommendation for general web video has two parts, an open option first and the proprietary one as the fallback: WebM with AV1 video and Opus audio, then MP4 with H.264 video and AAC audio, which it calls a broadly supported combination, by every major browser. The video element lists both and the browser takes the first it can play:
<video controls width="1280" height="720" poster="clip.jpg">
<source src="clip.webm" type="video/webm; codecs=av01,opus">
<source src="clip.mp4" type="video/mp4">
</video> If only one file is practical, MDN's advice is the format with the broadest reach, MP4. The video compressor writes MP4 with H.264 and AAC, or WebM with VP9 and Opus where the browser cannot encode H.264, and the video resizer brings a 4K camera file down to the size the page actually shows. Audio-only uses of a clip go through the audio extractor.
Which file for which job
| Job | Export | Why |
|---|---|---|
| Social media upload | MP4, H.264 + AAC | Accepted everywhere |
| Video on your own website | WebM (AV1 or VP9) plus MP4 fallback | Smaller files for most visitors, playback for all |
| Sending to a client or colleague | MP4, H.264 + AAC | Opens in every player without a plugin |
| Short silent loop on a page | MP4 or WebM, muted and autoplaying | A fraction of the size of a GIF; the video to GIF converter is for the places that only take GIFs |
| Archive of the original | Whatever the camera wrote, often MOV | Keep it; every conversion starts from here |
Converting without losing more than you must
- Change the container, keep the codec when you can. A MOV with H.264 inside becomes an MP4 by remuxing, with no re-encoding and no loss.
- Trim before you re-encode. The video trimmer cuts the clip first, so the expensive step runs on fewer seconds.
- Re-encode once, from the original. Each generation of lossy encoding discards detail; compress the master, not the last export.
- Match the target. A 1080p page slot does not need a 4K file; resolution and bitrate, not the container, set the size.
Frequently asked questions
What is the difference between a container and a codec?
MDN defines a media container as a file format that wraps one or more media streams, video and audio, together with metadata, so they can be stored and played back together. The codec is the compression method used for each stream inside. MP4, WebM and MOV are containers; H.264, VP9 and AV1 are video codecs. The file extension tells you the container, not the codec.
Is MP4 or WebM better?
For reach, MP4 with H.264 video and AAC audio: MDN calls it a broadly supported combination, by every major browser. For efficiency and licensing, WebM with AV1 video and Opus audio, which MDN lists first because every part is open and royalty-free and well supported, except Safari on older Apple devices. The usual answer is both, WebM first and MP4 as the fallback.
Why does my MOV file not play in the browser?
MDN says browser support for QuickTime is limited to older versions of Safari and browsers that had Apple's QuickTime plugin, which no longer exists. A MOV usually holds H.264 video that browsers can decode, so remuxing or converting it to MP4 fixes playback without a visible quality change.
Does converting between formats lose quality?
Changing the container alone does not; the streams are copied. Changing the codec re-encodes the picture, which always costs some detail, so convert from the original rather than from an earlier conversion, and keep the original.
Which format should I upload to social platforms?
MP4 with H.264 and AAC, the combination MDN says every major browser supports and the one every upload form and player accepts. Export it at the resolution the platform asks for and keep the original.
Sources
- MDN Web Docs: Media container formats (definition of a container; MP4, WebM, QuickTime, Ogg and 3GP with the codecs each holds; WebM as an open royalty-free container, MP4 as the industry standard; QuickTime support limited to older Safari; MIME types)
- MDN Web Docs: Web video codec guide (AV1, AVC, HEVC, VP8 and VP9 with containers, licensing and browser support; the recommendation of WebM with AV1 and Opus first, MP4 with AVC and AAC as the broadly supported fallback)