High Dynamic Range (HDR) video encoding requires careful attention to detail to preserve the high brightness, contrast, and color accuracy that HDR content offers. FFmpeg, with its wide array of encoding options and support for HDR-specific standards, is an effective tool for encoding HDR video.
Setting Up FFmpeg for HDR Encoding
FFmpeg supports HDR video encoding with formats like HEVC (H.265) and VP9, which are commonly used for delivering HDR content. To get started, ensure you are using an FFmpeg build that supports HDR encoding and includes the necessary libraries (e.g., x265 for HEVC encoding).
Encoding HDR10 Video
For HDR10 encoding, the main tasks include applying the PQ (Perceptual Quantizer) transfer function and specifying the correct color primaries (Rec. 2020). The following command shows how to encode an HDR10 video with FFmpeg:
ffmpeg -i input.mov -c:v libx265 -preset slow -x265-params "colorprim=bt2020:transfer=smpte2084:colormatrix=bt2020nc" -c:a aac output_hdr10.mp4- colorprim=bt2020: Sets the color primaries to Rec. 2020, the standard for HDR.
- transfer=smpte2084: Applies the PQ transfer function, required for HDR10.
- colormatrix=bt2020nc: Specifies the non-constant luminance matrix for HDR.
This command ensures that the HDR10 content is encoded with the proper color profile and transfer function.

Encoding with HLG for Broadcast
Hybrid Log-Gamma (HLG) is widely used in broadcast environments due to its backward compatibility with SDR displays. HLG can be encoded using HEVC, and FFmpeg can be configured to apply the HLG transfer function.
To encode HLG HDR content, use the following FFmpeg command:
ffmpeg -i input.mov -c:v libx265 -x265-params "transfer=hlg:colorprim=bt2020:colormatrix=bt2020nc" -c:a aac output_hlg.mp4- transfer=hlg: Applies the HLG transfer function.
- colorprim=bt2020: Uses Rec. 2020 color primaries.
- colormatrix=bt2020nc: Specifies the color matrix for HDR encoding.

Bitrate Considerations for HDR Encoding
HDR video often requires higher bitrates compared to SDR video due to the increased amount of data needed to preserve the finer details in brightness and color. When encoding HDR content, the bitrate should be adjusted to ensure high-quality output.
- For HDR10: Aim for a bitrate of 20"40 Mbps for 1080p HDR10 content, and up to 80"100 Mbps for 4K HDR10 content.
- For Dolby Vision: The bitrate can be higher due to dynamic metadata, with similar ranges as HDR10 depending on resolution and scene complexity.
- For HLG: A bitrate similar to HDR10 can be used, but make sure to test across different devices to ensure consistent quality.
Use the -b:v option in FFmpeg to specify the bitrate for encoding:
ffmpeg -i input.mov -c:v libx265 -b:v 25M -c:a aac output_hdr10.mp4 
Enabling HDR10+ or Dolby Vision (Experimental Use)
HDR10+ and Dolby Vision require dynamic metadata support and typically need custom toolchains. While FFmpeg does not natively support full Dolby Vision encoding, HDR10+ encoding is possible with patched x265 builds. For example:
ffmpeg -i input.mov -c:v libx265 -x265-params "hdr10_opt=1:hdr10_plus=1" -c:a copy output_hdr10plus.mp4Ensure that your FFmpeg and x265 builds are HDR10+ enabled.

What"s Next?
Looking to automate HDR video encoding workflows with greater precision? Use Cincopa"s API to trigger FFmpeg-based encoding jobs with HDR10, HLG, or HDR10+ settings. Apply color primaries like Rec. 2020, assign PQ or HLG transfer functions, manage bitrate parameters, and control advanced x265 flags at scale. Streamline your HDR content pipeline, maintain broadcast-ready quality, and deliver visually rich videos across supported devices"without manual command-line configuration.

