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

fcntl.ioctl() Invalid argument #5

Closed yingshaoxo closed 4 years ago

yingshaoxo commented 4 years ago

After running the example, I get this error:

Traceback (most recent call last):
  File "test.py", line 12, in <module>
    camera = pyfakewebcam.FakeWebcam('/dev/video1', 640, 480)
  File "/usr/local/lib/python3.7/dist-packages/pyfakewebcam/pyfakewebcam.py", line 55, in __init__
    fcntl.ioctl(self._video_device, _v4l2.VIDIOC_S_FMT, self._settings)
OSError: [Errno 22] Invalid argument

So I printed out the self._video_device, _v4l2.VIDIOC_S_FMT, self._settings:

9 -1060088315 <pyfakewebcam.v4l2.v4l2_format object at 0x7f234b6701e0>

I don't know where goes wrong there. Can you have a look? Please.

makovez commented 4 years ago

Getting same error here

namoso ~/xdrive/pyfakewebcam/examples $ python flashing_doge.py 
Traceback (most recent call last):
  File "flashing_doge.py", line 8, in <module>
    cam = pyfakewebcam.FakeWebcam('/dev/video1', 1280, 720)
  File "/usr/local/lib/python3.7/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
namoso ~/xdrive/pyfakewebcam/examples $

using fedora

racksold commented 4 years ago

I also just stuck with the same:

Traceback (most recent call last):
  File "/home/racks/PycharmProjects/vicam/ex.py", line 12, in <module>
    camera = pyfakewebcam.FakeWebcam('/dev/video1', 640, 480)
  File "/home/racks/PycharmProjects/vicam/venv/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

using Ubuntu 18.04 LTS

thecaralice commented 4 years ago

I managed to fix it. Try selecting different device - for me /dev/video1 was being used and modprobe created /dev/video2 and /dev/video3. Check ls /dev | grep -P '^video\d+$' output for available video devices and select one of the last ones.

racksold commented 4 years ago

I managed to fix it. Try selecting different device - for me /dev/video1 was being used and modprobe created /dev/video2 and /dev/video3. Check ls /dev | grep -P '^video\d+$' output for available video devices and select one of the last ones.

actually I has already done that.

I have 3 devices (1, 2 virtual): root@ubuntu:/home/racks# v4l2-ctl --list-devices Dummy video device (0x0000) (platform:v4l2loopback-000): /dev/video1 Dummy video device (0x0001) (platform:v4l2loopback-001): /dev/video2 Droidcam (platform:v4l2loopback_dc-000): /dev/video0

I have tried all of them and got the same error.

yingshaoxo commented 4 years ago

No, it still not work.

But here has good news for you guys: nowadays nobody uses a built-in pc camera anymore. Everybody uses they phone to record videos.

thecaralice commented 4 years ago

I managed to fix it. Try selecting different device - for me /dev/video1 was being used and modprobe created /dev/video2 and /dev/video3. Check ls /dev | grep -P '^video\d+$' output for available video devices and select one of the last ones.

actually I has already done that.

I have 3 devices (1, 2 virtual): root@ubuntu:/home/racks# v4l2-ctl --list-devices Dummy video device (0x0000) (platform:v4l2loopback-000): /dev/video1 Dummy video device (0x0001) (platform:v4l2loopback-001): /dev/video2 Droidcam (platform:v4l2loopback_dc-000): /dev/video0

I have tried all of them and got the same error.

Does ffplay /dev/videoX work?

yingshaoxo commented 4 years ago

@MinerChAI

Hi there, I think the problem here is that you are using a different OS than us.

I'm personally using ubuntu 19.10.

What's yours? (This is maybe the key to solve this problem since the author of this package disappeared)

makovez commented 4 years ago

I need it to "fake" the camera of my pc. I can't fake the camera of my android device.

Il Mer 8 Apr 2020, 17:01 yingshaoxo notifications@github.com ha scritto:

No, it still not work.

But here has good news for you guys: nowadays nobody uses a built-in pc camera anymore. Everybody uses they phone to record videos.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jremmons/pyfakewebcam/issues/5#issuecomment-611010437, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFFQR4ZNLRB6CEXFZQMMFPLRLSGVFANCNFSM4KPIEMFQ .

thecaralice commented 4 years ago

@MinerChAI

Hi there, I think the problem here is that you are using a different OS than us.

I'm personally using ubuntu 19.10.

What's yours? (This is maybe the key to solve this problem since the author of this package disappeared)

Mine is Manjaro but I don't think that's the problem

racksold commented 4 years ago

I managed to fix it. Try selecting different device - for me /dev/video1 was being used and modprobe created /dev/video2 and /dev/video3. Check ls /dev | grep -P '^video\d+$' output for available video devices and select one of the last ones.

actually I has already done that. I have 3 devices (1, 2 virtual): root@ubuntu:/home/racks# v4l2-ctl --list-devices Dummy video device (0x0000) (platform:v4l2loopback-000): /dev/video1 Dummy video device (0x0001) (platform:v4l2loopback-001): /dev/video2 Droidcam (platform:v4l2loopback_dc-000): /dev/video0 I have tried all of them and got the same error.

Does ffplay /dev/videoX work?

Yes, for my webcam it works fine for other video devices (virtual) I get this result:

(base) racks@ubuntu:~$ ffplay /dev/video2 ffplay version 3.4.6-0ubuntu0.18.04.1 Copyright (c) 2003-2019 the FFmpeg developers built with gcc 7 (Ubuntu 7.3.0-16ubuntu3) configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared libavutil 55. 78.100 / 55. 78.100 libavcodec 57.107.100 / 57.107.100 libavformat 57. 83.100 / 57. 83.100 libavdevice 57. 10.100 / 57. 10.100 libavfilter 6.107.100 / 6.107.100 libavresample 3. 7. 0 / 3. 7. 0 libswscale 4. 8.100 / 4. 8.100 libswresample 2. 9.100 / 2. 9.100 libpostproc 54. 7.100 / 54. 7.100 [video4linux2,v4l2 @ 0x7f6bac000b80] Cannot open video device /dev/video2: No such file or directory /dev/video2: No such file or directory nan : 0.000 fd= 0 aq= 0KB vq= 0KB sq= 0B f=0/0

thecaralice commented 4 years ago

I managed to fix it. Try selecting different device - for me /dev/video1 was being used and modprobe created /dev/video2 and /dev/video3. Check ls /dev | grep -P '^video\d+$' output for available video devices and select one of the last ones.

actually I has already done that. I have 3 devices (1, 2 virtual): root@ubuntu:/home/racks# v4l2-ctl --list-devices Dummy video device (0x0000) (platform:v4l2loopback-000): /dev/video1 Dummy video device (0x0001) (platform:v4l2loopback-001): /dev/video2 Droidcam (platform:v4l2loopback_dc-000): /dev/video0 I have tried all of them and got the same error.

Does ffplay /dev/videoX work?

Yes, for my webcam it works fine for other video devices (virtual) I get this result:

(base) racks@ubuntu:~$ ffplay /dev/video2 ffplay version 3.4.6-0ubuntu0.18.04.1 Copyright (c) 2003-2019 the FFmpeg developers built with gcc 7 (Ubuntu 7.3.0-16ubuntu3) configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared libavutil 55. 78.100 / 55. 78.100 libavcodec 57.107.100 / 57.107.100 libavformat 57. 83.100 / 57. 83.100 libavdevice 57. 10.100 / 57. 10.100 libavfilter 6.107.100 / 6.107.100 libavresample 3. 7. 0 / 3. 7. 0 libswscale 4. 8.100 / 4. 8.100 libswresample 2. 9.100 / 2. 9.100 libpostproc 54. 7.100 / 54. 7.100 [video4linux2,v4l2 @ 0x7f6bac000b80] Cannot open video device /dev/video2: No such file or directory /dev/video2: No such file or directory nan : 0.000 fd= 0 aq= 0KB vq= 0KB sq= 0B f=0/0

Did you run the modprobe thing?

racksold commented 4 years ago

I managed to fix it. Try selecting different device - for me /dev/video1 was being used and modprobe created /dev/video2 and /dev/video3. Check ls /dev | grep -P '^video\d+$' output for available video devices and select one of the last ones.

actually I has already done that. I have 3 devices (1, 2 virtual): root@ubuntu:/home/racks# v4l2-ctl --list-devices Dummy video device (0x0000) (platform:v4l2loopback-000): /dev/video1 Dummy video device (0x0001) (platform:v4l2loopback-001): /dev/video2 Droidcam (platform:v4l2loopback_dc-000): /dev/video0 I have tried all of them and got the same error.

Does ffplay /dev/videoX work?

Yes, for my webcam it works fine for other video devices (virtual) I get this result: (base) racks@ubuntu:~$ ffplay /dev/video2 ffplay version 3.4.6-0ubuntu0.18.04.1 Copyright (c) 2003-2019 the FFmpeg developers built with gcc 7 (Ubuntu 7.3.0-16ubuntu3) configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared libavutil 55. 78.100 / 55. 78.100 libavcodec 57.107.100 / 57.107.100 libavformat 57. 83.100 / 57. 83.100 libavdevice 57. 10.100 / 57. 10.100 libavfilter 6.107.100 / 6.107.100 libavresample 3. 7. 0 / 3. 7. 0 libswscale 4. 8.100 / 4. 8.100 libswresample 2. 9.100 / 2. 9.100 libpostproc 54. 7.100 / 54. 7.100 [video4linux2,v4l2 @ 0x7f6bac000b80] Cannot open video device /dev/video2: No such file or directory /dev/video2: No such file or directory nan : 0.000 fd= 0 aq= 0KB vq= 0KB sq= 0B f=0/0

Did you run the modprobe thing?

of course:

root@ubuntu:/home/racks# modprobe v4l2loopback devices=2 root@ubuntu:/home/racks# v4l2-ctl --list-devices Dummy video device (0x0000) (platform:v4l2loopback-000): /dev/video1

Dummy video device (0x0001) (platform:v4l2loopback-001): /dev/video2

Droidcam (platform:v4l2loopback_dc-000): /dev/video0

thecaralice commented 4 years ago

I managed to fix it. Try selecting different device - for me /dev/video1 was being used and modprobe created /dev/video2 and /dev/video3. Check ls /dev | grep -P '^video\d+$' output for available video devices and select one of the last ones.

actually I has already done that. I have 3 devices (1, 2 virtual): root@ubuntu:/home/racks# v4l2-ctl --list-devices Dummy video device (0x0000) (platform:v4l2loopback-000): /dev/video1 Dummy video device (0x0001) (platform:v4l2loopback-001): /dev/video2 Droidcam (platform:v4l2loopback_dc-000): /dev/video0 I have tried all of them and got the same error.

Does ffplay /dev/videoX work?

Yes, for my webcam it works fine for other video devices (virtual) I get this result: (base) racks@ubuntu:~$ ffplay /dev/video2 ffplay version 3.4.6-0ubuntu0.18.04.1 Copyright (c) 2003-2019 the FFmpeg developers built with gcc 7 (Ubuntu 7.3.0-16ubuntu3) configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared libavutil 55. 78.100 / 55. 78.100 libavcodec 57.107.100 / 57.107.100 libavformat 57. 83.100 / 57. 83.100 libavdevice 57. 10.100 / 57. 10.100 libavfilter 6.107.100 / 6.107.100 libavresample 3. 7. 0 / 3. 7. 0 libswscale 4. 8.100 / 4. 8.100 libswresample 2. 9.100 / 2. 9.100 libpostproc 54. 7.100 / 54. 7.100 [video4linux2,v4l2 @ 0x7f6bac000b80] Cannot open video device /dev/video2: No such file or directory /dev/video2: No such file or directory nan : 0.000 fd= 0 aq= 0KB vq= 0KB sq= 0B f=0/0

Did you run the modprobe thing?

of course:

root@ubuntu:/home/racks# modprobe v4l2loopback devices=2 root@ubuntu:/home/racks# v4l2-ctl --list-devices Dummy video device (0x0000) (platform:v4l2loopback-000): /dev/video1

Dummy video device (0x0001) (platform:v4l2loopback-001): /dev/video2

Droidcam (platform:v4l2loopback_dc-000): /dev/video0

And what about ls /dev | grep -P '^video\d+$'?

racksold commented 4 years ago

I managed to fix it. Try selecting different device - for me /dev/video1 was being used and modprobe created /dev/video2 and /dev/video3. Check ls /dev | grep -P '^video\d+$' output for available video devices and select one of the last ones.

actually I has already done that. I have 3 devices (1, 2 virtual): root@ubuntu:/home/racks# v4l2-ctl --list-devices Dummy video device (0x0000) (platform:v4l2loopback-000): /dev/video1 Dummy video device (0x0001) (platform:v4l2loopback-001): /dev/video2 Droidcam (platform:v4l2loopback_dc-000): /dev/video0 I have tried all of them and got the same error.

Does ffplay /dev/videoX work?

Yes, for my webcam it works fine for other video devices (virtual) I get this result: (base) racks@ubuntu:~$ ffplay /dev/video2 ffplay version 3.4.6-0ubuntu0.18.04.1 Copyright (c) 2003-2019 the FFmpeg developers built with gcc 7 (Ubuntu 7.3.0-16ubuntu3) configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared libavutil 55. 78.100 / 55. 78.100 libavcodec 57.107.100 / 57.107.100 libavformat 57. 83.100 / 57. 83.100 libavdevice 57. 10.100 / 57. 10.100 libavfilter 6.107.100 / 6.107.100 libavresample 3. 7. 0 / 3. 7. 0 libswscale 4. 8.100 / 4. 8.100 libswresample 2. 9.100 / 2. 9.100 libpostproc 54. 7.100 / 54. 7.100 [video4linux2,v4l2 @ 0x7f6bac000b80] Cannot open video device /dev/video2: No such file or directory /dev/video2: No such file or directory nan : 0.000 fd= 0 aq= 0KB vq= 0KB sq= 0B f=0/0

Did you run the modprobe thing?

of course: root@ubuntu:/home/racks# modprobe v4l2loopback devices=2 root@ubuntu:/home/racks# v4l2-ctl --list-devices Dummy video device (0x0000) (platform:v4l2loopback-000): /dev/video1 Dummy video device (0x0001) (platform:v4l2loopback-001): /dev/video2 Droidcam (platform:v4l2loopback_dc-000): /dev/video0

And what about ls /dev | grep -P '^video\d+$'?

it sees only the real webcam

(base) racks@ubuntu:~$ ls /dev | grep -P '^video\d+$'
video0
thecaralice commented 4 years ago

I managed to fix it. Try selecting different device - for me /dev/video1 was being used and modprobe created /dev/video2 and /dev/video3. Check ls /dev | grep -P '^video\d+$' output for available video devices and select one of the last ones.

actually I has already done that. I have 3 devices (1, 2 virtual): root@ubuntu:/home/racks# v4l2-ctl --list-devices Dummy video device (0x0000) (platform:v4l2loopback-000): /dev/video1 Dummy video device (0x0001) (platform:v4l2loopback-001): /dev/video2 Droidcam (platform:v4l2loopback_dc-000): /dev/video0 I have tried all of them and got the same error.

Does ffplay /dev/videoX work?

Yes, for my webcam it works fine for other video devices (virtual) I get this result: (base) racks@ubuntu:~$ ffplay /dev/video2 ffplay version 3.4.6-0ubuntu0.18.04.1 Copyright (c) 2003-2019 the FFmpeg developers built with gcc 7 (Ubuntu 7.3.0-16ubuntu3) configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared libavutil 55. 78.100 / 55. 78.100 libavcodec 57.107.100 / 57.107.100 libavformat 57. 83.100 / 57. 83.100 libavdevice 57. 10.100 / 57. 10.100 libavfilter 6.107.100 / 6.107.100 libavresample 3. 7. 0 / 3. 7. 0 libswscale 4. 8.100 / 4. 8.100 libswresample 2. 9.100 / 2. 9.100 libpostproc 54. 7.100 / 54. 7.100 [video4linux2,v4l2 @ 0x7f6bac000b80] Cannot open video device /dev/video2: No such file or directory /dev/video2: No such file or directory nan : 0.000 fd= 0 aq= 0KB vq= 0KB sq= 0B f=0/0

Did you run the modprobe thing?

of course: root@ubuntu:/home/racks# modprobe v4l2loopback devices=2 root@ubuntu:/home/racks# v4l2-ctl --list-devices Dummy video device (0x0000) (platform:v4l2loopback-000): /dev/video1 Dummy video device (0x0001) (platform:v4l2loopback-001): /dev/video2 Droidcam (platform:v4l2loopback_dc-000): /dev/video0

And what about ls /dev | grep -P '^video\d+$'?

it sees only the real webcam

(base) racks@ubuntu:~$ ls /dev | grep -P '^video\d+$'
video0

Then seems like modprobe didn't create the devices

yingshaoxo commented 4 years ago

@MinerChAI Thank you for your help.

Now I know how to make it work.

Step 1:

install pyfakewebcam by sudo pip3 install pyfakewebcam

Step 2:

install v4l2 by sudo apt install v4l2loopback-utils

Step 3:

set v4l2 by modprobe v4l2loopback devices=1

Step 4:

check the right virtual cam by ls /dev | grep -P '^video\d+$'. use the last one, for example, /dev/video3

Step 5:

run python script:

import time
import pyfakewebcam
import numpy as np

blue = np.zeros((480,640,3), dtype=np.uint8)
blue[:,:,2] = 255

red = np.zeros((480,640,3), dtype=np.uint8)
red[:,:,0] = 255

camera = pyfakewebcam.FakeWebcam('/dev/video3', 640, 480)

while True:

    camera.schedule_frame(red)
    time.sleep(1/30.0)

    camera.schedule_frame(blue)
    time.sleep(1/30.0)

Step 6:

check the result by ffplay /dev/video3

In the end

Big thanks to the author @jremmons

makovez commented 4 years ago

Is it possible to install v4l2loopback-utils On fedora?

Il Gio 9 Apr 2020, 12:06 yingshaoxo notifications@github.com ha scritto:

@MinerChAI https://github.com/MinerChAI Thank you for your help.

Now I know how to make it work. Step 1:

install pyfakewebcam by sudo pip3 install pyfakewebcam Step 2:

install v4l2 by sudo apt install v4l2loopback-utils Step 3:

set v4l2 by modprobe v4l2loopback devices=1 Step 4:

check the right virtual cam by ls /dev | grep -P '^video\d+$'. use the last one, for example, /dev/video3 Step 5:

run python script:

import time import pyfakewebcam import numpy as np

blue = np.zeros((480,640,3), dtype=np.uint8) blue[:,:,2] = 255

red = np.zeros((480,640,3), dtype=np.uint8) red[:,:,0] = 255

camera = pyfakewebcam.FakeWebcam('/dev/video3', 640, 480)

while True:

camera.schedule_frame(red)
time.sleep(1/30.0)

camera.schedule_frame(blue)
time.sleep(1/30.0)

Step 6:

check the result by ffplay /dev/video3 In the end

Big thanks to the author @jremmons https://github.com/jremmons

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jremmons/pyfakewebcam/issues/5#issuecomment-611445561, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFFQR46HD25H4KOUYFFPYZ3RLWM2FANCNFSM4KPIEMFQ .

merwok commented 4 years ago

FWIW I have read in another tutorial that after running modprobe xyz, you should run depmod -a to ensure that any module required by xyz is also loaded.

racksold commented 4 years ago

@MinerChAI Thank you for your help.

Now I know how to make it work.

Step 1:

install pyfakewebcam by sudo pip3 install pyfakewebcam

Step 2:

install v4l2 by sudo apt install v4l2loopback-utils

Step 3:

set v4l2 by modprobe v4l2loopback devices=1

Step 4:

check the right virtual cam by ls /dev | grep -P '^video\d+$'. use the last one, for example, /dev/video3

Step 5:

run python script:

import time
import pyfakewebcam
import numpy as np

blue = np.zeros((480,640,3), dtype=np.uint8)
blue[:,:,2] = 255

red = np.zeros((480,640,3), dtype=np.uint8)
red[:,:,0] = 255

camera = pyfakewebcam.FakeWebcam('/dev/video3', 640, 480)

while True:

    camera.schedule_frame(red)
    time.sleep(1/30.0)

    camera.schedule_frame(blue)
    time.sleep(1/30.0)

Step 6:

check the result by ffplay /dev/video3

In the end

Big thanks to the author @jremmons

actually I have done just like you have written and still have just this:

(base) racks@ubuntu:~/PycharmProjects/vicam$ python ex.py
Warning! opencv could not be imported; performace will be degraded!
Traceback (most recent call last):
  File "ex.py", line 12, in <module>
    camera = pyfakewebcam.FakeWebcam('/dev/video1', 640, 480)
  File "/home/racks/anaconda3/lib/python3.7/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
merwok commented 4 years ago

If you have v4l-utils installed, you can run v4l2-ctl --list-devices to confirm which device should be used.

mmatthe commented 4 years ago

Same issue here:

$ sudo modprobe v4l2loopback devices=1 video_nr=20 card_label='v4l2loopback' exclusive_caps=1
$ sudo depmod -a
$ v4l2-ctl --list-devices
v4l2loopback (platform:v4l2loopback-000):
    /dev/video20

Webcam C170: Webcam C170 (usb-0000:00:1a.0-1.2):
    /dev/video0
    /dev/video1
$ ls /dev | grep -P '^video\d+$' 
video0
video1
video20
Traceback (most recent call last):
  File "fakexample.py", line 12, in <module>
    camera = pyfakewebcam.FakeWebcam('/dev/video20', 640, 480)
  File "/tmp/env/lib/python3.7/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

Update and fix

I fixed it with some more research. An v4l2 loopback issue suggested there are problems with some newer kernel version. Proposed solution was to install the kernel module from github instead of using the officially distributed v4l2-loopback package from Ubuntu 18.04. Hence, downloaded and installed, and now the red/blue example is working.