C.W.K.
Stream
Lesson 08 of 10 · published

Pixel Formats — yuv420p and Why It Matters

~10 min · pixel-format, chroma-subsampling, compatibility

Level 0Viewer
0 XP0/73 lessons0/15 achievements
0/100 XP to next level100 XP to go0% complete

The chroma-subsampling alphabet soup

A pixel format string like yuv420p10le packs four pieces of information:

  • yuv — color space (vs rgb).
  • 420 — chroma subsampling. 4:4:4 = full color, 4:2:2 = half horizontal chroma, 4:2:0 = quarter chroma (¼ the chroma data of 4:4:4).
  • p — planar layout (separate Y, U, V planes).
  • 10le — 10-bit little-endian (vs the default 8-bit).

What you'll actually see

  • yuv420p — 8-bit 4:2:0. The H.264 web/mobile default. Use it.
  • yuv420p10le — 10-bit 4:2:0. HEVC HDR, finer gradients, slight quality bump.
  • yuv422p10le — 10-bit 4:2:2. ProRes 422 default.
  • yuva444p10le — 10-bit 4:4:4 with alpha. ProRes 4444.

The trap

If you decode a 4:2:0 source and re-encode without specifying -pix_fmt, FFmpeg picks the encoder's preferred format. libx264 will sometimes emit 4:4:4 by accident if the source was unusual, and that file won't play on iPhone, Safari, or most TVs. Always explicitly set -pix_fmt yuv420p for compatibility outputs.

Code

Force the right pixel format·bash
# 8-bit 4:2:0 — universal compatibility
ffmpeg -i in.mp4 -c:v libx264 -crf 20 -pix_fmt yuv420p out.mp4

# 10-bit 4:2:0 — slightly better gradients (HEVC, browsers OK)
ffmpeg -i in.mp4 -c:v libx265 -crf 24 -pix_fmt yuv420p10le -tag:v hvc1 out.mp4

# 10-bit 4:2:2 — for ProRes editing master
ffmpeg -i in.mp4 -c:v prores_ks -profile:v 3 -pix_fmt yuv422p10le master.mov
Inspect what you ended up with·bash
# What pixel format did the output land in?
ffprobe -v error -select_streams v:0 \
  -show_entries stream=pix_fmt,bits_per_raw_sample \
  -of default=noprint_wrappers=1 out.mp4
# pix_fmt=yuv420p
# bits_per_raw_sample=8

External links

Exercise

Encode a clip three ways: libx264 -pix_fmt yuv420p, libx264 -pix_fmt yuv444p, libx265 -pix_fmt yuv420p10le -tag:v hvc1. Try opening each in QuickTime, Safari, and Chrome on a phone. Note which fail. The 4:4:4 one is the failure case to remember.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.