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.mkvParameter Breakdown
-i input_hdr.mp4: Specifies your source HDR input video.-c:v libsvtav1: Selects the SVT-AV1 encoder, which is currently the industry standard for CPU-based AV1 encoding.-preset 4: Determines the encoding speed-to-efficiency ratio. Presets range from 0 (slowest, highest quality/compression) to 13 (fastest, lowest compression). Presets between 4 and 6 offer an excellent balance for high-quality encodes.-crf 24: Constant Rate Factor controls the visual quality. Lower values yield higher quality at the expense of larger file sizes. For AV1, a CRF value between 20 and 28 is recommended for HDR content.-pix_fmt yuv420p10le: Sets the pixel format to 10-bit YUV 4:2:0. This is a strict requirement for HDR10, as 8-bit formats will cause severe color banding.-svtav1-params color-primaries=9:transfer-characteristics=16:matrix-coefficients=9: This argument passes the critical HDR10 metadata flags directly to the SVT-AV1 encoder:color-primaries=9specifies BT.2020.transfer-characteristics=16specifies SMPTE ST 2084 (PQ curve).matrix-coefficients=9specifies BT.2020 non-constant luminance.
-c:a copy: Copies the audio stream directly from the source without re-encoding it, preserving original quality and saving processing time.output_hdr_av1.mkv: The final output file name. Using the MKV container is highly recommended for AV1 and HDR metadata compatibility.
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=400This ensures that HDR-capable TVs and monitors read the precise brightness limits of your video file for accurate tone mapping.