-
Notifications
You must be signed in to change notification settings - Fork 54
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
"No v4l2 loopback device found" after using pyvirtualcam once with exclusive_caps=1
#61
Comments
I'm unable to reproduce this on Ubuntu 18.04 (kernel 4.15.0-143) using the same v4l2loopback version with/without running |
Also, if you choose a specific device you will see a better error message, for example: with pyvirtualcam.Camera(width=1280, height=720, fps=20, device="/dev/video0") as cam: This must match the device created by v4l2loopback obviously. |
Thanks for your quick response. This issue occurs even without any consumer connected at any point. I just started a script and quit it (Ctrl+c) and then tried to restart it, resulting in above error. I also tried specifying the device to use which resulted in this error:
Until now I didn't try connecting another producer after having run a pyvirtualcam script. I just tried with OBS, and OBS can connect to the loopback device. I even added another v4l2 source in OBS and selected my loopback device, and it worked. Yesterday, I tried the virtualvideo module which uses ffmpeg for accessing the loopback device. I just tried running their showFish.py sample after having used pyvirtualcam and it worked, too. Neither Basically, it looks like pyvirtualcam leaves the loopback device in a state that makes it unaccessible for pyvirtualcam again but not for any other application. I attached
while in the failing case it shows:
Interestingly, pyvirtualcam doesn't detect
(after):
I am not especially apt in reading |
Not exactly sure what's going on. How do you create the device? Are you using |
If I remove There's still the question why every other application but pyvirtualcam isn't bothered by having the loopback device been used before. But that's more out of curiosity than urgency. |
exclusive_caps=1
On my end I still can't reproduce it with the same modprobe line you've given, with For me, before running the pyvirtualcam script, |
I do face the same issue on gentoo linux (pyvirtualcam==0.8.0). |
After modprobe, befor using: After terminating: |
I am using Since in my case If there is any other additional information that you need to recreate the issue, please ask me : ) |
I'm experiencing a very similar (perhaps, identical?) problem. If I load v4l2 by running:
I can only start pyvirtualcamera once. The second time I do it, I get the following error:
One workaround is to load the module with Details of my system: I'm using Python 3.10.4. |
Same issue for me under Ubuntu 22
|
Similar issue for me running Ubuntu 22.04.3 LTS:
This is the code I'm running, it's the basic greyscale animation with a SIGINT handler for a graceful exit (which I thought was the issue...): main.pyimport signal
import pyvirtualcam
import numpy as np
GLOBAL_SIGINT_RECEIVED = False
def onSigint(sig, frame):
global GLOBAL_SIGINT_RECEIVED
GLOBAL_SIGINT_RECEIVED = True
signal.signal(signal.SIGINT, onSigint)
with pyvirtualcam.Camera(width=1280, height=720, fps=20, device="/dev/video0") as cam:
print(f'Using virtual camera: {cam.device}')
frame = np.zeros((cam.height, cam.width, 3), np.uint8) # RGB
while True:
frame[:] = cam.frames_sent * 4 % 255 # grayscale animation
cam.send(frame)
cam.sleep_until_next_frame()
if (GLOBAL_SIGINT_RECEIVED) :
break This is the output of Output of v4l2-ctl BEFORE running the code, WITH exclusive_caps=1
Output of v4l2-ctl AFTER running the code, WITH exclusive_caps=1
This is the exception raised by my program: And this is the output i have creating the device without Output of v4l2-ctl BEFORE running the code, WITHOUT exclusive_caps=1
Output of v4l2-ctl AFTER running the code, WITHOUT exclusive_caps=1
|
Fix: Stop the video stream before closing the device, e.g: ioctl(vcam->device, VIDIOC_STREAMOFF, &parm) A fix might be to insert this before 'close(_camera_fd);':
Maybe as an extra function, as the close() is used 3 times. |
@GermanWarez Are you able to test this and create a PR if it works? |
@letmaik TODO: Add ioctl to set both VIDIOC_STREAMON and VIDIOC_STREAMOFF, using the fix for obs as reference. |
I hit the same issue. Wait, nobody tested the PR since March? |
Describe the bug
After running a script using pyvirtualcam the next run causes this error:
Only after unloading and reloading the kernel module I can run another script using pyvirtualcam.
To Reproduce
Every single sample code causes this error.
I even rewrote a script to not use the
with
statement and callcam.close()
(and evencam._backend.close()
) directly.The text was updated successfully, but these errors were encountered: