Captures the Windows Desktop via Desktop Duplication API.
The filter exclusively returns D3D11 Hardware Frames, for on-gpu encoding or processing. So an explicit hwdownload is needed for any kind of software processing.
It accepts the following options:
- output_idx
-
DXGI Output Index to capture.
Usually corresponds to the index Windows has given the screen minus one, so it’s starting at 0.
Defaults to output 0.
- draw_mouse
-
Whether to draw the mouse cursor.
Defaults to true.
Only affects hardware cursors. If a game or application renders its own cursor, it’ll always be captured.
- framerate
-
Framerate at which the desktop will be captured.
Defaults to 30 FPS.
- video_size
-
Specify the size of the captured video.
Defaults to the full size of the screen.
Cropped from the bottom/right if smaller than screen size.
- offset_x
-
Horizontal offset of the captured video.
- offset_y
-
Vertical offset of the captured video.
- output_fmt
-
Desired filter output format. Defaults to 8 Bit BGRA.
It accepts the following values:
- auto
-
Passes all supported output formats to DDA and returns what DDA decides to use.
- 8bit, bgra
-
8 Bit formats always work, and DDA will convert to them if neccesary.
- 10bit, x2bgr10
-
Filter initialization will fail if 10 bit format is requested but unavailable.
Examples
Capture primary screen and encode using nvenc:
ffmpeg -f lavfi -i ddagrab -c:v h264_nvenc -cq 18 output.mp4
You can also skip the lavfi device and directly use the filter. Also demonstrates downloading the frame and encoding with libx264. Explicit output format specification is required in this case:
ffmpeg -filter_complex ddagrab=output_idx=1:framerate=60,hwdownload,format=bgra -c:v libx264 -crf 18 output.mp4
If you want to capture only a subsection of the desktop, this can be achieved by specifying a smaller size and its offsets into the screen:
ddagrab=video_size=800x600:offset_x=100:offset_y=100