Convert EXR to Rec. 2020 HEVC with FFmpeg
This article provides a step-by-step guide on how to convert a high-dynamic-range (HDR) OpenEXR image sequence into a compressed Rec. 2020 HEVC (H.265) video using FFmpeg. You will learn the exact command-line parameters required to handle linear-to-HDR color space conversions, maintain 10-bit color depth, and embed the correct HDR metadata for seamless playback on modern HDR displays.
Prerequisites
To perform this conversion, your FFmpeg build must be compiled with:
* --enable-libx265 (for HEVC encoding) *
--enable-libzimg (for the zscale filter, which
handles high-precision color space conversions)
The FFmpeg Command
To convert a linear Rec. 2020 EXR sequence to an HDR10 (Rec. 2020, PQ transfer function) HEVC video, use the following command:
ffmpeg -framerate 24 -i input_%04d.exr -vf "zscale=tin=linear:pin=bt2020:t=smpte2084:p=bt2020:r=limited,format=yuv420p10le" -c:v libx265 -crf 18 -x265-params "colorprim=bt2020:transfer=smpte2084:colormatrix=bt2020nc:master-display=G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,1):max-cll=1000,400" output.mp4Parameter Breakdown
1. Input Settings
-framerate 24: Sets the speed of the input sequence to 24 frames per second.-i input_%04d.exr: Specifies the input files.%04dmatches four-digit padded sequences (e.g.,input_0001.exr).
2. Video Filter (-vf)
The zscale filter converts the linear high-bit-depth EXR
data into the correct HDR10 format: * tin=linear: Tells
FFmpeg the input transfer characteristics are Linear. *
pin=bt2020: Identifies the input primaries as Rec. 2020. If
your EXR files use ACES AP1 or Rec. 709 primaries, change this parameter
accordingly (e.g., pin=bt709). * t=smpte2084:
Converts the transfer curve to SMPTE ST 2084 (PQ curve, standard for
HDR10). * p=bt2020: Sets the output color primaries to Rec.
2020. * r=limited: Standardizes the color range to limited
(video range), which is required for standard HEVC distribution. *
format=yuv420p10le: Outputs to 10-bit YUV 4:2:0, the
standard pixel format for HDR10 compatibility.
3. Encoding and Metadata Settings
-c:v libx265: Selects the x265 encoder for HEVC output.-crf 18: Sets the Constant Rate Factor. Lower values mean higher quality; 16–22 is ideal for visually lossless HDR encoding.-x265-params: Flags the video stream with essential metadata so HDR TVs and monitors recognize the signal:colorprim=bt2020: Flags the output container as Rec. 2020.transfer=smpte2084: Flags the container to use the PQ curve.colormatrix=bt2020nc: Specifies the non-constant luminance matrix for Rec. 2020.master-display: (Optional but recommended) Embeds mastering display color volume metadata.max-cll: (Optional but recommended) Defines the Maximum Content Light Level (MaxCLL) and Maximum Frame-Average Light Level (MaxFALL) in nits.