Skip to content

feat: opt-in Windows Graphics Capture backend for window stills (#113) - #146

Merged
TMHSDigital merged 1 commit into
mainfrom
feat/gfxcapture-113
Oct 24, 2026
Merged

TMHSDigital merged 1 commit into
mainfrom
feat/gfxcapture-113

Conversation

@TMHSDigital

Copy link
Copy Markdown
Owner

Refs #113. This covers stills; recording is blocked (see below), so the issue stays open.

What

  • backend: "wgc" on screenshot and find_text (window targets): captures the window's own surface through FFmpeg 8's gfxcapture, selected by window handle (hwnd=). There's no title regex to quote, and it can't match the wrong window. gdigrab stays the default.
  • Window enumeration now returns each window's HWND ([int64]$h), carried on WindowBounds.
  • wgcAvailable() probes ffmpeg -h filter=gfxcapture once. Without it, a clear error and hint. A non-window target with wgc is rejected.
  • Shared captureStill() (utils/still.ts) so both tools pick the backend the same way. Results report backend.

Measured (FFmpeg 8.1.1, Windows 11)

  • Covered window: lime window fully under a topmost magenta window → wgc mean RGB ≈ (2, 255, 0) (the window itself), gdigrab ≈ (255, 0, 255) (the cover). This is now a live-harness test.
  • Still latency: wgc 1.3-2.3 s vs gdigrab ~0.2 s, hence opt-in.
  • Recording is the blocker. gfxcapture emits a frame only when the window repaints. Recording a static window via -f lavfi -i gfxcapture… (with an fps fill or a constant-clock overlay) blocks waiting for input: ffmpeg ignores the graceful-stop q and the file comes out empty. That would break stop_recording, so start_recording and wait_for_change stay on gdigrab. The README documents this. A real fix probably needs a capture source that repeats the last frame on a timer (a native helper or an upstream gfxcapture option). I'll note it on Windows Graphics Capture backend via FFmpeg gfxcapture for true per-window capture #113.

Tests

  • Unit: WGC still args (handle, filtergraph), invalid handles.
  • Live harness: the covered-window test above, plus wgc on a region: target errors clearly. While here, I made the wait_for_change and screen_diff: let agents wait for and verify on-screen changes #116 wait_for_change live test wait until its window is actually up (PowerShell + WinForms startup varies), which fixed one flaky run. Harness 14/14, three runs in a row.
  • Full suite 275.

Version 0.20.0; README, mcp-tools.json, CHANGELOG.

🤖 Generated with Claude Code

screenshot and find_text accept backend: "wgc" for window: targets, which
captures the window's own surface by handle via FFmpeg 8's gfxcapture,
even when covered. Recordings stay on gdigrab: gfxcapture only emits a
frame on repaint, so a static-window recording stalls and ignores the
graceful stop.

Refs #113

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@TMHSDigital
TMHSDigital merged commit f387a31 into main Oct 24, 2026
8 checks passed
@TMHSDigital
TMHSDigital deleted the feat/gfxcapture-113 branch October 24, 2026 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant