How to Use FFmpeg gdigrab on Windows

This guide explains how to capture your Windows desktop or specific application windows using FFmpeg’s built-in gdigrab device. You will learn the essential commands for full-screen recording, capturing specific windows, defining custom screen regions, and configuring key settings like frame rate and resolution.

What is gdigrab?

The gdigrab option is a device input format native to Windows that uses the Graphics Device Interface (GDI) to capture screen data. It is a lightweight, built-in solution that does not require installing external screen capture codecs or drivers.

Capture the Entire Desktop

To capture your entire Windows desktop, use desktop as the input source. Run the following command in your Command Prompt or PowerShell:

ffmpeg -f gdigrab -framerate 30 -i desktop output.mp4

To stop recording at any time, press q on your keyboard while the command prompt window is active.

Capture a Specific Window

If you only want to record a specific open window instead of the entire screen, you can target it using its exact window title.

ffmpeg -f gdigrab -framerate 30 -i title="Calculator" output.mp4

Capture a Specific Screen Region

You can record a specific coordinate box on your desktop by defining the offset coordinates and the video size.

ffmpeg -f gdigrab -framerate 30 -offset_x 100 -offset_y 50 -video_size 1280x720 -i desktop output.mp4

Showing the Mouse Cursor

By default, gdigrab includes the mouse cursor in the recording. If you want to explicitly enable or disable this feature, use the draw_mouse parameter:

Adding Audio to the Screen Capture

Because gdigrab only captures video, you must pair it with a Windows audio capture device (such as dshow or wasapi) if you want to record sound at the same time.

First, list your available audio input devices:

ffmpeg -list_devices true -f dshow -i dummy

Once you identify your microphone or system stereo mix name from the list, combine the video and audio inputs:

ffmpeg -f gdigrab -framerate 30 -i desktop -f dshow -i audio="Microphone (Realtek Audio)" output.mp4