Record HDR Screen Using FFmpeg and ddagrab
This guide explains how to capture high-dynamic-range (HDR) screen
recordings on Windows using FFmpeg and the Desktop Duplication API
(ddagrab). By leveraging hardware acceleration and 10-bit
color spaces, you can record high-quality, lag-free HDR footage from
your desktop. Below, you will find the exact FFmpeg commands, parameter
breakdowns, and configuration steps required to output standard
HDR10-compliant video files.
Prerequisites
Before starting, ensure your system meets the following requirements: * Operating System: Windows 10 or Windows 11. * Hardware: An HDR-compatible monitor with HDR enabled in the Windows Display Settings. * Software: A recent build of FFmpeg (version 5.0 or newer recommended) compiled with hardware acceleration support (like NVIDIA NVENC, AMD AMF, or Intel QSV).
The FFmpeg HDR Capture Command
To capture your HDR desktop, you must grab the display using the 10-bit pixel format and tag the output video with the correct HDR10 metadata.
Run the following command in your command prompt or terminal:
ffmpeg -f ddagrab -output_format p010 -i desktop -c:v hevc_nvenc -pix_fmt p010le -color_range tv -colorspace bt2020nc -color_primaries bt2020 -color_trc smpte2084 -cq 20 output.mp4Parameter Breakdown
-f ddagrab: Specifies the Desktop Duplication API as the input device. This API has direct access to the GPU frame buffers, making it fast enough for real-time HDR recording.-output_format p010: Tellsddagrabto capture the desktop in 10-bit color depth. This prevents color banding and preserves the wide color gamut of HDR.-i desktop: Targets the primary display for capture.-c:v hevc_nvenc: Uses NVIDIA’s hardware-accelerated HEVC (H.265) encoder. If you are using an AMD GPU, replace this withhevc_amf. For Intel GPUs, usehevc_qsv.-pix_fmt p010le: Sets the output pixel format to 10-bit YUV 4:2:0, which is standard for HDR10 playback compatibility.-color_range tv: Sets the color range to limited (TV) range, standard for most consumer HDR playback devices.-colorspace bt2020nc&-color_primaries bt2020: Configures the color space metadata to Rec. 2020, the standard color gamut for HDR video.-color_trc smpte2084: Sets the Transfer Characteristics metadata to SMPTE ST 2084 (PQ curve), which is required for HDR10 displays to correctly interpret the brightness levels of the video.-cq 20: Sets the Constant Quality factor. Lower values yield higher quality at the cost of larger file sizes. A value of 20 to 23 is recommended for high-quality screen recording.
Alternative: CPU Encoding (libx265)
If you do not have a dedicated GPU supporting hardware-accelerated 10-bit HEVC encoding, you can use your CPU. Note that CPU encoding is highly demanding and may cause dropped frames during gameplay or high-motion desktop use.
ffmpeg -f ddagrab -output_format p010 -i desktop -c:v libx265 -pix_fmt p010le -color_range tv -colorspace bt2020nc -color_primaries bt2020 -color_trc smpte2084 -crf 20 -preset ultrafast output.mp4Using the -preset ultrafast option is necessary for
real-time CPU screen capturing to prevent lag and frame loss.