jremmons / pyfakewebcam

A library for writing RGB frames to a fake webcam device on Linux!
GNU Lesser General Public License v3.0
9 stars 2 forks source link

OSError: [Errno 22] Invalid argument fcntl.ioctl #7

Open saifrahmed opened 4 years ago

saifrahmed commented 4 years ago

Dear @jremmons - Firstly thanks for this project, this is exactly what I was looking for!

I tried running the project (both pip installed and via local pulls (both tagged release and master branch) but keep getting and "OSError: [Errno 22] Invalid argument" on the fcntl.ioctl call.

I tried using both webcams w/o success. I also did a ls /dev | grep video and tried the different devices w/o success.

Suspecting an issue with the settings object _v4l2.v4l2_format() I also tried to strip that down w/o success. I'm running on Ubuntu 18 with all the required dependency installs. Any suggestions on possible ways to debug this?

Traceback (most recent call last):
    camera = pyfakewebcam.FakeWebcam('/dev/video20', 640, 480)
  File "/home/sahmed/WORKSPACE/scantrac/ctnr-fakecam/pyfakewebcam/pyfakewebcam.py", line 54, in __init__
    fcntl.ioctl(self._video_device, _v4l2.VIDIOC_S_FMT, self._settings)
OSError: [Errno 22] Invalid argument
enteryournamehere commented 4 years ago

I'm running into the same issue on Mint 19.3:

Traceback (most recent call last):
  File "webtest.py", line 11, in <module>
    camera = pyfakewebcam.FakeWebcam('/dev/video20', 640, 480)
  File "/usr/local/lib/python3.6/dist-packages/pyfakewebcam-0.1.0-py3.6.egg/pyfakewebcam/pyfakewebcam.py", line 56, in __init__
    fcntl.ioctl(self._video_device, _v4l2.VIDIOC_S_FMT, self._settings)
OSError: [Errno 22] Invalid argument
jjenly commented 4 years ago

its seems Proposed solution was to install the kernel module from github instead of using the officially distributed v4l2-loopback package from Ubuntu 18.04

https://github.com/umlaeute/v4l2loopback/issues/172

enteryournamehere commented 4 years ago

That seems to fix it, thanks!

pedrodiamel commented 4 years ago

Ubuntu 18.04 Linux 5.3.0-46-generic

remove apt package

sudo modprobe -r v4l2loopback sudo apt remove v4l2loopback-dkms

install aux

sudo apt-get install linux-generic sudo apt install dkms

install v4l2loopback from the repository

https://github.com/umlaeute/v4l2loopback.git cd v4l2loopback make

instal mod

sudo cp -R . /usr/src/v4l2loopback-1.1 sudo dkms add -m v4l2loopback -v 1.1 sudo dkms build -m v4l2loopback -v 1.1 sudo dkms install -m v4l2loopback -v 1.1 sudo reboot

bgeels commented 4 years ago

Do you happen to know if these steps are relevant for Ubuntu 20.04? Thanks!

cahidenes commented 3 years ago

Using video2 instead of video1 worked for me. (Ubuntu 20.04)

Alwinator commented 3 years ago

I have the same problem with Ubuntu 21.04. (I have already tried all mentioned fixes). Any ideas?

JanSurft commented 3 years ago

I have the same problem with Ubuntu 21.04. (I have already tried all mentioned fixes). Any ideas?

Do sudo modprobe -r v4l2loopback

see the output of ls /dev/video*

In your modprobe command choose a virtual device number that is not already present.

In my case I used modprobe v4l2loopback devices=1 exclusive_caps=1 video_nr=7 card_label="v4l2loopback"

With 7 being an id that was not existing prior to activating v4l2loopback.

Alwinator commented 3 years ago

@JanSurft Thanks a lot! Now it works! I think the explicit phrase of the video ID did the trick.

sudo modprobe -r v4l2loopback
sudo modprobe v4l2loopback devices=1 exclusive_caps=1 video_nr=7 card_label="v4l2loopback"
ls /dev/video*

image

ghost commented 3 years ago

@JanSurft Thanks a lot! Now it works! I think the explicit phrase of the video ID did the trick.

sudo modprobe -r v4l2loopback
sudo modprobe v4l2loopback devices=1 exclusive_caps=1 video_nr=7 card_label="v4l2loopback"
ls /dev/video*

image

For me, it was /dev/video20. Why does that happen, and can I set the number manually to 2?