fix: Windows recording dies ~1s in — write-stall platform contract + libopenh264 software fallback (#149)#151
Merged
Merged
Conversation
…t + libopenh264 fallback Issue #149 (petercr, real Windows device): recordings failed about one second in with "raw video FIFO timed out". Two coupled defects on the raw yuv420p leg Windows uses: 1. The raw FIFO writer's deadline was the recording QUEUE's 250ms age budget, anchored at frame submit time — a frame that waited out a Media Foundation pause in the latest-wins mailbox was declared dead before its first byte, and the sliding no-progress window was the same 250ms, so the Windows 30s hard timeout was unreachable. 2. Software h264_mf runs below realtime (0.86x at 1080p30 on the reporter's box), so the pipe backs up structurally no matter the timeout. Fixes: - New RAW_VIDEO_FIFO_WRITE_STALL_TOLERANCE (Windows 10s; elsewhere the existing 2s hard timeout). The write deadline anchors at WRITE START, and QueuedRawVideoFrame no longer carries a timestamp at all — the writer is structurally unable to drop a frame by age. Late frames are written; only a zero-progress pipe is fatal. - Windows software fallback switches from h264_mf to libopenh264 (~2.5x realtime on the reporter's device, benchmarked with the bundled ffmpeg) with -rc_mode bitrate -allow_skip_frames 1. New EncodeBackend::SoftwareOpenH264 ("software-open-h264") pinned across protocol serde, shared/backend.ts, and the diagnostics tab. Hardware Media Foundation stays the probed fast path. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughChangesEncoder fallback and raw FIFO behavior
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant RawYuv420pEncodingLoop
participant QueuedRawVideoFrame
participant RawWriterLoop
participant RawVideoFIFO
RawYuv420pEncodingLoop->>QueuedRawVideoFrame: enqueue frame without submitted_at
QueuedRawVideoFrame->>RawWriterLoop: deliver pending latest frame
RawWriterLoop->>RawVideoFIFO: start frame write
RawWriterLoop->>RawVideoFIFO: complete frame within stall tolerance or hard timeout
Possibly related PRs
Suggested reviewers: ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
TheOrcDev
added a commit
that referenced
this pull request
Jul 20, 2026
…165) - 0.9.47-beta.1 changelog: camera frame-rate mismatch warning + honest quality-check freeze verdicts (from #164), plus the 0.9.46 remote-control work shipping to macOS for the first time. - recording.rs: drop the needless &format! borrow in the cfg(windows) OpenH264 fallback log — it has been failing the Windows clippy gate on main since #151. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #149.
What was wrong
Two coupled defects on the raw yuv420p FIFO leg that Windows recordings use (no VideoToolbox there), confirming @petercr's excellent diagnosis:
RAW_VIDEO_FIFO_FRAME_WRITE_HARD_TIMEOUTwas unreachable. MF pauses draining the pipe for seconds at a time → healthy recording condemned as terminal ~1 second in.The fix
Write-stall tolerance is now a platform contract, decoupled from queue age (
encoder_bridge.rs):RAW_VIDEO_FIFO_WRITE_STALL_TOLERANCE: 10s on Windows, elsewhere the existing 2s hard timeout.QueuedRawVideoFrameno longer carries a timestamp at all — the writer is structurally unable to drop a frame by age. Age is a queue-admission concern; recording law: late frames are written, only a zero-byte-progress pipe is fatal.libopenh264 replaces software h264_mf as the Windows fallback (
recording.rs):FfmpegH264Platform::WindowsSoftware→libopenh264+yuv420pwith-rc_mode bitrate -allow_skip_frames 1(per the real-device benchmark: ~2.5x realtime at 1080p30/8Mbps with the bundled ffmpeg, which carries libopenh264 and no libx264).EncodeBackend::SoftwareOpenH264(wire valuesoftware-open-h264) pinned in the protocol serde test,shared/backend.ts, and the diagnostics tab formatter.Relationship to #141
Complementary: #141 disables the hardware probe on a box where it misbehaves; this PR fixes the contract that killed the session and makes the software fallback actually able to keep up. After this lands, a failed/disabled hardware probe degrades to a working openh264 recording instead of a dead one.
Not in this PR (future work): tee-backed hardware probe against a real capture sample (option 3); bundling libx264 (option 4 — unnecessary, GPL).
Tests
cargo test -p videorc-backend1310 green,cargo clippy -- -D warnings,cargo fmt --check,pnpm typecheck/lint/format:check.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes