|
6 | 6 | from enum import Enum, EnumMeta, unique
|
7 | 7 | from typing import TYPE_CHECKING, TypedDict, cast
|
8 | 8 |
|
| 9 | +from _ctypes import COMError # pylint: disable=C2701 |
9 | 10 | from pygrabber.dshow_graph import FilterGraph
|
10 | 11 |
|
11 | 12 | from capture_method.BitBltCaptureMethod import BitBltCaptureMethod
|
|
14 | 15 | from capture_method.ForceFullContentRenderingCaptureMethod import ForceFullContentRenderingCaptureMethod
|
15 | 16 | from capture_method.VideoCaptureDeviceCaptureMethod import VideoCaptureDeviceCaptureMethod
|
16 | 17 | from capture_method.WindowsGraphicsCaptureMethod import WindowsGraphicsCaptureMethod
|
17 |
| -from utils import WINDOWS_BUILD_NUMBER, first, try_get_direct3d_device |
| 18 | +from utils import GITHUB_REPOSITORY, WINDOWS_BUILD_NUMBER, first, try_get_direct3d_device |
18 | 19 |
|
19 | 20 | if TYPE_CHECKING:
|
20 | 21 | from AutoSplit import AutoSplit
|
@@ -44,11 +45,10 @@ class CaptureMethodMeta(EnumMeta):
|
44 | 45 | # Allow checking if simple string is enum
|
45 | 46 | def __contains__(self, other: str):
|
46 | 47 | try:
|
47 |
| - self(other) # pyright: ignore [reportGeneralTypeIssues] pylint: disable=no-value-for-parameter |
| 48 | + self(other) # pylint: disable=no-value-for-parameter |
48 | 49 | except ValueError:
|
49 | 50 | return False
|
50 |
| - else: |
51 |
| - return True |
| 51 | + return True |
52 | 52 |
|
53 | 53 |
|
54 | 54 | @unique
|
@@ -147,17 +147,26 @@ def get(self, __key: CaptureMethodEnum):
|
147 | 147 |
|
148 | 148 | implementation=BitBltCaptureMethod,
|
149 | 149 | )
|
150 |
| -CAPTURE_METHODS[CaptureMethodEnum.DESKTOP_DUPLICATION] = CaptureMethodInfo( |
151 |
| - name="Direct3D Desktop Duplication", |
152 |
| - short_description="slower, bound to display", |
153 |
| - description=( |
154 |
| - "\nDuplicates the desktop using Direct3D. " |
155 |
| - "\nIt can record OpenGL and Hardware Accelerated windows. " |
156 |
| - "\nAbout 10-15x slower than BitBlt. Not affected by window size. " |
157 |
| - "\nOverlapping windows will show up and can't record across displays. " |
158 |
| - ), |
159 |
| - implementation=DesktopDuplicationCaptureMethod, |
160 |
| -) |
| 150 | +try: |
| 151 | + import d3dshot |
| 152 | + d3dshot.create(capture_output="numpy") |
| 153 | +except (ModuleNotFoundError, COMError): |
| 154 | + pass |
| 155 | +else: |
| 156 | + CAPTURE_METHODS[CaptureMethodEnum.DESKTOP_DUPLICATION] = CaptureMethodInfo( |
| 157 | + name="Direct3D Desktop Duplication", |
| 158 | + short_description="slower, bound to display", |
| 159 | + description=( |
| 160 | + "\nDuplicates the desktop using Direct3D. " |
| 161 | + "\nIt can record OpenGL and Hardware Accelerated windows. " |
| 162 | + "\nAbout 10-15x slower than BitBlt. Not affected by window size. " |
| 163 | + "\nOverlapping windows will show up and can't record across displays. " |
| 164 | + "\nThis option may not be available for hybrid GPU laptops, " |
| 165 | + "\nsee D3DDD-Note-Laptops.md for a solution. " |
| 166 | + f"\nhttps://www.github.com/{GITHUB_REPOSITORY}#capture-method " |
| 167 | + ), |
| 168 | + implementation=DesktopDuplicationCaptureMethod, |
| 169 | + ) |
161 | 170 | CAPTURE_METHODS[CaptureMethodEnum.PRINTWINDOW_RENDERFULLCONTENT] = CaptureMethodInfo(
|
162 | 171 | name="Force Full Content Rendering",
|
163 | 172 | short_description="very slow, can affect rendering",
|
|
0 commit comments