Repository navigation
Conversation
Read Windows capture back through a staging ring with DO_NOT_WAIT instead of a blocking Map plus a second full-frame copy, and let the fragmented/instant M4S muxer encode from the captured D3D11 texture through Media Foundation with the existing FFmpeg encoder as fallback. Also removes the unused win_segmented muxers and the never-invoked DiskSpaceCallback plumbing.
|
@Addin is attempting to deploy a commit to the Cap Software Inc Team on Vercel. A member of the Team first needs to authorize it. |
- Keep the readback budget authoritative by default; CAP_READBACK_BLOCKING opts into an unbounded Map. - Negotiate MFT types inside the candidate loop and handle WARP without VIDEO_SUPPORT. - Validate harness --path values and count failures only for exercised paths.
- Evict idle stale-size staging textures before reporting StagingBusy. - Size the benchmark copy from each mapped frame and rebuild old_frame on resize. - Require METransformDrainComplete and return errors on failed or timed-out drains. - Count drained samples in the encoder health output counters. - Keep benchmark runs alive across capture idle timeouts.
|
@greptileai review |
|
@greptileai review |
|
Thanks @Addin, this is a lot of careful work and the measurements on the Pavilion are really useful. We can't merge it as is. These are the things we found:
Smaller things: the 285-line Before merging we'll also need CI to run on Windows and a real-device pass: AMD under GPU load, Intel iGPU, NVIDIA, a hybrid laptop, ARM64, pause/resume, window resize, crash recovery, and 4K60. Removing the unused |
- Block in Map by default and keep the readback deadline behind CAP_READBACK_BUDGET_MS. - Gate the Media Foundation texture path to opt-in Instant recordings; Studio and future recordings fall back to FFmpeg. - Output BT.709 limited-range video from the MF path and tag the DASH muxer with BT.709 metadata. - Send END_OF_STREAM before DRAIN and treat a slow drain as non-fatal. - Preserve the existing MFT selection and keyframe behavior for the MP4/camera encoders.
|
Thanks for the detailed review. Addressed in 270c880:
Smaller items: the new Validation: |
|
@greptileai review |
1 similar comment
|
@greptileai review |
Summary
Windows capture currently copies every frame back to the CPU with a blocking
Map(READ), then copies it again into an FFmpeg frame. This removes the second copy: the mapped staging texture is wrapped directly as an FFmpeg-backed frame, and Instant M4S recordings can encode straight from the captured D3D11 texture through Media Foundation. FFmpeg remains the fallback.Changes
scap-direct3d: staging-texture ring with in-use tracking. The blockingMapis the default; the boundedDO_NOT_WAITdeadline is opt-in withCAP_READBACK_BUDGET_MS.scap-ffmpeg: the mapped staging texture is anAVBufferRef-backedAVFrame; no per-frame pool or memcpy.win_fragmented_m4s: the MF texture path is opt-in for Instant recordings (CAP_MF_TEXTURE_INPUT=1), Instant-only, and falls back to FFmpeg on setup failure. A runtime MF failure finalizes the segments already written and disables the path for later recordings. Studio always uses FFmpeg.enc-mediafoundation/mediafoundation-ffmpeg: explicit-bitrate constructor,sequence_header(),sample_to_packet, non-fatal encoder-tail drain. The M4S path iterates MFTs, requests 2 s keyframe spacing, and reads the sequence header fromGetOutputCurrentType. MP4/camera keep their previous MFT selection and keyframe behaviour.enc-ffmpeg: the M4S MF path outputs BT.709 limited range, tags the MF media types, andSegmentedPacketMuxerwrites BT.709/limited-range colour tags. MP4/camera colour behaviour is unchanged.scap-ffmpeg/examples/cli.rs:--benchA/B readback harness.win_segmented*muxers andDiskSpaceCallbackplumbing.Performance
Measured on an HP Pavilion Gaming Notebook (i7-6700HQ, GTX 950M + HD 530, Windows 11, 1080p60).
Results summary
The 720p/900p rows are from the earlier opt-in deadline run; the 1080p rows are from the default blocking
Map. Both runs had zero misses.Instant mode
Readback A/B (
--bench --seconds 30)The 1080p rows are a fresh isolated A/B run on the default blocking path; 720p/900p used the opt-in 8 ms deadline. Neither run missed a frame. The deadline remains available with
CAP_READBACK_BUDGET_MS.Validation
cargo fmt --all --checkcargo checkforscap-direct3d,scap-ffmpeg,cap-enc-mediafoundation,cap-mediafoundation-ffmpeg,cap-recording-D warningsscap-direct3d6/6,cap-mediafoundation-ffmpeg1/1, and theSegmentedPacketMuxerinit/colour-tag testScope / follow-up
H264StreamMuxer) is unchanged; this targets Instant/fragmented M4S.

Confidence Score: 5/5
The PR appears safe to merge with texture encoding remaining opt-in.Summary
This PR removes a Windows frame copy and adds opt-in texture encoding for Instant recordings.
Reviews (5) · Last reviewed commit: "fix(recording): address Windows capture ..." · Reviewed by Greptile