When someone says «I have an MP4 video», they are giving you useful but incomplete information. MP4 is a container, in other words a box. Inside the box there are one or more streams compressed with a codec, and it is the codec that determines quality, file size and device compatibility. Mixing up the two is the most common cause of problems such as «the file opens but I only get audio» or «the TV says the format is not supported».
What a codec is
A codec (from coder-decoder) is the algorithm that compresses and decompresses data. Uncompressed Full HD video takes up an enormous amount of space: every frame is a matrix of millions of values, repeated dozens of times per second. A codec exploits two kinds of redundancy:
- spatial: similar areas within the same frame, such as a uniform sky;
- temporal: parts that do not change from one frame to the next, such as the background of an interview.
The most widespread video codecs today are H.264 (also called AVC), H.265 (HEVC), VP9 and AV1. For audio we have AAC, Opus, MP3, AC-3 and others. Each has its own bitstream format and needs a specific decoder.
What a container is
The container is the file format that packages the streams and keeps them in sync. It holds:
- one or more video streams;
- one or more audio streams (for example Italian and English);
- optional subtitles;
- chapters, cover art and metadata such as title, date and language;
- an index that lets a player jump to a precise point without reading the whole file.
The container compresses nothing: it only organises. That is why changing container without touching the streams is an almost instant, lossless operation, while changing codec requires a full re-encode.
The most common containers
| Container | Extension | Strengths | Typical limits |
|---|---|---|---|
| MP4 | .mp4, .m4v | near-universal compatibility, web friendly | limited support for some subtitle formats |
| Matroska | .mkv | accepts almost any codec, many tracks, chapters | less supported by some TVs and browsers |
| WebM | .webm | designed for the web, based on Matroska | accepts only specific codecs (VP8, VP9, AV1, Vorbis, Opus) |
| QuickTime | .mov | common in professional editing | often very large files with intermediate codecs |
| MPEG-TS | .ts | resilient to errors, used in broadcast and streaming | more overhead than MP4 |
An .mkv file can contain H.264 video and AAC audio exactly like an .mp4: the compressed content is identical, only the wrapper changes.
Why a file «won't open»
When a player refuses a file, there are almost always three causes.
- The container is not supported. Some TVs read MP4 but not MKV. In that case a container change is enough.
- The codec is not supported. An older device may open the MP4 but lack a decoder for HEVC or AV1. Here you need a re-encode, or a software player that includes the decoder.
- The codec profile or level is too high. Even with the same codec, a 10-bit H.264 video or one with a high level may not be decodable by hardware built for 8 bit.
The typical «I see the picture but hear no sound» case usually means an audio track in a codec the player does not know, for example DTS in an MKV played on a smart TV.
Remuxing and transcoding
Two operations must be kept apart:
- remuxing: the streams are extracted from one container and placed in another, untouched. It is fast and does not degrade quality.
- transcoding: the streams are decoded and compressed again, possibly with another codec or another bitrate. It is slow and always involves a loss, unless you use lossless codecs.
With FFmpeg, remuxing from MKV to MP4 looks like this:
ffmpeg -i input.mkv -c copy output.mp4
The -c copy option tells FFmpeg to copy the streams as they are. If the command fails, one of the streams, often the subtitles, is probably not allowed in the target container.
How to find out what is inside a file
The extension is not enough, because it only describes the container, and sometimes not even that reliably. To know which codecs are present you need analysis tools such as MediaInfo or ffprobe, which show for each track the codec, profile, resolution, frame rate, bitrate and language. In my work it is the first thing I do with a problematic file: within seconds you know whether a remux will do or a re-encode is needed.
Choosing the right combination
For most uses a few practical rules apply:
- maximum compatibility: MP4 with H.264 video and AAC audio;
- personal archive with several languages and subtitles: MKV with the codec you prefer;
- modern web with light files: WebM or MP4 with AV1 or VP9 and Opus audio, with an H.264 fallback for older browsers;
- editing: MOV or MXF with an intermediate codec designed for editing.
In short
- The container is the box; the codec is the way the content is compressed.
- Changing container (remuxing) is quick and lossless; changing codec requires transcoding.
- A file that won't open may be down to the container, the codec or the profile used.
- The extension is not enough: MediaInfo or ffprobe tell you what is inside.
- MP4 with H.264 and AAC remains the most compatible choice.