Containers vs codecs: why some conversions take seconds and others take minutes

A video file is two things at once: a container (the box: MP4, MOV, MKV, WebM) and the codecs inside it (the compression: H.264, HEVC, VP9, AAC, Opus). Knowing which one is the problem tells you which kind of conversion you need.

The box and what is in it

The container organises streams: it holds one or more video tracks, audio tracks, subtitles and chapters, plus timestamps and an index so players can seek. The codec is the algorithm that compressed each stream. H.264 video in an MP4 and H.264 video in an MKV are the same pictures in different packaging.

Each container spec lists which codecs it allows. WebM, for example, allows only VP8, VP9 and AV1 video with Vorbis or Opus audio. Matroska (MKV) allows nearly anything. Players then add their own limits on top: Safari refuses VP9 in MP4 even though the spec permits it.

Try it: what fits where?

Pick the codecs inside your file and the container you want. The cable turns teal when the streams can simply be moved across, and a converter box appears when they can't.

Your file

Container
Video codec
Audio codec

Convert to

Remux: copy both streams into the new box

The HEVC video and AAC audio are allowed in MP4, so nothing is decoded. It takes seconds and the picture is bit-for-bit identical.

Step through a remux and a transcode

The same "convert to MP4" button does very different amounts of work depending on the source. Each bar below is a packet of compressed video; taller ones are keyframes.

Demux. FFmpeg opens the MOV and splits it into its streams: compressed H.264 video packets and AAC audio packets, each with a timestamp.

One more layer: pixel formats

When a video is transcoded, the frames are not stored as red, green and blue. Encoders convert them to one brightness channel (Y) and two colour-difference channels, then usually keep colour at a quarter of the resolution. That is the yuv420p you see in FFmpeg logs, and players expect it: an H.264 file in 4:4:4 often won't play on phones at all. Our converter always writes yuv420p for H.264 for that reason.

The brightness channel is a weighted sum that follows human vision. Under the BT.709 standard for HD video it is Y = 0.2126 R + 0.7152 G + 0.0722 B, so green supplies about 72% of what you perceive as detail. That weighting holds in daylight; under moonlight your eyes switch to rod cells, colours fade and blue-greens look brightest. How much moonlight you get depends on the phase, which ahaboo narrates in its explainer on why the Moon has phases.

So which conversion do I need?

  • The file won't open at all, or an app says "unsupported file type": usually the container. A remux may be enough (MKV to MP4, MOV to MP4).
  • It opens but shows black video, or only plays sound: usually the codec, often HEVC. Re-encode the video (HEVC to MP4).
  • It plays but is too big: that is compression, not conversion. Try SqueezeVideos.

Questions

Is MP4 a codec?

No. MP4 is a container. The codec is what compresses the pictures inside it, usually H.264, sometimes HEVC or AV1.

Why does my video player say "unsupported codec" for an MP4?

The player understands the MP4 container but not the codec inside, typically HEVC on an older PC or in Firefox. Re-encoding the video to H.264 fixes it.

Does remuxing lose quality?

No. Remuxing copies the compressed packets into a new container without decoding them.