letmaik / pyvirtualcam

🎥 Send frames to a virtual camera from Python
GNU General Public License v2.0
455 stars 49 forks source link

Virtual Camera may not be cleaning up after usage #5

Closed rahatzamancse closed 3 years ago

rahatzamancse commented 3 years ago

For example, here is a simple snippet to reproduce the error

import pyvirtualcam

with pyvirtualcam.Camera(640, 480, 20, 0, print_fps=True) as cam:
    print("Everything works fine")

with pyvirtualcam.Camera(640, 480, 20, 0, print_fps=True) as cam:
    print("Here it throws the error")

This outputs as follows:

Everything works fine
virtual camera output already started
Traceback (most recent call last):
  File "d:\vcam\ultra-virtual-cam-filter\test.py", line 6, in <module>
    with pyvirtualcam.Camera(640, 480, 20, 0, print_fps=True) as cam:
  File "C:\Users\rahat\.conda\envs\vcam\lib\site-packages\pyvirtualcam\camera.py", line 86, in __init__
    _native_windows.start(width, height, fps, delay)
RuntimeError: error starting virtual camera output

So, my guess is, maybe it is not calling the below function at all? https://github.com/letmaik/pyvirtualcam/blob/d88dd87c46d5c700378a882e78e8c61ae02eac9e/pyvirtualcam/native_windows/controller/controller.cpp#L67

DevZiegler commented 3 years ago

Hi have you found a solution. I can confirm the error when running the samples simple.py script. (after restarting the script)

letmaik commented 3 years ago

Fixed in the upcoming release.