You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(windows): prevent OBS Virtual Camera from freezing during recording - #1684
On Windows, OBS Virtual Camera can produce a stuttering preview and a webcam recording that holds its first frame while the screen recording continues. A looping OBS media source reproduces the recording freeze without a phone or physical camera. The same virtual-camera stream records with motion in FFmpeg.
Set a null reference clock on the DirectShow graph for the OBS Virtual Camera CLSID before starting capture. The change is confined to electron/native/wgc-capture/src/dshow_webcam_capture.cpp. OpenScreen continues to timestamp the screen and camera on its shared recording clock.
Validated on Windows 11 with OBS Studio 33.0.3 and the OpenScreen 2.4.0 Store build. The patched helper recorded 181 camera frames in about six seconds without a freeze. In a separate test with a four-second pause, both tracks finished at 12.368 seconds and the test pattern timecode showed no accumulated camera delay after resume. This change targets the saved webcam recording. The preview before recording was not validated.
Summary by CodeRabbit
Bug Fixes
OBS Virtual Camera capture now uses updated synchronization settings during initialization. If those settings cannot be applied, capture initialization fails instead of continuing with an incomplete setup.
Other camera devices are unaffected by this change.
Review was skipped as selected files did not have any reviewable changes.
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: defaults
Review profile: CHILL
Plan: Advanced
Run ID: 94a66526-f026-486c-a0bc-5e433ae85e0f
Commits
Reviewing files that changed from the base of the PR and between 7385775 and c5e67f3.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
For OBS Virtual Camera, DirectShow capture initialization now disables the graph reference clock. If querying IMediaFilter or setting the sync source fails, initialization returns false. Other devices skip this behavior.
Changes: OBS Virtual Camera clock handling
Layer / File(s)
Summary
Identify the device and configure its graph clock electron/native/wgc-capture/src/dshow_webcam_capture.cpp
The code adds the OBS Virtual Camera CLSID. For that device, initialization queries IMediaFilter and calls SetSyncSource(nullptr). Initialization returns false if either operation fails. Other devices do not enter this branch.
This change targets the OBS Virtual Camera freeze on Windows and applies only to that device, so other webcams keep their existing behavior. No merge-blocking risk is identified. Preview behavior was not validated, as the PR states.
Pre-merge checks: 4
Check name
Status
Explanation
Linked Issues check
Issue #1683 requires a fix for the OBS Virtual Camera recording freeze on Windows. It asks for IMediaFilter::SetSyncSource(nullptr) before Run(), limited to the OBS Virtual Camera CLSID, with other we…
Out of Scope Changes check
The whole-PR diff against the merge base changes one file, electron/native/wgc-capture/src/dshow_webcam_capture.cpp, with +12 lines. Every change is the new CLSID constant, the OBS-only SetSyncSource(…
Title check
The title names the fix (preventing OBS Virtual Camera freezing) and the platform (Windows), which matches the changeset. It sets a null reference clock on the DirectShow graph for the OBS Virtual Cam…
Description check
The description covers the problem, the approach, the affected file, and the validation performed, and it links issue #1683. It states the scope limit that preview was not validated. The template's Ty…
Full details: Linked Issues check
Explanation
Issue #1683 requires a fix for the OBS Virtual Camera recording freeze on Windows. It asks for IMediaFilter::SetSyncSource(nullptr) before Run(), limited to the OBS Virtual Camera CLSID, with other webcam graphs unchanged and timestamps still on the shared recording clock. The diff in dshow_webcam_capture.cpp adds CLSID_ObsVirtualCamera ({A3FCE0F5-3493-419F-958A-ABA1250EC20B}). After the sample grabber setup and before the IMediaControl query, which precedes Run(), it calls SetSyncSource(nullptr) only when selectedClsid matches that CLSID. Other devices skip this path. Failures return false. No file outside the helper changed, so the shared recording clock is untouched. The issue asks for no automated tests, and the diff adds none. Preview behavior is out of scope per the issue. Limitation: the diff context does not show the declaration of selectedClsid, so the compile-time scope was not independently confirmed.
Full details: Out of Scope Changes check
Explanation
The whole-PR diff against the merge base changes one file, electron/native/wgc-capture/src/dshow_webcam_capture.cpp, with +12 lines. Every change is the new CLSID constant, the OBS-only SetSyncSource(nullptr) block, and an INFO log line. All of these serve issue #1683. No unrelated files, refactors, or preview-path changes appear in the diff.
Full details: Title check
Explanation
The title names the fix (preventing OBS Virtual Camera freezing) and the platform (Windows), which matches the changeset. It sets a null reference clock on the DirectShow graph for the OBS Virtual Camera CLSID, and the title describes that outcome. The title is specific and concise.
Full details: Description check
Explanation
The description covers the problem, the approach, the affected file, and the validation performed, and it links issue #1683. It states the scope limit that preview was not validated. The template's Type of change, Release impact, Desktop impact, and Screenshots sections are not filled in. The Testing section is written as narrative results rather than steps or commands, and the template's Related issue wording uses 'Fixes #1683', which is valid.
Resolution
Optional improvements: tick the Type of change (Bug fix), Release impact (Patch), and Desktop impact (Windows) boxes, state that no screenshots apply or add a short video, and list the test commands or steps in the Testing section. The Summary section could also be a brief one-line statement at the top, separate from the background.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
frayzis
changed the title
Fix OBS Virtual Camera freeze on Windows
fix(windows): prevent OBS Virtual Camera from freezing during recording
Nov 25, 2026
The reason will be displayed to describe this comment to others. Learn more.
Thanks @frayzis. I tested 73857758c on Windows 11 (RTX 4090 Laptop) with the official OBS Studio 33.0.3 virtual camera (CLSID {A3FCE0F5-3493-419F-958A-ABA1250EC20B}), fed a looping test card with a frame counter. The WGC helper was built from this head and from its parent 2b65ea937 with the same toolchain and flags, so the two binaries differ only by this change.
Pass:
A/B on the helper. I drove each build directly with a config built from the fields in electron/ipc/handlers.ts (display capture plus OBS Virtual Camera at 1280x720@30). The app path is tested separately, below. Both builds miss the device in Media Foundation and fall back to DirectShow (Requested webcam device was not found by Media Foundation; trying DirectShow); only this head logs INFO: OBS Virtual Camera DirectShow graph clock disabled.
Build
Camera track
freezedetect
Counter at 2 s / 10 s / 20 s
parent
742 frames, 24.7 s
frozen from 0 s to the end
23 / 23 / 23
this head (two takes)
743 and 740 frames, 24.7 s
no freeze
18 / 26 / 36
Through the app. I selected OBS Virtual Camera in Device settings and recorded a 29 s take with a ~5 s pause:
The floating camera preview kept moving during the take (counter 18 → 28, then 44 after resume).
The camera and screen tracks both came out at 28.834 s, and the camera track has no freeze.
Media Foundation cameras keep their path. A USB UVC webcam was picked by Media Foundation (score=1000), and the new branch did not run.
About the evidence in the description. The frame count on its own ("181 camera frames in about six seconds") would look the same without the fix: the frozen parent take above also has ~30 fps of frames, because captureLoop stores whatever GetCurrentBuffer returns on every tick and bumps the sequence each time. The moving test-pattern timecode you checked in the pause test is what tells the two apart (as does ffmpeg -vf freezedetect), so it may be worth leading with that.
Worth checking. I couldn't tie these to the change, but two starts with this head stalled out of about eight:
Right after a frozen take with the parent helper, the next take with this head spent over two minutes before DirectShow format negotiation (DirectShow webcam format), which runs before the new code. It then failed with Timed out waiting for first WGC frame.
The first app take after restarting OBS failed with Timed out waiting for native Windows capture to start. The next app take started in under a second.
After restarting OBS, three direct takes started in under a second. The parent helper only ran twice and didn't stall. My guess is OBS's virtual camera being left in a bad state, not this change.
Small things:
If QueryInterface(IMediaFilter) or SetSyncSource fails, initialize returns false (dshow_webcam_capture.cpp:349-353) and the take continues without a camera. Logging a warning and carrying on with the clock attached would keep today's behaviour as the fallback.
The comment at :345-347 could say why it stalls: OBS stamps samples with absolute reference time and ignores tStart.
The PR template's Type of change, Release impact and Desktop impact boxes are unchecked.
Not covered: a non-OBS DirectShow-only camera (I don't have one), Windows 10 and arm64. The USB webcam smoke test ended with SinkWriter::Finalize failed (0xc00d4a44) because the camera delivered no visible frames in a dark room. The parent helper fails the same way, so I can't read anything about this change from it.
The failing "Rust test (macOS compositor)" job is audio::tests::a_clipped_voice_exports_under_minus_one_dbtp_and_keeps_what_loudness_it_can, which fails the same way on main at 96e3cd327 (run 45831334221). #1678, still open, fixes it.
Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.
Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.
Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.
Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.
This branch has not been deployed
No deployments
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
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 #1683
On Windows, OBS Virtual Camera can produce a stuttering preview and a webcam recording that holds its first frame while the screen recording continues. A looping OBS media source reproduces the recording freeze without a phone or physical camera. The same virtual-camera stream records with motion in FFmpeg.
Set a null reference clock on the DirectShow graph for the OBS Virtual Camera CLSID before starting capture. The change is confined to
electron/native/wgc-capture/src/dshow_webcam_capture.cpp. OpenScreen continues to timestamp the screen and camera on its shared recording clock.Validated on Windows 11 with OBS Studio 33.0.3 and the OpenScreen 2.4.0 Store build. The patched helper recorded 181 camera frames in about six seconds without a freeze. In a separate test with a four-second pause, both tracks finished at 12.368 seconds and the test pattern timecode showed no accumulated camera delay after resume. This change targets the saved webcam recording. The preview before recording was not validated.
Summary by CodeRabbit