feat(moq-video): native Windows Media Foundation capture, drop nokhwa#1716
Merged
Conversation
Replace the last nokhwa dependency with a native Media Foundation webcam capture on Windows, so frame capture is now native on all three platforms (AVFoundation/ScreenCaptureKit on macOS, V4L2 on Linux, Media Foundation on Windows). The new capture drives an IMFSourceReader with the source reader's video processor enabled, so whatever the camera emits (MJPEG / YUY2 / NV12) is coerced to NV12, which we deinterleave to CPU I420 for the encoder. Devices are enumerated via MFEnumDeviceSources and selected by index or a friendly-name substring. The COM/MF lifecycle is balanced per open/close on the single blocking capture thread, and Drop calls IMFMediaSource::Shutdown so the camera releases promptly (LED off) when a viewer leaves, preserving the on-demand open/close model. The Windows FFI is type-checked against the x86_64-pc-windows-msvc target, but the path is not yet exercised on real Windows hardware. See the DESIGN-native-codecs.md "unverified" section. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
kixelated
enabled auto-merge (squash)
June 14, 2026 02:53
kixelated
disabled auto-merge
June 14, 2026 02:54
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.
Summary
Implements native Windows webcam capture via Media Foundation, replacing the last
nokhwadependency. Frame capture is now native on all three platforms: AVFoundation/ScreenCaptureKit (macOS), V4L2 (Linux), Media Foundation (Windows).capture/mediafoundation.rsdrives anIMFSourceReaderwith the source reader's video processor enabled, so whatever the camera emits (MJPEG / YUY2 / NV12) is coerced to NV12. Each sample is copied to a tightly-packed CPUI420(newI420::from_nv12, a chroma deinterleave with no color conversion) for the openh264 / NVENC path.MFEnumDeviceSourcesand selected by index or a friendly-name substring (--camera).DropcallsIMFMediaSource::Shutdownso the camera releases promptly (LED off) when the last viewer leaves, preserving the on-demand open/close model that the rest ofmoq-videorelies on.nokhwadep; addswindows = "0.62"(resolves to the 0.62.2 already in the tree vianetwatch, so no duplicate version).webcam.rsdeleted.DESIGN-native-codecs.md, crate-level docs, anddoc/bin/cli.md(which still had stale ffmpeg-era "dshow /h264_videotoolbox" capture wording).Public API
No public API or wire change. Capture is internal to
moq-video; this swaps the Windows backend implementation and removes a dependency.Config,Encoder,Producer,publish_capture, andErrorare unchanged. Targetsdev, where the rest of the moq-video native-codecs overhaul (#1691, #1704) lives and which the DESIGN doc designates for this work.Test plan
cargo clippy -p moq-videoclean (host/macOS)cargo test -p moq-video— 10/10 passmoq-cli --features capturebuilds (host)x86_64-pc-windows-msvc(verified in a scratch crate; the whole crate can't cross-compile from the dev Mac because openh264's vendored C++ build needs MSVC)IMF2DBuffer::ContiguousCopyToyields unpadded NV12 so the deinterleave is correct, (3) the open /Shutdown/ reopen cycle releases and reacquires the camera cleanly. Tracked in the DESIGN doc's "unverified" section.Remaining DESIGN cleanup after this: re-introduce VAAPI once
cros-codecsbuilds against libva ≥ 2.23.🤖 Generated with Claude Code
(Written by Claude)