Convert Rec 709 to Rec 2020 with FFmpeg

Converting video from the standard Rec. 709 color space to the wider Rec. 2020 color space is a common task when prepping older or standard definition content for modern HDR workflows. This guide demonstrates how to perform this conversion using FFmpeg's colormatrix video filter, provides the exact command-line syntax, and explains how to properly tag the output metadata so media players recognize the wide color gamut.

The Basic colormatrix Command

To mathematically map color coordinates from Rec. 709 (BT.709) to Rec. 2020 (BT.2020), you use the colormatrix video filter with the source and destination color spaces defined as bt709:bt2020.

Here is the fundamental FFmpeg command:

ffmpeg -i input.mp4 -vf "colormatrix=bt709:bt2020" -c:a copy output.mp4

Applying Correct Color Metadata

While the colormatrix filter alters the actual pixel values, most media players rely on container metadata to know how to render the colors. Without proper tags, your output may look washed out or distorted because the player will still assume it is in the Rec. 709 space.

To ensure players recognize the Rec. 2020 color space, you must explicitly set the color space, color primaries, and transfer characteristics. Because Rec. 2020 requires higher bit-depths to prevent color banding, it is also highly recommended to output to a 10-bit pixel format (such as yuv420p10le) and use a modern codec like H.265 (HEVC).

Here is the complete, production-ready command:

ffmpeg -i input.mp4 -vf "colormatrix=bt709:bt2020" -c:v libx265 -pix_fmt yuv420p10le -colorspace bt2020nc -color_primaries bt2020 -color_trc bt2020_10 -c:a copy output.mp4

Breakdown of the Command Flags

  • -vf "colormatrix=bt709:bt2020": The video filter that converts the color coefficients from BT.709 (SDR standard) to BT.2020.
  • -c:v libx265: Encodes the video to HEVC (H.265), which is the industry-standard codec for Rec. 2020 and HDR content.
  • -pix_fmt yuv420p10le: Sets the pixel format to 10-bit YUV 4:2:0. Rec. 2020 requires at least 10-bit depth to prevent color banding in the wider gamut.
  • -colorspace bt2020nc: Sets the color matrix metadata to BT.2020 non-constant luminance.
  • -color_primaries bt2020: Tags the video with BT.2020 color primaries.
  • -color_trc bt2020_10: Sets the transfer characteristics to 10-bit BT.2020.

Limitations of Colormatrix Conversion

It is important to understand that this process is a color space container transformation. Converting a Rec. 709 video to Rec. 2020 does not automatically make it High Dynamic Range (HDR) or magically recover deep, saturated colors that were not originally captured. It merely places the existing Standard Dynamic Range (SDR) colors into a larger Rec. 2020 color envelope, which is useful when integrating SDR assets into an HDR project timeline.