Skip to content

Windows Graphics Capture backend via FFmpeg gfxcapture for true per-window capture #113

Closed

Description

@TMHSDigital

What and who

Add a second Windows capture backend built on FFmpeg's new gfxcapture source filter (Windows.Graphics.Capture). For anyone who records a specific app: agents verifying a UI, developers recording a demo of one window.

Why

Today window:<title> resolves the window's on-screen rectangle once at start and grabs that area with gdigrab (README, "Windows notes"). So the window must be on top and unminimized, anything drawn over it is captured, and a moved window falls out of frame. WGC captures the window's own surface: background and occluded windows, GPU/DirectComposition apps (Chrome, Electron, UWP) and windows that move or resize. It also directly addresses the "Drop: title-based window grab" item in #107 and makes the wrong-window risk in #89 much smaller, since gfxcapture can target by HWND or executable name rather than title.

Approach

Done when

With FFmpeg 8+, window: capture records a window that is behind another window and keeps recording correctly after it is moved. The result reports which backend was used, and older FFmpeg builds fall back to gdigrab with no regression. README Windows notes are updated.

Activity

  1. added
    feature
    effort: medium
    impact: high
    on Oct 24, 2026
  2. TMHSDigital commented on Oct 24, 2026

    @TMHSDigital
    OwnerAuthor

    Progress and findings (PR #146).

    Shipped: opt-in backend: "wgc" for stills (screenshot, find_text) on window: targets, capturing by HWND through FFmpeg 8's gfxcapture. A window fully covered by another comes out as itself (verified in the live harness).

    Blocked: recording. gfxcapture only emits a frame when the window repaints. For a static window, -f lavfi -i "gfxcapture=…,hwdownload,format=bgra" blocks waiting for the next frame:

    • with an fps=N fill, or a constant-clock color + overlay=repeatlast=1:eof_action=repeat, the output still stalls;
    • ffmpeg does not process the graceful-stop q while blocked (still running 6 s after q), and the file comes out empty.

    That would break stop_recording, so start_recording and wait_for_change stay on gdigrab. WGC stills are also slow (1.3-2.3 s vs ~0.2 s for gdigrab), so it's opt-in rather than the default.

    Possible ways forward:

    1. An upstream gfxcapture option to re-emit the last frame on a timer (the WGC API supports MinUpdateInterval; FFmpeg would need to repeat frames itself).
    2. A small native helper (C#/WinRT) that keeps the last frame and pushes it at a fixed rate into ffmpeg over a pipe.
    3. Record with a forced-repaint trick (not recommended: invasive).

    Leaving this open for the recording half.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort: mediumfeatureimpact: high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions