Every video file has two layers. The container is the format in the file name, such as .mp4, .mov, .mkv or .avi: a box that holds the video, the sound and the timing that keeps them in step. The codecs are the methods used to compress what's in the box, such as H.264 or HEVC for the picture and AAC or Dolby Digital for the sound. A player has to understand both, which is why two files that both end in .mp4 can behave completely differently.
The envelope and the letter
Think of the container as an envelope and the codec as the language the letter inside is written in. Anyone can open the envelope, but if the letter is in a language they don't read, they're stuck. A media player that "supports MP4" can open the box; whether it can play what's inside depends on the codecs.
A container usually holds:
- one or more video streams
- one or more audio streams, for example different languages, or a commentary
- subtitles, in some containers
- chapters and metadata, such as the recording date or which way up the video goes
- an index and timestamps, so the player can jump to any point and keep sound and picture together
A codec (short for coder/decoder) is the method that squeezes the video or sound into fewer bits, and unpacks it again for playback. Uncompressed, one minute of 1080p video at 30 frames per second takes more than 5 GB. Codecs shrink that to around a hundred megabytes or less, by throwing away detail you're unlikely to notice and storing mostly what changes from one frame to the next.
Common containers and what's usually inside
| Container | Usual video codecs | Usual audio codecs | Where you'll meet it |
|---|---|---|---|
| MP4 (.mp4, .m4v) | H.264, HEVC, AV1 | AAC | Phones, cameras, downloads, the web |
| MOV (.mov) | H.264, HEVC, ProRes | AAC, PCM | iPhones, Macs, many cameras |
| MKV (.mkv) | Almost anything | Almost anything, including AC-3, DTS and FLAC | OBS recordings, downloaded films |
| WebM (.webm) | VP8, VP9, AV1 | Opus, Vorbis | Browser recordings, web video |
| AVI (.avi) | DivX or Xvid, Motion JPEG, DV | MP3, PCM | Old digital cameras, 2000s downloads, some dashcams |
| MTS, M2TS | H.264 | Dolby Digital (AC-3), PCM | AVCHD camcorders, Blu-ray discs |
| WMV (.wmv) | Windows Media Video | Windows Media Audio | Windows Movie Maker, older Windows PCs |
| MPG, VOB | MPEG-2 | MP2, AC-3 | DVDs, older camcorders and TV recorders |
| 3GP (.3gp) | H.263, H.264 | AMR, AAC | Older mobile phones |
"Usual" is doing a lot of work in that table. Most containers can hold several codecs, and MKV can hold almost any. That's exactly why the extension alone can't tell you whether a file will play.
Why the same .mp4 plays here and not there
Here are the four situations behind most "it plays on my computer but not yours" problems.
1. The player can open the container but not the video codec. An .mp4 from a GoPro or an iPhone clip in .mov is often HEVC. A new laptop plays it; an older PC without the HEVC extension shows an error or a black picture. See what is HEVC.
2. The video plays but the audio codec isn't supported. A camcorder's .mts file or a film in .mkv often has Dolby Digital or DTS sound. Many phones, browsers and web tools can't decode those, so you get picture with no sound. Video plays but has no sound goes through the fixes.
3. The codec is supported, but not those settings. Codecs have profiles and levels: optional advanced features and maximum sizes. A TV that plays ordinary 1080p H.264 may refuse 10-bit H.264 or 4K at 60 fps, even though it's "the same codec".
4. The player doesn't know the container at all. QuickTime Player won't open an .mkv file, even when the H.264 video inside is something it plays every day.
Players such as VLC bring their own decoders for almost every codec, so they don't depend on what your system has installed. That's why "try it in VLC" is the first troubleshooting step for so many video problems.
How to see what's inside a file
MediaInfo (free, for Windows, Mac and Linux) shows everything. Open the file and look at the General, Video and Audio sections. Note its naming: it calls the MP4 container "MPEG-4", H.264 "AVC" and Dolby Digital "AC-3".
VLC shows the codecs while a file plays: on Windows, choose Tools › Codec Information; on a Mac, Window › Media Information.
QuickTime Player on a Mac shows the format of files it can open under Window › Show Movie Inspector.
ffprobe, which comes with FFmpeg, prints a summary:
ffprobe -hide_banner input.mp4
Look for the lines starting with Stream. Trimmed down, they look like this:
Stream #0:0: Video: hevc (Main), yuv420p, 1920x1080, 30 fps
Stream #0:1: Audio: aac (LC), 48000 Hz, stereo
The first line is the video codec (HEVC here), the second the audio codec. If there's no Audio line, the file has no sound track at all.
Changing the container vs changing the codec
There are two ways to make a file more compatible, and they're very different jobs.
Remuxing (also called rewrapping) moves the existing video and sound into a different container. Nothing is re-compressed, so it takes seconds and loses nothing. It only works if the new container supports the codecs: H.264 and AAC move between MKV, MOV and MP4 easily. With FFmpeg:
ffmpeg -i input.mkv -c copy output.mp4
Transcoding (re-encoding) decodes the video and compresses it again with a different codec. It's slower and loses a little quality, but it's the only fix when the codec itself is the problem. Old AVI files are a typical case: their DivX, Xvid or Motion JPEG video is better converted to H.264 than rewrapped:
ffmpeg -i input.avi -c:v libx264 -crf 20 -preset medium -pix_fmt yuv420p -c:a aac -b:a 160k output.mp4
The -pix_fmt yuv420p matters here. Motion JPEG from old cameras often uses a colour format that would otherwise produce an H.264 file most players can't open.
So changing a file's extension, or remuxing it, never fixes a codec problem. If an HEVC .mov won't play on a PC, an HEVC .mp4 won't either.
If you have a folder of old clips to join anyway, ClipMerge converts AVI, WMV and other older formats on your device and saves one H.264 MP4, so there's no separate conversion step. Many old camera and camcorder files are also interlaced, which needs its own fix: see interlaced vs progressive video.
"MPEG-4" means three different things
This trips people up when reading device specs and file details:
- MPEG-4 Part 14 is the MP4 container.
- MPEG-4 Part 2 (also called MPEG-4 Visual) is an older video codec. DivX and Xvid are versions of it, and it's common in AVI files from the 2000s.
- MPEG-4 Part 10 is H.264, also called AVC.
AAC sound is part of the MPEG-4 family too. So when an old TV or media player says it plays "MPEG-4", it may mean the DivX-era codec rather than H.264 in an .mp4. Check the manual for the codec names, not just the container.