Encode HDR Video with libvpx-vp9
High Dynamic Range (HDR) video offers enhanced color depth and
contrast, but encoding it correctly requires specific metadata and
profile parameters. This guide outlines the strictly required command
line arguments needed to encode HDR video content using the FFmpeg
libvpx-vp9 encoder, ensuring your output retains its HDR
properties and plays back correctly on compatible displays.
To successfully encode HDR10 (the most common HDR format) using the
VP9 codec, you must use FFmpeg with the libvpx-vp9 library.
The following command line arguments are strictly required to trigger
10-bit encoding and pass the correct color metadata to the decoder:
ffmpeg -i input.mp4 -c:v libvpx-vp9 -profile:v 2 -pix_fmt yuv420p10le -color_primaries bt2020 -color_trc smpte2084 -colorspace bt2020nc output.webmRequired Arguments Explained
-profile:v 2
This argument is mandatory. VP9 Profile 0 only supports 8-bit color. You must explicitly set the profile to2to enable 10-bit color depth support, which is required for HDR.-pix_fmt yuv420p10le
This sets the pixel format to 10-bit YUV with 4:2:0 chroma subsampling. Without this, the encoder may default to an 8-bit pixel format, discarding the HDR color depth.-color_primaries bt2020
This flags the video container to use the BT.2020 color gamut, which defines the wider range of colors available in HDR.-color_trc smpte2084
This defines the Transfer Characteristics. For standard HDR10 content, you must usesmpte2084(also known as Perceptual Quantizer or PQ). If you are encoding Hybrid Log-Gamma (HLG) HDR content, usearib-std-b67instead.-colorspace bt2020nc
This sets the matrix coefficients to BT.2020 non-constant luminance, which determines how the luma and chroma channels are mapped from the RGB source.