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
  • -f gdigrab: Specifies the GDI grabber as the input format.
  • -framerate 30: Sets the capture speed to 30 frames per second (fps). You can adjust this value as needed.
  • -i desktop: Selects the entire primary display as the input source.
  • output.mp4: The name and format of the recorded file.

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
  • -i title="Window_Title": Instructs FFmpeg to capture only the window matching the specified title (e.g., "Calculator", "Notepad", or "Google Chrome"). The title must match the text shown in the window's title bar.

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
  • -offset_x 100: The horizontal starting point (in pixels) from the left edge of the screen.
  • -offset_y 50: The vertical starting point (in pixels) from the top edge of the screen.
  • -video_size 1280x720: The width and height of the capture area (1280 pixels wide by 720 pixels high).

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:

  • To hide the cursor:

    ffmpeg -f gdigrab -draw_mouse 0 -framerate 30 -i desktop output.mp4
  • To show the cursor (default):

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

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