What is the difference between a video codec and a container?
The codec determines how the video is compressed; the container is the file format holding the compressed streams together. .mp4 is a container — it tells you almost nothing about what is inside.
The container — MP4, MKV, MOV, AVI, WebM. It bundles the video stream, one or more audio streams, subtitles, chapters and metadata into a single file, and stores the information needed to keep them synchronised.
The codec — H.264, H.265/HEVC, AV1, VP9, ProRes. It defines the compression algorithm: how the video data is reduced in size, and how it must be decoded to play.
Why this explains a common frustration. A file may refuse to play, or play with no sound, despite having a familiar extension — because the container is supported but the codec inside it is not. The extension describes the box, not the contents, which is why "convert it to MP4" sometimes fixes nothing.
The main video codecs:
H.264 (AVC) — the universal compatibility baseline. Supported by essentially everything, hardware-accelerated everywhere, and less efficient than newer options.
H.265 (HEVC) — roughly half the file size at similar quality. Encumbered by complex patent licensing, which slowed adoption considerably and is why support is inconsistent.
AV1 — royalty-free, developed by an industry consortium partly in response to HEVC's licensing. More efficient again, computationally demanding, and now widely used by streaming services.
VP9, its predecessor.
ProRes and DNxHD — editing codecs, much larger files, designed for fast decoding and repeated re-encoding rather than distribution.
Audio codecs sit alongside: AAC, MP3, Opus, FLAC, and lossless surround formats.
Lossy versus lossless. Almost all distribution codecs are lossy — data is permanently discarded. Re-encoding a lossy file loses more each time, which is why repeatedly re-uploaded video degrades visibly.
Hardware acceleration matters practically: a device with a dedicated decoder for a codec plays it efficiently; without one, software decoding drains battery and may stutter.