A container is a wrapper, not the video
When you see a file ending in .mp4, .mkv, .mov or .webm, the extension names a container. A container is a structured file that packages several separate things together: one or more video streams, one or more audio streams, optional subtitle tracks, and descriptive data such as titles and chapter markers. It also stores timing information so that picture and sound stay in sync during playback.
The actual picture and sound are compressed by video codecs and audio codecs, and the container simply holds the results. This is why two files with the same extension can behave very differently: one may play everywhere, while another may fail on an older device because the codec inside is not supported there. The container tells a player where things are, and the codec tells it how to decode them.
A useful comparison is a shipping box. The box has a standard shape and a label, but what is inside can vary a great deal.
What a container actually stores
Most modern containers share the same basic jobs:
- Streams. Separate tracks for video, audio and subtitles, often in several languages.
- Timing. Timestamps that let a player line up picture and sound and jump to a chosen point.
- An index. A map of where each chunk of data sits, so seeking does not require reading the whole file.
- Metadata. Descriptive tags, covered in more detail in the article on video metadata.
Containers differ in which codecs they officially support, how flexible they are with extra tracks, how well they work for streaming, and how widely devices and software accept them.
MP4
MP4, formally MPEG-4 Part 14, is probably the most widely supported video container. It grew out of the QuickTime file format and is accepted by most phones, browsers, televisions and editing programs. It is most often paired with the H.264 codec for picture and AAC for sound, although it can also hold newer codecs such as the HEVC codec and the AV1 codec.
Its strength is compatibility, which is why it is a common choice when you export settings for upload or sharing. Its weakness is that it is less accommodating than some alternatives when a file has many unusual tracks.
MOV
MOV is Apple’s QuickTime container, and MP4 is closely related to it in structure. MOV files are common in cameras, phones and professional editing workflows, particularly on Apple hardware. A MOV file may contain codecs aimed at editing, which prioritise quality and smooth scrubbing over small file size, and these files can be very large. Because MOV is so flexible, a MOV file is not guaranteed to play on every device even though the extension is familiar.
MKV
MKV is the Matroska container, an open format designed to hold almost anything: many audio tracks, many subtitle tracks, chapters, attachments and a wide range of codecs. That flexibility makes it popular for archiving and for files with multiple languages. The trade-off is that support is less universal on phones, televisions and some editing software, so a file often has to be converted before it plays everywhere.
WebM
WebM is a container designed for the web. It is a restricted profile built on Matroska and is intended for royalty-free codecs: the VP9 codec and the AV1 codec for video, with Vorbis or Opus for audio. Browsers commonly support it, and it is often used for video delivered on web pages. It is less common as a general-purpose file for editing or for sending to someone who just wants to double-click and watch.
Other containers you may meet
AVI is an older Microsoft format that still turns up in archives, though it lacks features that modern formats take for granted. Broadcast and streaming workflows use containers such as MPEG transport stream and fragmented MP4 pieces, which are cut into short segments for delivery. How those segments are packaged is part of HLS and DASH, and the whole chain is described in the streaming pipeline overview.
Choosing a container
There is rarely a single correct answer, but some rules of thumb hold up:
- For sharing, uploading or playing on many devices, MP4 with H.264 video and AAC audio is often the safest choice.
- For archiving a file with several audio or subtitle tracks, MKV tends to be more accommodating.
- For editing on Apple software or working with camera footage, MOV is common and frequently what the equipment produces.
- For video embedded directly in web pages, WebM can be useful, often alongside an MP4 version for wider support.
Changing containers without losing quality
Because the container is separate from the codec, it is sometimes possible to move the streams from one container to another without re-encoding them. This process is often called remuxing. It is fast and does not reduce quality, because the compressed data is copied unchanged. It only works if the destination container supports the codecs involved.
Re-encoding, by contrast, decodes and compresses the video again. With lossy compression that normally costs some quality, so it is best avoided unless the codec itself must change. If a file will not play, checking which codecs it contains, not just its extension, is usually the most useful first step.