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.mp4

Parameter Breakdown

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.mp4

Using the -preset ultrafast option is necessary for real-time CPU screen capturing to prevent lag and frame loss.