Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VideoCaptureWinRTInternal fails to read frames #86

Open
FrayxRulez opened this issue Sep 14, 2020 · 1 comment · May be fixed by #101
Open

VideoCaptureWinRTInternal fails to read frames #86

FrayxRulez opened this issue Sep 14, 2020 · 1 comment · May be fixed by #101

Comments

@FrayxRulez
Copy link
Contributor

FrayxRulez commented Sep 14, 2020

I'm running Windows 2004 on a MacBook Pro 2019, using VMware Fusion.
Built-in Camera app works properly with VMware virtual camera drivers, but VideoCaptureWinRTInternal fails to read frames from it.
All the initialization part goes pretty well, the implementation automatically selects kYUV2 over kI420 (that would be my preference), but then VideoCaptureWinRTInternal::FrameArrived fails to decode the bitmap: bitmap_buffer->GetPlaneCount returns 1 rather than 2 causing the whole thing to fail.
This seems to happen also on physical devices (to say, not VMs), but I can't confirm it's the same issue.

@FrayxRulez
Copy link
Contributor Author

FrayxRulez commented Sep 15, 2020

Did some further investigation, and this actually patches the thing. Probably a really bad solution, but it works.

diff --git a/modules/video_capture/windows/video_capture_winrt.cc b/modules/video_capture/windows/video_capture_winrt.cc
index 854f40e8b2..af79f6dcf6 100644
--- a/modules/video_capture/windows/video_capture_winrt.cc
+++ b/modules/video_capture/windows/video_capture_winrt.cc
@@ -513,15 +513,11 @@ HRESULT VideoCaptureWinRTInternal::FrameArrived(
       hr = bitmap_buffer->GetPlaneCount(&plane_count);
     }
 
-    if (SUCCEEDED(hr)) {
-      hr = plane_count == 2 ? S_OK : E_FAIL;
-    }
-
-    if (SUCCEEDED(hr)) {
+    if (SUCCEEDED(hr) && plane_count >= 1) {
       hr = bitmap_buffer->GetPlaneDescription(0, &bitmap_plane_description_y);
     }
 
-    if (SUCCEEDED(hr)) {
+    if (SUCCEEDED(hr) && plane_count == 2) {
       hr = bitmap_buffer->GetPlaneDescription(1, &bitmap_plane_description_uv);
     }
 

@FrayxRulez FrayxRulez linked a pull request Nov 23, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant