[Windows] Add DirectShow support for capture cards not detected by Qt6/WMF - #1154
[Windows] Add DirectShow support for capture cards not detected by Qt6/WMF#1154CYLMos wants to merge 7 commits into
Conversation
|
Posting to say that this has my attention and isn't being ignored. But it is big and will take time to review. Thanks for doing this! |
|
This might get a revisit in the next month or so when we start experimenting with GPU acceleration on the video display (which is a really bad problem now that we are able to achieve 4k60 via NV12). There's a good chance that what we have in mind for GPU acceleration is going to conflict with this. So we're likely to try studying this before we make a decision on what to do since it uses OpenCV. If we do decide to pick this up, testing is going to be difficult since we lack DirectShow-only capture cards. Maybe OBS's virtual camera can be leveraged. But I think that might be video-only. |
| rect(), | ||
| qimage, | ||
| QRect(0, 0, qimage.width(), qimage.height()) | ||
| ); |
There was a problem hiding this comment.
Looking forward to the 4k60 world, painting video frames on the UI thread is what has been biting us. So we won't be definitely won't be able to use this as-is as we try moving to hardware acceleration.
Summary
Qt6 uses Windows Media Foundation (WMF) exclusively for
QMediaDevices::videoInputs()and WASAPI for audio enumeration. Capture cards that only provide DirectShow drivers (e.g. AVerMedia GC550) are invisible to both APIs, making them impossible to select in the Video/Audio dropdowns.This PR adds a Windows-only DirectShow backend for video and audio capture to support these devices.
All changes are made by AI (Claude Opuse 4.6). please reivew the code carefully. Maybe somethings messed up by AI but I didn't notice.
Known issues:
Root Cause
QMediaDevices::videoInputs()returns nothing for these devices.QAudioDevice.Changes
New files (Windows-only,
#ifdef _WIN32):DirectShowCameraList.h/.cpp— Enumerates DirectShow video devices viaICreateDevEnum; identifies devices absent from Qt6's WMF list; providesget_video_devices_with_audio_pins()for embedded audio pins. Device names use the conventiondshow:<index>:<friendly_name>.CameraVideoSource_OpenCV.h/.cpp— OpenCV-based video capture widget usingcv::VideoCapture(index, cv::CAP_DSHOW). Features:Qt::PreciseTimerat 16 ms for ~60 FPS displayWA_OpaquePaintEvent/WA_NoSystemBackgroundto prevent flickershared_ptr<atomic<bool>alive flag to prevent use-after-free crashreport_source_frame()andnotify_rendered_frame()for correct FPS statsDirectShowAudioCapture.h/.cpp— Captures audio from a DirectShow video filter's audio pin viaISampleGrabberCB::BufferCBcallback. Filter graph: source filter → SampleGrabber → NullRenderer, connected viaICaptureGraphBuilder2::RenderStreamwith triple pin category fallback (PIN_CATEGORY_CAPTURE→PIN_CATEGORY_PREVIEW→nullptr).Modified files:
get_all_cameras()appends DirectShow-only devices;get_camera_name()handlesdshow:prefix.VideoSource_Camera.cpp— InstantiatesCameraVideoSource_OpenCVwhen adshow:device is selected.AudioInfo.cpp— Adds DirectShow audio pin enumeration;dshow_audio:devices are given supported formats{MONO_48000, DUAL_44100, DUAL_48000}withpreferred_format_index = 2.AudioSource.cpp— ConstructsDirectShowAudioCapturefordshow_audio:devices.MediaServicesQt6.cpp— Adds COM initialization (CoInitializeEx) in the audio thread body.cmake/SourceFiles.cmake— Registers all new source files.Testing
Tested with AVerMedia GC550 on Windows 11, MSVC 2022, Qt 6.8.3
Notes
#ifdef _WIN32and has no effect on Linux/macOS builds.QMediaDevices::videoInputs().