How to Encode HDR Video to AV1 Using FFmpeg

Encoding High-Dynamic-Range (HDR) video to the modern, royalty-free AV1 codec allows you to drastically reduce file sizes while preserving stunning visual quality, deep color depths, and bright highlights. This guide provides a straightforward, step-by-step walkthrough on how to use FFmpeg to transcode HDR10 content into AV1 using the highly efficient SVT-AV1 (libsvtav1) encoder, ensuring all essential HDR metadata remains intact during the process.

Prerequisites

To encode HDR video to AV1, you need a recent version of FFmpeg (version 5.0 or newer is highly recommended) compiled with the libsvtav1 library. You can verify your installation by running ffmpeg -encoders in your terminal and looking for libsvtav1.

The FFmpeg Command for HDR10 to AV1

HDR10 videos rely on specific color parameters: 10-bit color depth, BT.2020 color primaries, the SMPTE ST 2084 (PQ) transfer function, and BT.2020 non-constant matrix coefficients.

Here is the standard command to encode an HDR video to AV1 while preserving this metadata:

ffmpeg -i input_hdr.mp4 -c:v libsvtav1 -preset 4 -crf 24 -pix_fmt yuv420p10le -svtav1-params color-primaries=9:transfer-characteristics=16:matrix-coefficients=9 -c:a copy output_hdr_av1.mkv

Parameter Breakdown

Handling Mastering Display Metadata (Optional)

If your source video contains specific static HDR metadata (Mastering Display Color Volume and Content Light Level), modern versions of FFmpeg and libsvtav1 will automatically read this metadata from the source and pass it to the output file.

If you need to manually inject or override this metadata, you can append the mastering-display and content-light parameters to the -svtav1-params option. For example:

-svtav1-params color-primaries=9:transfer-characteristics=16:matrix-coefficients=9:mastering-display=G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,1):content-light=max-cll=1000:max-fall=400

This ensures that HDR-capable TVs and monitors read the precise brightness limits of your video file for accurate tone mapping.