VIDEONICS
SECTIONDelivery
IN08:00:04:16
READING11 min
CHECKED

Codecs, containers and bitrate — how it all fits together

‘A video in MP4’ tells you nothing about quality. MP4 is a wrapper. Quality, size and how smoothly it edits are decided by the codec, its settings and the data rate.

Container vs. codec

A container (MOV, MP4, MXF, MKV) is a file format: it wraps one or more tracks of picture, sound, subtitles and timecode, keeps them in sync and carries metadata. A codec determines how the data in an individual track is compressed. The same container can carry different codecs, and the same codec can sit in different containers.

DIAGRAM · WHAT’S INSIDE THE FILE

A container and its codecs in one file The rectangle represents a MOV or MP4 file. Inside are tracks: video encoded with the H.264 or ProRes codec, audio in AAC or PCM, subtitles and timecode, and metadata. The container wraps the tracks; the codec determines how the data in each track is compressed. CONTAINER .mov / .mp4 / .mxf / .mkv wraps the tracks, sync, timecode and metadata V1 video codec: H.264 · HEVC · ProRes · DNxHR · AV1 A1 audio codec: PCM (uncompressed) · AAC · Opus T subtitles / TC timecode, subtitles, chapters M metadata colour space, resolution, fps, date…
The container is a wrapper with tracks. The codec is how a particular track is compressed. Playback support depends on the combination of both.

That is why ‘the MP4 won’t play’ can happen: the player knows the container but not the codec inside (HEVC or AV1 on an older device, for example).

Intra vs. long-GOP

Codecs compress the picture in two ways:

  • Within a frame (intra). Each frame is compressed on its own, like a photograph. Apple says of all ProRes codecs that they are ‘frame-independent’ — each frame is encoded and decoded independently. DNxHR works the same way. Files are larger, but the editing software can jump to any frame without calculating the ones around it.
  • Between frames (long-GOP). The codec stores a complete key frame (I) and then only the differences: P frames are predicted from previous frames, B frames from both previous and following ones. The group from one I frame to the next is the GOP. At the same quality the files are much smaller — which is why distribution works this way (H.264, H.265, AV1). When editing, though, the computer has to decode other frames to display a single one, which slows playback down with 4K and several tracks.

H.264 and H.265 also have all-intra profiles, used by some professional cameras. So the name of the codec alone doesn’t tell you whether it is long-GOP; you need to look at the profile.

Bit depth and chroma subsampling

Bit depth determines the number of levels per channel: 8 bits = 256, 10 bits = 1,024, 12 bits = 4,096. For log recording and grading, 10 bits is a sensible minimum.

Chroma subsampling exploits the fact that the eye is more sensitive to brightness than to colour. The J:a:b notation tells you how many colour samples there are relative to luminance samples in a block of 4 × 2 pixels:

Common chroma subsampling
FormatColour resolutionWhere you will meet it
4:4:4fullProRes 4444, DNxHR 444, graphics, VFX, mastering
4:2:2half horizontallyprofessional recording, ProRes 422, DNxHR, broadcast
4:2:0half horizontally and verticallydistribution (YouTube recommends 4:2:0 for H.264 uploads), many cameras and phones

In normal viewing you often won’t see a difference between 4:2:2 and 4:2:0. In keying (green screen) and heavy grading you will — edges and fine colour transitions break up sooner.

Bitrate and file size

The data rate (bitrate) is the amount of data per second. File size is simply:

size [B] = data rate [b/s] × duration [s] ÷ 8

Example: 100 Mb/s × 3,600 s ÷ 8 = 45,000,000,000 B = 45 GB per hour.

With CBR (constant bitrate) the result is exact. With VBR (variable bitrate) the encoder gives more bits to demanding scenes and fewer to simple ones — the final size is close to the average, not exact. ProRes is VBR with a target number of bits per frame; Apple says the maximum is about 10% above the target and many simple frames are smaller. DNxHR has a fixed number of bytes per frame for each level and resolution, so its data rate can be calculated exactly.

INTERACTIVE · STORAGE CALCULATOR

Storage calculator

Recording length
Space required —
per minute
—
per hour
—
data rate
—
per frame
—

The ProRes and DNxHR presets come from the official Apple and Avid tables; for H.264, H.265 and AV1 you enter the data rate of your own encoder.
Data rates at UHD 3840 × 2160 and 25 fps (official tables)
CodecMb/sGB / hourSource
ProRes 422 Proxy15168Apple, 25p table
ProRes 422 LT342154Apple
ProRes 422492221Apple
ProRes 422 HQ737332Apple
ProRes 4444 (no alpha)1,106498Apple
DNxHR LB149.967.5Avid: 749,568 B/frame
DNxHR SQ481.7216.8Avid: 2,408,448 B/frame
DNxHR HQ / HQX728.3327.7Avid: 3,641,344 B/frame
DNxHR 4441,457.4655.8Avid: 7,286,784 B/frame
H.264 upload (YouTube, SDR)35–4515.8–20.3YouTube recommendation for 2160p

The DNxHR values are calculated from bytes per frame: bytes × 8 × 25 ÷ 10⁶. Avid also gives them in MB/s in its table (e.g. 57.42 MB/s for UHD SQ at 25 fps — in binary megabytes). Here GB per hour is calculated in decimal (10⁹ B).

Which codec when

Choosing a codec by stage
StageGoalTypical choice
RecordingAs much information as you can afford to storeRAW, ProRes 422 HQ / 4444, 10-bit H.265 or H.264 intra in camera
EditingSmooth playbackAn intra codec (ProRes, DNxHR); with long-GOP originals, proxies (ProRes Proxy, DNxHR LB)
Exchange / masteringNo loss of quality across several generationsProRes 422 HQ / 4444 (XQ), DNxHR HQX / 444, or uncompressed or IMF as the recipient requires
Upload to a platformA high-quality source for re-encodingH.264 or H.265 at a high data rate; some platforms also accept ProRes
Delivery to the viewerA small file, wide supportThe platform re-encodes it itself (often H.264, VP9 or AV1 depending on the device)
i NOTE

Every re-encode with a lossy codec loses something. So export from the master file straight to the target format — not ‘from MP4 to MP4’.