FFmpeg ddagrab: How to Capture Desktop at 120fps
This article explains how to capture high-frame-rate desktop video at
120 frames per second (fps) on Windows using FFmpeg’s Desktop
Duplication API (ddagrab) input. You will learn the exact
FFmpeg command structures, the importance of hardware-accelerated
encoders, and optimization techniques to ensure smooth, stutter-free,
high-speed screen recordings.
Why Use ddagrab for 120fps?
The default Windows grabber in FFmpeg, gdigrab, relies
on the CPU and GDI engine, which struggles to capture video beyond 30 to
60 fps without dropping frames. The ddagrab input utilizes
the Windows Desktop Duplication API (DDA), which directly accesses the
GPU’s frame buffer. This hardware-level access reduces CPU overhead to
almost zero, making 120fps capture highly efficient and feasible on
modern systems.
Prerequisites
To capture desktop video at 120fps, your system must meet the
following requirements: * Operating System: Windows 8
or later. * Graphics Card: A dedicated GPU (NVIDIA,
AMD, or Intel) with up to date drivers. * Monitor Refresh
Rate: Your monitor should ideally be running at 120Hz or
higher. If your monitor runs at 60Hz, capturing at 120fps will result in
duplicate frames. * FFmpeg: A modern build of FFmpeg
(configured with --enable-libd3d11va and
--enable-dxva2).
The 120fps Capture Command
For 120fps capture, you must combine the ddagrab input
with a hardware-accelerated encoder. Below is the optimized command
using NVIDIA’s NVENC hardware encoder:
ffmpeg -hwaccel d3d11va -f ddagrab -framerate 120 -i desktop -c:v h264_nvenc -preset p1 -cq 19 -pix_fmt yuv420p output.mp4Alternative: Command for AMD GPUs (AMF)
If you are using an AMD graphics card, use the following command:
ffmpeg -hwaccel d3d11va -f ddagrab -framerate 120 -i desktop -c:v h264_amf -quality speed -pix_fmt yuv420p output.mp4Alternative: Command for Intel GPUs (QSV)
If you are using Intel Integrated Graphics, use the following command:
ffmpeg -hwaccel d3d11va -f ddagrab -framerate 120 -i desktop -c:v h264_qsv -preset veryfast -pix_fmt nv12 output.mp4Command Breakdown
-hwaccel d3d11va: Enables Direct3D 11 hardware acceleration to process the video frames directly on the GPU.-f ddagrab: Tells FFmpeg to use the Desktop Duplication API input device.-framerate 120: Sets the desktop capture speed to 120 frames per second.-i desktop: Specifies the input target (the entire primary display desktop).-c:v h264_nvenc(or_amf/_qsv): Chooses a hardware-accelerated video encoder. Using software encoding (likelibx264) at 120fps will likely bottleneck your CPU and cause frame drops.-preset p1/-quality speed: Prioritizes encoding speed over compression efficiency to prevent encoding lag.-pix_fmt yuv420p: Formats the pixel color space to YUV 420p to ensure maximum compatibility with video players and editing software.
Performance Optimization Tips
If you experience skipped frames or stuttering during a 120fps recording, apply the following adjustments:
Specify the Capturing Screen: If you have multiple monitors and want to capture a specific screen, use the
-output_idxparameter. For example, to capture the second monitor, use-output_idx 1:ffmpeg -hwaccel d3d11va -f ddagrab -framerate 120 -output_idx 1 -i desktop -c:v h264_nvenc output.mp4Limit Capture Area: Capturing the entire desktop at 120fps is resource-intensive. You can crop the capture area using
-video_size,-offset_x, and-offset_y:ffmpeg -hwaccel d3d11va -f ddagrab -framerate 120 -video_size 1920x1080 -offset_x 0 -offset_y 0 -i desktop -c:v h264_nvenc output.mp4Capture Cursor: By default,
ddagrabcaptures the mouse cursor. If you want to disable cursor capture to save processing overhead, add-draw_mouse 0before the-i desktopparameter.