Fix Windows DirectShow: Add virtual camera support and friendly names#657
Fix Windows DirectShow: Add virtual camera support and friendly names#657cmorillas wants to merge 1 commit intopion:masterfrom
Conversation
Fix three critical issues in Windows DirectShow camera driver:
1. Single-frame capture bug - streaming stopped after first frame
2. No virtual camera support - OBS Virtual Camera didn't work
3. Unfriendly device names - showed DirectShow paths instead of camera names
Changes:
- Remove Null Renderer connection to enable continuous frame delivery
- Auto-detect NV12 and YUY2 formats based on buffer size
- Convert both formats to I420 (4:2:0) for consistency
- Use IPropertyBag FriendlyName property for readable camera names
(e.g., "OBS Virtual Camera" instead of "@device_sw_{...}\{...}")
- Fix memory leak in Open() if listResolution fails
- Optimize NV12 conversion with loop unrolling
- Add channel buffer to reduce frame drops
- Add oleaut32 library dependency for VARIANT functions
Tested on:
- Windows 10/11
- OBS Virtual Camera (NV12 format) - now works
- Physical webcams (YUY2 format) - continue working
- Device enumeration shows friendly names
- Sustained 30+ FPS streaming
Files modified:
- pkg/driver/camera/camera_windows.cpp
- pkg/driver/camera/camera_windows.go
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #657 +/- ##
=======================================
Coverage 42.52% 42.52%
=======================================
Files 84 84
Lines 5703 5703
=======================================
Hits 2425 2425
Misses 3130 3130
Partials 148 148 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
at-wat
left a comment
There was a problem hiding this comment.
Thank you for fixing windows code!
(Most of the active developers don't use windows)
| memset(&mediaType, 0, sizeof(mediaType)); | ||
| mediaType.majortype = MEDIATYPE_Video; | ||
| mediaType.subtype = MEDIASUBTYPE_YUY2; | ||
| // Accept any format by leaving subtype as zeros (equivalent to GUID_NULL) |
There was a problem hiding this comment.
Is it possible that an incompatible format is chosen?
| // FIX: Don't connect to null renderer | ||
| // Null renderer causes DirectShow to pause after one frame |
There was a problem hiding this comment.
I thought output pins should be terminated by connecting to null renderer when I wrote this long ago. (I'm not familiar with windows API)
If it's not necessary, please remove the code instead of commenting out.
| fprintf(stderr, "Unexpected buffer size: %d (expected NV12=%d or YUY2=%d)\n", | ||
| len, expectedNV12, expectedYUY2); | ||
| return S_OK; |
There was a problem hiding this comment.
I think the whole program should fail instead of ignoring the data if an incompatible format is selected.
|
hi @cmorillas is this PR still active? |
|
Sorry. I forgot. No. It is not active
El vie, 30 ene 2026, 18:49, sean yu ***@***.***> escribió:
… *hexbabe* left a comment (pion/mediadevices#657)
<#657 (comment)>
hi @cmorillas <https://github.com/cmorillas> is this PR still active?
—
Reply to this email directly, view it on GitHub
<#657 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AR3W362HRXGI6MIWPOAOCOD4JOKQ7AVCNFSM6AAAAACJJNFXWSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTQMRUHEYTQOBRHA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Partially addresses #95 - Adds NV12 format support and fixes continuous frame delivery
Problem
The current Windows DirectShow implementation has three critical issues:
Solution
This PR fixes all three issues:
Testing
Tested on Windows 10/11 with:
Before/After
Device names:
Streaming:
Files Modified
pkg/driver/camera/camera_windows.cpp(~90 lines changed)pkg/driver/camera/camera_windows.go(~25 lines changed)Breaking Changes
None - 100% backward compatible
Notes
This patch was developed with Claude AI assistance through extensive testing and iteration. I'm not a C programmer, so please review carefully. Happy to address any feedback!
Co-authored-by: Claude AI https://claude.ai