What is the difference between a container and a codec?
A codec compresses the video or audio (H.264, VP9, AAC, Opus). A container (MP4, WebM, MKV) packages those streams into one file.
Definition
“MP4” describes the box, not what's inside. An MP4 usually holds H.264 video and AAC audio but can hold others. WebM holds VP9 or AV1 video with Opus audio.
In practice
A useful mental model: the codec is the language the picture is written in; the container is the envelope it's mailed in. Changing the envelope (remuxing, e.g. MKV → MP4) is instant and lossless. Changing the language (re-encoding, e.g. VP9 → H.264) takes CPU time and loses some quality.
This is why ffmpeg -c copy is so fast — it only rewrites the container.
Why it matters when downloading video
- Compatibility depends on the codec more than the extension.
- Merging tracks with
-c copyonly works if the container supports both codecs.
Common combinations
| Container | Video codec | Audio codec |
|---|---|---|
| MP4 | H.264 (AVC) | AAC |
| WebM | VP9 or AV1 | Opus |
| M4A | — | AAC |
| MKV | Anything | Anything |
FAQ
Which should I pick for compatibility?
MP4 with H.264/AAC.
Related
Last updated 2026-10-25