fangfufu / Linux-Fake-Background-Webcam

Faking your webcam background under GNU/Linux, now supports background blurring, animated background, colour map effect, hologram effect and on-demand processing.
GNU General Public License v3.0
1.6k stars 161 forks source link

Invalid argument error #13

Closed sashavor closed 4 years ago

sashavor commented 4 years ago

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 commented 4 years ago

Did you set up your v4l2loopback device correctly?

sashavor commented 4 years ago

I created a file called /etc/modprobe.d/v4l2loopback.conf

and put "options v4l2loopback devices=1 exclusive_caps=1 video_nr=2 card_label="v4l2loopback"

Is there any way to check whether the v4l2loopback device is correctly set up?

On Wed, Apr 29, 2020 at 9:23 AM Fufu Fang notifications@github.com wrote:

Did you set up your v4l2loopback device correctly?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/fangfufu/Linux-Fake-Background-Webcam/issues/13#issuecomment-621202004, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADMMIITGUNGTMZS2YYWIVN3RPAS6XANCNFSM4MTWRAKA .

-- Sasha Luccioni, PhD Director of Scientific Projects (AI for Humanity, Mila), Postdoctoral Researcher (UdeM) Directrice des projets scientifiques (IA pour l'humanité, Mila), Chercheure postdoctorale (UdeM) [image: Image result for universite de montreal logo]

fangfufu commented 4 years ago

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 commented 4 years ago

v4l2-ctl --list-devices gives:

v4l2loopback (platform:v4l2loopback-000): /dev/video2

USB2.0 VGA UVC WebCam: USB2.0 V (usb-0000:00:14.0-9): /dev/video0 /dev/video1

would webcamoid be an alternative?

On Wed, Apr 29, 2020 at 9:33 AM Fufu Fang notifications@github.com wrote:

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

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

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/fangfufu/Linux-Fake-Background-Webcam/issues/13#issuecomment-621209610, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADMMIIUM6WF2SQPUYKDHEPDRPAUCXANCNFSM4MTWRAKA .

-- Sasha Luccioni, PhD Director of Scientific Projects (AI for Humanity, Mila), Postdoctoral Researcher (UdeM) Directrice des projets scientifiques (IA pour l'humanité, Mila), Chercheure postdoctorale (UdeM) [image: Image result for universite de montreal logo]

fangfufu commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

height and width print out fine, they are 640 and 480, and nothing is using my webcam at the moment..

I'll try the Docker version and let you know how it goes. Thanks!

On Wed, Apr 29, 2020 at 9:56 AM Fufu Fang notifications@github.com wrote:

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?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/fangfufu/Linux-Fake-Background-Webcam/issues/13#issuecomment-621225486, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADMMIITS2XUIK53HZMY6FJDRPAWX3ANCNFSM4MTWRAKA .

-- Sasha Luccioni, PhD Director of Scientific Projects (AI for Humanity, Mila), Postdoctoral Researcher (UdeM) Directrice des projets scientifiques (IA pour l'humanité, Mila), Chercheure postdoctorale (UdeM) [image: Image result for universite de montreal logo]

fangfufu commented 4 years ago

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

sashavor commented 4 years ago

that folder doesn't exist. I think that's the problem.

That means that the v4l2loopback device hasn't been set up, right? :)

On Wed, Apr 29, 2020 at 10:07 AM Fufu Fang notifications@github.com wrote:

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

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/fangfufu/Linux-Fake-Background-Webcam/issues/13#issuecomment-621233856, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADMMIITY7H6FELAUBVURSL3RPAYCBANCNFSM4MTWRAKA .

-- Sasha Luccioni, PhD Director of Scientific Projects (AI for Humanity, Mila), Postdoctoral Researcher (UdeM) Directrice des projets scientifiques (IA pour l'humanité, Mila), Chercheure postdoctorale (UdeM) [image: Image result for universite de montreal logo]

fangfufu commented 4 years ago

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

sashavor commented 4 years ago

should I try to install from their github? https://github.com/umlaeute/v4l2loopback

On Wed, Apr 29, 2020 at 10:27 AM Fufu Fang notifications@github.com wrote:

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

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/fangfufu/Linux-Fake-Background-Webcam/issues/13#issuecomment-621247084, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADMMIIWKLJ3GLJEY566SQJTRPA2OZANCNFSM4MTWRAKA .

-- Sasha Luccioni, PhD Director of Scientific Projects (AI for Humanity, Mila), Postdoctoral Researcher (UdeM) Directrice des projets scientifiques (IA pour l'humanité, Mila), Chercheure postdoctorale (UdeM) [image: Image result for universite de montreal logo]

fangfufu commented 4 years ago

I installed it from my distribution's package manager.

sashavor commented 4 years ago

Ok, I set it up, /dev/video2 exists and I modified the rights so it's not read-only anymore.

I'll try again!

On Wed, Apr 29, 2020 at 10:36 AM Fufu Fang notifications@github.com wrote:

I installed it from my distribution's package manager.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/fangfufu/Linux-Fake-Background-Webcam/issues/13#issuecomment-621252313, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADMMIIWMJFXBVVKMYMRSFNDRPA3N7ANCNFSM4MTWRAKA .

-- Sasha Luccioni, PhD Director of Scientific Projects (AI for Humanity, Mila), Postdoctoral Researcher (UdeM) Directrice des projets scientifiques (IA pour l'humanité, Mila), Chercheure postdoctorale (UdeM) [image: Image result for universite de montreal logo]

sashavor commented 4 years ago

Seems like other people are getting this issue: https://github.com/jremmons/pyfakewebcam/issues/5

On Wed, Apr 29, 2020 at 10:39 AM Sasha Luccioni sasha.luccioni@mila.quebec wrote:

Ok, I set it up, /dev/video2 exists and I modified the rights so it's not read-only anymore.

I'll try again!

On Wed, Apr 29, 2020 at 10:36 AM Fufu Fang notifications@github.com wrote:

I installed it from my distribution's package manager.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/fangfufu/Linux-Fake-Background-Webcam/issues/13#issuecomment-621252313, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADMMIIWMJFXBVVKMYMRSFNDRPA3N7ANCNFSM4MTWRAKA .

-- Sasha Luccioni, PhD Director of Scientific Projects (AI for Humanity, Mila), Postdoctoral Researcher (UdeM) Directrice des projets scientifiques (IA pour l'humanité, Mila), Chercheure postdoctorale (UdeM) [image: Image result for universite de montreal logo]

-- Sasha Luccioni, PhD Director of Scientific Projects (AI for Humanity, Mila), Postdoctoral Researcher (UdeM) Directrice des projets scientifiques (IA pour l'humanité, Mila), Chercheure postdoctorale (UdeM) [image: Image result for universite de montreal logo]

fangfufu commented 4 years ago

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

sashavor commented 4 years ago

I reinstalled v4l2loopback and I am not getting an error message anymore.. but I am getting just a blank video, all black -_-

On Wed, Apr 29, 2020 at 10:49 AM Fufu Fang notifications@github.com wrote:

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

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/fangfufu/Linux-Fake-Background-Webcam/issues/13#issuecomment-621260811, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADMMIIX4EC4M2CEUQQLN6LLRPA47JANCNFSM4MTWRAKA .

-- Sasha Luccioni, PhD Director of Scientific Projects (AI for Humanity, Mila), Postdoctoral Researcher (UdeM) Directrice des projets scientifiques (IA pour l'humanité, Mila), Chercheure postdoctorale (UdeM) [image: Image result for universite de montreal logo]

fangfufu commented 4 years ago

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

sashavor commented 4 years ago

I'll try. I just don't have Docker installed :)

On Wed, Apr 29, 2020 at 11:10 AM Fufu Fang notifications@github.com wrote:

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

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/fangfufu/Linux-Fake-Background-Webcam/issues/13#issuecomment-621274431, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADMMIIWH5BJYKV6M62CF7LTRPA7OBANCNFSM4MTWRAKA .

-- Sasha Luccioni, PhD Director of Scientific Projects (AI for Humanity, Mila), Postdoctoral Researcher (UdeM) Directrice des projets scientifiques (IA pour l'humanité, Mila), Chercheure postdoctorale (UdeM) [image: Image result for universite de montreal logo]

emanuelbatista commented 4 years ago

I've had the same issue reported by @sashavor

emanuelbatista commented 4 years ago

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 commented 4 years ago

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

sashavor commented 4 years ago

I definitely do! I changed it with chmod 777

On Wed., Apr. 29, 2020, 8:12 p.m. Fufu Fang, notifications@github.com wrote:

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

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/fangfufu/Linux-Fake-Background-Webcam/issues/13#issuecomment-621535890, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADMMIIVROVNPGXOYNKUGHJTRPC7ADANCNFSM4MTWRAKA .

emanuelbatista commented 4 years ago

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. :smiley:

fangfufu commented 4 years ago

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

celvin commented 4 years ago

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 commented 4 years ago

@celvin , have you installed your v4l2loopback DKMS correctly?

celvin commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

fangfufu commented 4 years ago

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

fangfufu commented 4 years ago

@celvin, this patch might have fixed your problem. https://github.com/fangfufu/Linux-Fake-Background-Webcam/pull/29

dlazesz commented 4 years ago

@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: https://github.com/jremmons/pyfakewebcam/issues/7#issuecomment-616617011

Maybe it would work for others as well.

fangfufu commented 4 years ago

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

fangfufu commented 4 years ago

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