Configure rav1e Color Parameters in FFmpeg

This guide explains how to properly configure color description parameters—specifically color space, color primaries, and transfer characteristics—when encoding AV1 video using the rav1e encoder in FFmpeg. Setting these parameters correctly ensures that your encoded videos display accurate colors and brightness levels across different screens, players, and platforms.

Understanding the Color Parameters

When encoding video, you need to define how colors are represented. This is done using three metadata tags, collectively known as the color description:

  1. Color Primaries (-color_primaries): Defines the color gamut (the range of colors). Common values include bt709 for standard definition/HD and bt2020 for ultra-high-definition (UHD) and HDR.
  2. Color Transfer Characteristics (-color_trc): Defines the opto-electronic transfer function (gamma curve). Common values include bt709 for SDR, smpte2084 for HDR10 (PQ), and arib-std-b67 for Hybrid Log-Gamma (HLG).
  3. Color Space (-colorspace): Defines the matrix coefficients used to derive luma and chroma signals from red, green, and blue primaries. Common values include bt709 and bt2020nc.

Additionally, you can specify the Color Range (-color_range), which is typically tv (limited range, standard for most video) or pc (full range).

FFmpeg Command Examples for rav1e

FFmpeg’s librav1e wrapper maps standard FFmpeg color options directly to the encoder. You do not need complex nested parameters; you can pass the standard flags directly.

Standard Definition / High Definition (SDR BT.709)

For standard 1080p web video, use the BT.709 color space:

ffmpeg -i input.mp4 -c:v librav1e -pix_fmt yuv420p10le -color_primaries bt709 -color_trc bt709 -colorspace bt709 -color_range tv output.mp4

High Dynamic Range (HDR10 / BT.2020 PQ)

For high-quality HDR content, use the BT.2020 color gamut and the SMPTE 2084 (PQ) transfer curve. 10-bit pixel format (yuv420p10le) is highly recommended for HDR to prevent color banding:

ffmpeg -i input.mp4 -c:v librav1e -pix_fmt yuv420p10le -color_primaries bt2020 -color_trc smpte2084 -colorspace bt2020nc -color_range tv output.mp4

Broadcast HDR (HLG / BT.2020)

For HLG-based HDR, which is commonly used in broadcasting, configure the parameters as follows:

ffmpeg -i input.mp4 -c:v librav1e -pix_fmt yuv420p10le -color_primaries bt2020 -color_trc arib-std-b67 -colorspace bt2020nc -color_range tv output.mp4

Verifying the Output

After encoding your video, you can verify that the color parameters were written correctly to the file’s metadata using ffprobe:

ffprobe -v error -select_streams v:0 -show_entries stream=color_space,color_transfer,color_primaries,color_range -of default=noprint_wrappers=1 output.mp4