FFmpeg VP9 Color Primaries Space and TRC Guide

This article provides a direct guide on how to configure the -color_primaries, -color_trc, and -colorspace settings when encoding VP9 video using FFmpeg. Correctly setting these metadata flags ensures that web browsers, operating systems, and media players render colors accurately, whether you are encoding Standard Definition (SD), High Definition (HD), or High Dynamic Range (HDR) content.

Understanding the Color Parameters

When encoding VP9 video with the libvpx-vp9 encoder, defining color metadata prevents video players from guessing the color space, which often results in washed-out or distorted colors.

Standard Configurations

1. Standard HD Video (BT.709 / SDR)

For standard 1080p or 4K SDR video, you should explicitly set the color space to BT.709. Use the following FFmpeg command:

ffmpeg -i input.mp4 -c:v libvpx-vp9 -color_primaries bt709 -color_trc bt709 -colorspace bt709 output.webm

2. HDR10 Video (BT.2020 with PQ)

For High Dynamic Range (HDR10) content, you must use the BT.2020 color gamut and the SMPTE 2084 (PQ) transfer function. You must also specify a 10-bit pixel format (yuv420p10le):

ffmpeg -i input.mp4 -c:v libvpx-vp9 -pix_fmt yuv420p10le -color_primaries bt2020 -color_trc smpte2084 -colorspace bt2020nc output.webm

3. HLG HDR Video (Hybrid Log-Gamma)

For broadcast-friendly HDR using HLG, configure the transfer characteristics to arib-std-b67:

ffmpeg -i input.mp4 -c:v libvpx-vp9 -pix_fmt yuv420p10le -color_primaries bt2020 -color_trc arib-std-b67 -colorspace bt2020nc output.webm

Supported FFmpeg Values Reference

Parameter Common Values Description
-color_primaries bt709
bt2020
smpte170m
Rec. 709 (HD)
Rec. 2020 (UHD/HDR)
NTSC/PAL (SD)
-color_trc bt709
smpte2084
arib-std-b67
iec61966-2-1
Rec. 709 (SDR)
SMPTE ST 2084 (HDR10)
HLG (Hybrid Log-Gamma)
sRGB
-colorspace bt709
bt2020nc
smpte170m
Rec. 709 (HD)
Rec. 2020 Non-Constant Luminance
NTSC/PAL (SD)