Skip to content
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

Invalid argument error #13

Closed
sashavor opened this issue Apr 29, 2020 · 34 comments
Closed

Invalid argument error #13

sashavor opened this issue Apr 29, 2020 · 34 comments

Comments

@sashavor
Copy link

Hi!

Following all the steps, I get the following error when I run python3 fake.py

Traceback (most recent call last):
  File "fake.py", line 24, in <module>
    fake = pyfakewebcam.FakeWebcam('/dev/video2', width, height)
  File "/home/sasha/.local/lib/python3.6/site-packages/pyfakewebcam/pyfakewebcam.py", line 54, in __init__
    fcntl.ioctl(self._video_device, _v4l2.VIDIOC_S_FMT, self._settings)
OSError: [Errno 22] Invalid argument

But when I run ls /dev | grep -P '^video\d+$', I get:

video0
video1
video2

Thanks!

@fangfufu
Copy link
Owner

Did you set up your v4l2loopback device correctly?

@sashavor
Copy link
Author

sashavor commented Apr 29, 2020 via email

@fangfufu
Copy link
Owner

What does your v4l2-ctl --list-devices show?

You could try and install webcamoid, and see if that can output to your virtual webcam. The default Debian package works. (I am on Debian.)

@sashavor
Copy link
Author

sashavor commented Apr 29, 2020 via email

@fangfufu
Copy link
Owner

webcamnoid supports chromakey / colourkey, if you have a uniform background. You can use it to test whether your v4l2loopback works.

Have you tried the Docker version? Maybe it is some sort of dependency problem?

@fangfufu
Copy link
Owner

Also, is anything else using your real webcam? Why don't you get it to print out width and height just before opening up the virtual webcam?

@sashavor
Copy link
Author

sashavor commented Apr 29, 2020 via email

@fangfufu
Copy link
Owner

what's the permission of your /dev/video2?

@sashavor
Copy link
Author

sashavor commented Apr 29, 2020 via email

@fangfufu
Copy link
Owner

That's right, you didn't manage to set up v4l2loopback properly...

@sashavor
Copy link
Author

sashavor commented Apr 29, 2020 via email

@fangfufu
Copy link
Owner

I installed it from my distribution's package manager.

@sashavor
Copy link
Author

sashavor commented Apr 29, 2020 via email

@sashavor
Copy link
Author

sashavor commented Apr 29, 2020 via email

@fangfufu
Copy link
Owner

Ah okay, do let me know if installing the Github version of the v4l2loopback helps.

@sashavor
Copy link
Author

sashavor commented Apr 29, 2020 via email

@fangfufu
Copy link
Owner

Try the Docker version? At least the dependencies for fakecam work correctly in the Docker version.

@sashavor
Copy link
Author

sashavor commented Apr 29, 2020 via email

@emanuelbatista
Copy link

I've had the same issue reported by @sashavor

@emanuelbatista
Copy link

I use Ubuntu 20.04 and I installed the v4l2loopback via github too.

I've used Docker to run the app, but I got the error message:

Successfully built 696da11f66d1
Successfully tagged fakecam:latest
WARNING: Image for service fakecam was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating linux-fake-background-webcam_bodypix_1 ... done
Creating linux-fake-background-webcam_fakecam_1 ... done
Attaching to linux-fake-background-webcam_bodypix_1, linux-fake-background-webcam_fakecam_1
bodypix_1  | 2020-04-29 23:51:04.893277: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
bodypix_1  | 2020-04-29 23:51:04.910404: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 3592665000 Hz
bodypix_1  | 2020-04-29 23:51:04.911066: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x7098510 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
bodypix_1  | 2020-04-29 23:51:04.911094: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): Host, Default Version
fakecam_1  | [ WARN:0] global ../modules/videoio/src/cap_gstreamer.cpp (480) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
fakecam_1  | [ERROR:0] global ../modules/videoio/src/cap.cpp (116) open VIDEOIO(GSTREAMER): raised OpenCV exception:
fakecam_1  | 
fakecam_1  | OpenCV(4.2.0) ../modules/videoio/src/cap_gstreamer.cpp:743: error: (-215:Assertion failed) uridecodebin in function 'open'
fakecam_1  | 
fakecam_1  | 
fakecam_1  | Traceback (most recent call last):
fakecam_1  |   File "fake.py", line 24, in <module>
fakecam_1  |     fake = pyfakewebcam.FakeWebcam('/dev/video2', width, height)
fakecam_1  |   File "/usr/local/lib/python3.8/dist-packages/pyfakewebcam/pyfakewebcam.py", line 54, in __init__
fakecam_1  |     fcntl.ioctl(self._video_device, _v4l2.VIDIOC_S_FMT, self._settings)
fakecam_1  | OSError: [Errno 22] Invalid argument
linux-fake-background-webcam_fakecam_1 exited with code 1

@fangfufu
Copy link
Owner

Could you two double check that you have the write permission to /dev/video2 please?

@sashavor
Copy link
Author

sashavor commented Apr 30, 2020 via email

@emanuelbatista
Copy link

Could you two double check that you have the write permission to /dev/video2 please?

That worked for me, thank you for your support @fangfufu. 😃

@fangfufu
Copy link
Owner

fangfufu commented May 7, 2020

There hasn't been any updates from @sashavor for a week, closing the issue for now.

@fangfufu fangfufu closed this as completed May 7, 2020
@celvin
Copy link

celvin commented May 8, 2020

I use Ubuntu 20.04 and I installed the v4l2loopback via github too.

I've used Docker to run the app, but I got the error message:

Successfully built 696da11f66d1
Successfully tagged fakecam:latest
WARNING: Image for service fakecam was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating linux-fake-background-webcam_bodypix_1 ... done
Creating linux-fake-background-webcam_fakecam_1 ... done
Attaching to linux-fake-background-webcam_bodypix_1, linux-fake-background-webcam_fakecam_1
bodypix_1  | 2020-04-29 23:51:04.893277: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
bodypix_1  | 2020-04-29 23:51:04.910404: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 3592665000 Hz
bodypix_1  | 2020-04-29 23:51:04.911066: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x7098510 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
bodypix_1  | 2020-04-29 23:51:04.911094: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): Host, Default Version
fakecam_1  | [ WARN:0] global ../modules/videoio/src/cap_gstreamer.cpp (480) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
fakecam_1  | [ERROR:0] global ../modules/videoio/src/cap.cpp (116) open VIDEOIO(GSTREAMER): raised OpenCV exception:
fakecam_1  | 
fakecam_1  | OpenCV(4.2.0) ../modules/videoio/src/cap_gstreamer.cpp:743: error: (-215:Assertion failed) uridecodebin in function 'open'
fakecam_1  | 
fakecam_1  | 
fakecam_1  | Traceback (most recent call last):
fakecam_1  |   File "fake.py", line 24, in <module>
fakecam_1  |     fake = pyfakewebcam.FakeWebcam('/dev/video2', width, height)
fakecam_1  |   File "/usr/local/lib/python3.8/dist-packages/pyfakewebcam/pyfakewebcam.py", line 54, in __init__
fakecam_1  |     fcntl.ioctl(self._video_device, _v4l2.VIDIOC_S_FMT, self._settings)
fakecam_1  | OSError: [Errno 22] Invalid argument
linux-fake-background-webcam_fakecam_1 exited with code 1

I also have the same issue, using Docker and 777 rights in /dev/video2

@fangfufu fangfufu reopened this May 8, 2020
@fangfufu
Copy link
Owner

fangfufu commented May 8, 2020

@celvin , have you installed your v4l2loopback DKMS correctly?

@celvin
Copy link

celvin commented May 8, 2020

I'm using the docker way and installed v4l2loopback DKMS from ubuntu 18.04 repositories:

$ v4l2-ctl --list-devices
v4l2loopback (platform:v4l2loopback-000):
/dev/video2

HD Pro Webcam C920 (usb-0000:00:14.0-10):
/dev/video0
/dev/video1

@celvin
Copy link

celvin commented May 8, 2020

Now I've installed v4l2loopback from their repository and thanks to that now it works well,

Originally the image was black because the device v4l2loopback wasn't listed in the app as a new device, not sure why but after installing webcamoid the secondary device started to show up

docker log shows:

fakecam_1 | OpenCV(4.2.0) ../modules/videoio/src/cap_gstreamer.cpp:743: error: (-215:Assertion failed) uridecodebin in function 'open'

@fangfufu
Copy link
Owner

Sorry, I have absolutely no idea. What's your OS, @celvin, have you checked the permission of /dev/video*?

@fangfufu
Copy link
Owner

There hasn't been an update for a while. I am going to close the ticket for now.

@fangfufu
Copy link
Owner

@celvin, this patch might have fixed your problem.
#29

@dlazesz
Copy link
Contributor

dlazesz commented May 27, 2020

@fangfufu Could you insert a guide to "correctly" install v4l2loopback from the github repository into README.md?

I had the same error message as OP did, and this guide solved it for Ubuntu 18.04 docker: jremmons/pyfakewebcam#7 (comment)

Maybe it would work for others as well.

@fangfufu
Copy link
Owner

Feel free to edit the README.md, and submit a pull request. :)

@fangfufu
Copy link
Owner

fangfufu commented Jun 3, 2020

Hi everyone, I have added support for akvcam, please try it out if you are still having issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants