From 7626f6fe784dd2f05cf97b040a37cfcb9feba881 Mon Sep 17 00:00:00 2001 From: Avasam Date: Mon, 22 May 2023 13:43:16 -0400 Subject: [PATCH] Catch pygrabber failure when adding video input device --- src/capture_method/__init__.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/capture_method/__init__.py b/src/capture_method/__init__.py index 12067412..c8fe942b 100644 --- a/src/capture_method/__init__.py +++ b/src/capture_method/__init__.py @@ -208,12 +208,17 @@ class CameraInfo(): name: str occupied: bool backend: str - resolution: tuple[int, int] | None + resolution: tuple[int, int] def get_input_device_resolution(index: int): filter_graph = FilterGraph() - filter_graph.add_video_input_device(index) + try: + filter_graph.add_video_input_device(index) + # This can happen since OBS 29.1 DLL blocking breaking VirtualCam + # https://github.com/Toufool/AutoSplit/issues/238 + except COMError: + return None resolution = filter_graph.get_input_device().get_current_format() filter_graph.remove_filters() return resolution @@ -242,7 +247,10 @@ async def get_camera_info(index: int, device_name: str): # finally: # video_capture.release() - return CameraInfo(index, device_name, False, backend, get_input_device_resolution(index)) + resolution = get_input_device_resolution(index) + return CameraInfo(index, device_name, False, backend, resolution) \ + if resolution is not None \ + else None future = asyncio.gather( *[