Set FFmpeg Colorspace Transfer Characteristics
This article provides a straightforward guide on how to specify input
and output transfer characteristics (TRC) using the FFmpeg
colorspace filter. You will learn the exact parameters
required to define these color properties, the list of supported
transfer curves, and practical command-line examples to ensure accurate
color conversions in your video processing workflows.
To define the input and output transfer characteristics in the FFmpeg
colorspace filter, you must use the itrc
(input transfer characteristics) and trc (output transfer
characteristics) options.
The Syntax
The basic syntax for applying the colorspace filter with
transfer characteristics is:
-vf colorspace=itrc=input_value:trc=output_valueIf you do not specify the input transfer characteristics
(itrc), FFmpeg will attempt to read them from the source
video’s metadata. Explicitly defining both parameters ensures accuracy,
especially when dealing with files that have missing or incorrect
metadata.
Common Transfer Characteristic Values
FFmpeg supports a variety of standard transfer curves. Some of the most common values include:
bt709: Standard definition for HDTV (BT.709).srgb: Standard RGB color space, commonly used for web and computer monitors.bt2020-10: 10-bit BT.2020 transfer characteristics (used for 4K/UHD).smpte2084: SMPTE ST 2084 (PQ / Perceptual Quantizer, used for HDR10).arib-std-b67: Hybrid Log-Gamma (HLG), commonly used in HDR broadcasting.linear: Linear transfer characteristics.bt601-6-625/bt601-6-525: Standard definition curves (PAL and NTSC).
Practical Examples
Example 1: Converting from sRGB to BT.709
If you have a screen recording (which typically uses the sRGB transfer curve) and want to convert it to standard HDTV colorspace (BT.709), use the following command:
ffmpeg -i input.mp4 -vf colorspace=itrc=srgb:trc=bt709 output.mp4Example 2: Complete Color Space Conversion
When changing transfer characteristics, it is often necessary to align the color space and primaries as well. This example converts a video from standard BT.709 to ultra-high-definition BT.2020:
ffmpeg -i input.mp4 -vf colorspace=ispace=bt709:itrc=bt709:iprimaries=bt709:space=bt2020nc:trc=bt2020-10:primaries=bt2020 output.mp4In this command: * ispace, itrc, and
iprimaries define the input as BT.709. *
space, trc, and primaries define
the target output as BT.2020 with 10-bit transfer characteristics.