lovettchris / wincam

A fast screen capture library for python on Windows 10 and above (x64 only).
MIT License
20 stars 7 forks source link

Failed to capture when working from inside a remote desktop app #4

Open morya opened 3 months ago

morya commented 3 months ago
Press ENTER to stop recording...Capture failed -2147467262
Exception in thread Thread-1 (<lambda>):
Traceback (most recent call last):
  File "D:\Python312\Lib\threading.py", line 1073, in _bootstrap_inner
    self.run()
  File "D:\Python312\Lib\threading.py", line 1010, in run
    self._target(*self._args, **self._kwargs)
  File "D:\pyws\demo1\wincam_example\t1.py", line 78, in <lambda>
    self._thread = Thread(target=lambda: self.video_thread(x, y, w, h, fps))
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\pyws\demo1\wincam_example\t1.py", line 51, in video_thread
    frame, timestamp = camera.get_bgr_frame()
                       ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\.virtualenvs\pyws-enCgLOFr\Lib\site-packages\wincam\dxcam.py", line 58, in get_bgr_frame
    raise Exception(f"Failed to start capture, error code {f'{-hr:02x}'}")
Exception: Failed to start capture, error code 7fffbffe

sample code was copied from example folder of this repo.

examples/video.py

lovettchris commented 3 months ago

Hmmm, that will need some debugging, but the fact that it failed before even reaching the error message "CreateCaptureSession is not supported on this version of Windows" means you might have a GPU problem, do you know what GPU you are using?

wincam requires Windows 10 version 10.0.26100.0 or later, or Windows 11. And you must have a GPU that supports DirectX 11. Specifically we call D3D11CreateDevice asking for hardware support for D3D11_SDK_VERSION on D3D11_CREATE_DEVICE_BGRA_SUPPORT images.

blaxkwidow commented 3 months ago

check https://github.com/lovettchris/wincam/pull/6

mrAntiUser commented 2 months ago

I confirm

Failed to start capture, error code 7fffbffe
  File "E:\Dev\Project\Python\ddd\main.py", line 213, in copy_backup_proc
    frame, _ = camera.get_bgr_frame()
               ^^^^^^^^^^^^^^^^^^^^^^
  File "E:\Dev\Project\Python\ddd\main.py", line 166, in copy_backup
    self._modifyCallback(self._src_dir, loc_path)
  File "E:\Dev\Project\Python\ddd\main.py", line 190, in <lambda>
    threading.Timer(DELAY_BEFORE_BACKUP, lambda: self.copy_backup()).start()
                                                 ^^^^^^^^^^^^^^^^^^
Exception: Failed to start capture, error code 7fffbffe

win10, dx12, rtx4080

WHalcyon commented 2 months ago

Getting the same Error: Failed to start capture, error code 7fffbffe running one of the examples while meeting all requirements.

lovettchris commented 1 week ago

Try moving your VM to windows 11. I do have Azure VM's running Windows 11 where wincam is working perfectly.