A codec is the method used to compress the video or audio itself (for example H.264, HEVC, AV1 or AAC), while a container is the file format that wraps those compressed streams together with subtitles, chapters and metadata (for example MP4, MKV or MOV). The file extension tells you the container, not the codec - two MP4 files can contain completely different codecs, which is why one plays and the other does not.
Below we explain each in more detail, list the common combinations and which ones work, and show how to tell what is inside a file and how to fix playback problems caused by the wrong codec or container.
What a codec does
The word codec comes from coder-decoder. A video codec defines how pictures are compressed into a bitstream and how that bitstream is turned back into pictures. Audio codecs do the same for sound. Codecs determine most of what you care about: quality at a given file size, how much processing power playback needs, and which devices can decode the result.
Common examples:
- Video delivery codecs: H.264 (AVC), H.265 (HEVC), AV1, VP9.
- Editing and intermediate codecs: Apple ProRes, Avid DNxHD and DNxHR.
- Lossless and archival codecs: FFV1, HuffYUV.
- Audio codecs: AAC, MP3, Opus, AC-3 (Dolby Digital), E-AC-3, FLAC, PCM.
Note that a codec (the format) and an encoder (the software that produces it) are different things. x264, NVIDIA NVENC and Intel Quick Sync all produce H.264, but with different speed and quality characteristics.
What a container does
A container (sometimes called a wrapper or file format) is the box that holds everything together. A typical file has one video stream, one or more audio streams, perhaps subtitle tracks and chapters, plus metadata such as title, creation date and rotation. The container stores these streams side by side, records how they are synchronised, and includes an index so players can seek.
The container decides what can go in the file - which codecs, how many tracks, which subtitle formats - but it has little effect on picture quality. Moving the same H.264 stream from MKV to MP4 does not change a single pixel.
The analogy
Think of the container as an envelope and the codec as the language the letter is written in. The envelope (MP4, MKV, MOV) tells the postman how to handle it. But if the letter is in a language the reader does not know (HEVC on a device without an HEVC decoder), opening the envelope does not help - they still cannot read it.
Common containers and what they hold
| Container | Typical video codecs | Typical audio codecs | Notes |
|---|---|---|---|
| MP4 (.mp4, .m4v) | H.264, HEVC, AV1 | AAC, AC-3, E-AC-3, Opus | The most widely supported. Limited subtitle support (mainly mov_text). |
| MKV (.mkv) | Almost anything | Almost anything | Very flexible: many audio and subtitle tracks, chapters, SRT and ASS subtitles. |
| MOV (.mov) | H.264, HEVC, ProRes | AAC, PCM | Apple's QuickTime format, common in cameras and editing. |
| WebM (.webm) | VP8, VP9, AV1 | Opus, Vorbis | A restricted form of Matroska designed for the web. |
| AVI (.avi) | MPEG-4 Part 2, MJPEG, older codecs | MP3, PCM | Old and limited; poorly suited to modern codecs with B-frames. |
| MXF (.mxf) | DNxHD, DNxHR, XDCAM, ProRes | PCM | Professional broadcast and editing workflows. |
| MPEG-TS (.ts, .m2ts, .mts) | H.264, HEVC, MPEG-2 | AAC, AC-3 | Used for broadcast and AVCHD cameras; tolerant of interruptions. |
For a closer look at the two most popular containers, see MKV vs MP4.
Why compatibility depends on both
For a video to play, the player must understand the container and be able to decode every codec inside it. That leads to some common situations:
- "MP4 won't play on my TV" - the TV reads MP4 fine but may not support the codec inside (often HEVC at a high profile, 10-bit H.264, or AV1).
- "Video plays but no sound" - the video codec is supported but the audio codec (often AC-3, E-AC-3 or DTS) is not.
- "My editor won't import MKV" - many editing programs do not accept MKV as a container at all, even if the H.264 inside is fine.
- "I renamed .mkv to .mp4 and it broke" - renaming a file changes the extension but not the container structure. Some players still cope by detecting the real format; many do not.
Some combinations simply are not allowed. WebM, for example, only accepts VP8, VP9 and AV1 video with Vorbis or Opus audio, so you cannot put H.264 in a WebM file. AVI handles modern codecs poorly. ProRes is normally carried in MOV, and DNxHR in MXF or MOV.
How to see what is inside a file
The extension alone will not tell you the codec. Use one of these:
- MediaInfo: a free tool that shows every stream, codec, profile, bitrate and colour setting.
- VLC: play the file and open Tools > Codec Information.
- FFprobe: run
ffprobe -hide_banner input.mp4to list the container and each stream.
Changing the container vs changing the codec
If the codecs inside are fine and you only need a different container, you can remux. This copies the streams into a new container without re-encoding, so it is fast and lossless:
ffmpeg -i input.mkv -map 0:v -map 0:a -c copy output.mp4
The -map options here keep the video and audio but leave out subtitle tracks, which MP4 may not accept in their original format. If the codec is the problem, you need to transcode - decode and re-encode - which takes longer and, with lossy codecs, loses a little quality each time. Our guides on converting video on Windows and what video encoding is cover that process.
Doing it with Movie Encoder
Movie Encoder shows full media info for every file you add - container, each video, audio and subtitle stream, codec, resolution, frame rate, bit depth, colour and HDR information and bitrates - so you can see straight away whether a problem is the container or the codec. It can remux with stream copy when only the container needs to change, or re-encode when the codec does.
When you pick an output, it warns you about codec and container combinations that do not work, and it only offers codecs and containers that its FFmpeg build actually supports.
Frequently asked questions
Is MP4 a codec?
No, MP4 is a container. It most often holds H.264 or HEVC video with AAC audio, but it can carry other codecs as well.
Does the container affect video quality?
No. The codec and its settings determine quality. Moving the same stream from one container to another leaves every frame unchanged.
How do I find out which codec a file uses?
Use a tool such as MediaInfo, VLC's codec information window or ffprobe. The file extension only tells you the container.
