Repository navigation
Description
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.
- FFmpeg
gfxcapturesource: https://ffmpeg.org/doxygen/trunk/vsrc__gfxcapture_8c_source.html - Usage notes (targets by title / monitor / exe / hwnd,
hwdownloadfor software encoders): https://qiita.com/calcMCalcm/items/b450222b5c1b467120bc ddagrab(Desktop Duplication) is a related GPU path for full/monitor targets: https://trac.ffmpeg.org/wiki/Capture/Desktop
Approach
- Probe at startup:
ffmpeg -h filter=gfxcapture; cache whether it's available. - In
src/utils/targets.ts, build-f lavfi -i gfxcapture=...,hwdownload,format=bgraargs when available; keepgdigrabas the fallback. This is a natural first step toward the backend seam Cross-platform capture backends (x11grab / avfoundation) #15 plans. - New target forms:
window:hwnd=0x...,window:exe=Code.exe, alongside title. start_recording/screenshotreportbackend: "gfxcapture" | "gdigrab"plus the matched window (also helps window: target can silently record the wrong window, and start_recording does not report which window matched #89).- Optional
backendoverride parameter.
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
TMHSDigital commentedon Oct 24, 2026
Progress and findings (PR #146).
Shipped: opt-in
backend: "wgc"for stills (screenshot,find_text) onwindow:targets, capturing by HWND through FFmpeg 8'sgfxcapture. A window fully covered by another comes out as itself (verified in the live harness).Blocked: recording.
gfxcaptureonly emits a frame when the window repaints. For a static window,-f lavfi -i "gfxcapture=…,hwdownload,format=bgra"blocks waiting for the next frame:fps=Nfill, or a constant-clockcolor+overlay=repeatlast=1:eof_action=repeat, the output still stalls;qwhile blocked (still running 6 s afterq), and the file comes out empty.That would break
stop_recording, sostart_recordingandwait_for_changestay 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:
gfxcaptureoption to re-emit the last frame on a timer (the WGC API supportsMinUpdateInterval; FFmpeg would need to repeat frames itself).Leaving this open for the recording half.
feat: opt-in Windows Graphics Capture backend for window stills (#113) (
feat: record a window through Windows Graphics Capture (#113) (#165)