Closed jas-ts closed 4 years ago
I am having the same issue. Where you able to solve it?
Same here
hashtag me too!
I encountered the same problem on UBUNTU 18.04 LTS, but it seems to only appear on 18.04 LTS platform, installv4l2loopback-dkms
on Ubuntu 19.10 on Raspberry Pi 4, and then use ffmepg to work fine. I had suspected a problem with ffmpeg, because the default apt installed version is 3.4.6, and the Raspberry Pi is 4.1.4. I uninstalled ffmpeg installed by apt and installed it using snap. Now ffmpeg on x64 platform is also the 4.1.4 version, but it doesn't work either.
The Ubuntu 18.04 kernel version on the x64 platform is 5.3.0-40-generic # 32 ~ 18.04.1-Ubuntu
, the Ubuntu 19.10 kernel version on the Raspberry Pi 4 is 5.3.00-1018-raspi2 # 20-Ubuntu
.
In addition, I also tried to compile and install the code of v4l2loopback from git on the x64 platform, because I found that the v4l2loopback installed by Raspberry Pi 19.10 using apt is the version of 0.12.2-1
, while the UBUNTU 1804 LTS on x86 is 0.10 .0-1ubuntu1.2
version. I used 0.12.2 and 0.12.3 and the code from the master branch to compile and install, but none worked.
I tested UBUNTU 19.10 on the x64 platform and found that v4l2loopback works normally. The installed version is the same as that of the Raspberry Pi's Ubuntu, both of which are 0.12.2. I tried to install the v4l2loopback-dkms_0.12.2-1_all.deb package of Ubuntu 19.10 on Ubuntu 18.04LTS separately, but I still get an error using ffmpeg:
swscaler @ 0x555853b98300] deprecated pixel format used, make sure you did set range correctly [video4linux2,v4l2 @ 0x555853b3b880] Unable to open V4L2 device '/dev/video20' Could not write header for output file #0 (incorrect codec parameters ?): Operation not permitted Error initializing output stream 0:0 --
dmesg:
[ 51.843214] mc: Linux media interface: v0.10 [ 51.848001] videodev: Linux video capture interface: v2.00 [ 51.848207] v4l2loopback: loading out-of-tree module taints kernel. [ 51.848237] v4l2loopback: module verification failed: signature and/or required key missing - tainting kernel [ 51.848701] v4l2loopback:
' invalid for parameter
debug' [ 57.630417] v4l2-loopback[2414]: creating v4l2loopback-device #0 [ 57.630424] v4l2-loopback[2255]: buffer_size = 0 (=0) [ 57.630520] v4l2-loopback[2414]: creating v4l2loopback-device #1 [ 57.630524] v4l2-loopback[2255]: buffer_size = 0 (=0) [ 57.630591] v4l2-loopback[2414]: creating v4l2loopback-device #2 [ 57.630594] v4l2-loopback[2255]: buffer_size = 0 (=0) [ 57.630658] v4l2-loopback[2414]: creating v4l2loopback-device #3 [ 57.630666] v4l2-loopback[2255]: buffer_size = 0 (=0) [ 57.630761] v4l2-loopback[2435]: module installed [ 57.630762] v4l2loopback driver version 0.12.2 loaded [ 57.633632] v4l2-loopback[1858]: opened dev:000000009e5eacf3 with image:000000006aeac343 [ 57.633678] v4l2-loopback[1964]: freeing image@000000006aeac343 for dev:000000009e5eacf3 [ 57.633684] v4l2-loopback[1858]: opened dev:00000000aa6e05f0 with image:000000006aeac343 [ 57.633690] v4l2-loopback[1858]: opened dev:000000006ec57220 with image:000000006aeac343 [ 57.633723] v4l2-loopback[1964]: freeing image@000000006aeac343 for dev:00000000aa6e05f0 [ 57.633729] v4l2-loopback[1964]: freeing image@000000006aeac343 for dev:000000006ec57220 [ 57.634412] v4l2-loopback[1858]: opened dev:000000004672366c with image:000000006aeac343 [ 57.634453] v4l2-loopback[1964]: freeing image@000000006aeac343 for dev:000000004672366c
same issue here Compiling from source in Ubuntu 18.04
Started working after removing the version installed by apt then installing from source and restarting ¯_(ツ)_/¯
Same issue on Linux 5.3.0-46-generic #38~18.04.1-Ubuntu SMP Tue Mar 31 04:17:56 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
with Intel(R) Core(TM)2 Duo CPU P8700 @ 2.53GHz
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
@pedrodiamel this is most certainly the wrong way to inject a different version of v4l2loopback
into dkms. a better approach is to fetch a newer version of v4l2loopback-dkms
package, e.g.
wget http://deb.debian.org/debian/pool/main/v/v4l2loopback/v4l2loopback-dkms_0.12.4-1_all.deb
sudo dpkg -i v4l2loopback-dkms_0.12.4-1_all.deb
however, how does this fix the problem at hand?
if you want to say that the problem is "fixed in the current versions of the v4l2loopback
module", why don't you just say so?
should this be closed then? @jas-ts et al...?
I think I'm seeing the same problem here...
gphoto2 --stdout --capture-movie | ffmpeg -i - -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/video0
ffmpeg version 4.1.4-1build2 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 9 (Ubuntu 9.2.1-4ubuntu1)
configuration: --prefix=/usr --extra-version=1build2 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
libpostproc 55. 3.100 / 55. 3.100
Capturing preview frames as movie to 'stdout'. Press Ctrl-C to abort.
[mjpeg @ 0x5653f54d2ac0] Format mjpeg detected only with low score of 12, misdetection possible!
Input #0, mjpeg, from 'pipe:':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: mjpeg, yuvj422p(pc, bt470bg/unknown/unknown), 1056x704, 25 tbr, 1200k tbn, 25 tbc
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> rawvideo (native))
[swscaler @ 0x5653f5626a00] deprecated pixel format used, make sure you did set range correctly
[video4linux2,v4l2 @ 0x5653f54d87c0] ioctl(VIDIOC_G_FMT): Invalid argument
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Error initializing output stream 0:0 --
Conversion failed!
dpitt at p-thunk in ~ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 19.10
Release: 19.10
Codename: eoan
dpitt at p-thunk in ~ uname -a
Linux p-thunk 5.3.0-46-generic #38-Ubuntu SMP Fri Mar 27 17:37:05 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
And I built v4l2loopback from the 0.12.5 tag.
argh, no, I'm sorry—I had the wrong device. Disregard!
I am building this project from the master branch, and I have the same issue. What's going on here? Also, this happens
$ v4l2-ctl --list-formats
ioctl: VIDIOC_ENUM_FMT
Did some one have solution for this issue?
not a solution but I can recommend you akvcam ( https://github.com/webcamoid/akvcam) for virtual camera emulation.
On Thu, 30 Jul 2020, 13:07 IvanUAH, notifications@github.com wrote:
Did some one have solution for this issue?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/umlaeute/v4l2loopback/issues/247#issuecomment-666301322, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKFM2EXTBQAE5GBPA2FG3FLR6FH6LANCNFSM4JSBZDSA .
For those who are wondering what went wrong here. You might be using a wrong /dev/video* device
ls -l /dev/video*
crw-rw----+ 1 root video 81, 0 Aug 24 10:19 /dev/video0
crw-rw----+ 1 root video 81, 1 Aug 24 10:19 /dev/video1
crw-rw----+ 1 root video 81, 2 Aug 26 22:26 /dev/video2
Now update your command to use the other video devices and it will work. In my case, it worked with /dev/video2
gphoto2 --stdout --capture-movie | ffmpeg -i - -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/video2
@xB-2048's solution worked for me! Thanks!
@xB-2048 thanks a lot for the solution! Totally worked!
Solved for a specific case.
I had an existing v4l2loopback instance, OBS virtual Cam. Trying to modprobe another v4l2loopback device, an android IP cam stream, on top of an existing instance won't work (Duh!). (FFMpeg results in ioctl(VIDIOC_G_FMT)
Followed how-do-i-automatically-run-modprobe-v4l2loopback-on-boot Added both boot time devices to /etc/modprobe.d/v4l2loopback.conf
options v4l2loopback devices=2 video_nr=4,10 card_label="MiA3","OBS-Cam" exclusive_caps=1,1
Checking...
$v4l2-ctl --list-devices
MiA3" (platform:v4l2loopback-000):
/dev/video4
"OBS-Cam (platform:v4l2loopback-001):
/dev/video10
Runs...
ffmpeg -i http://192.168.2.2:8080/video -fflags nobuffer -vf format=yuv420p -r 30 -f v4l2 /dev/video4
without ioctl faults.
So basically https://stackoverflow.com/questions/62075776/running-two-v4l2loopback-devices-with-their-individual-properties
Trying to modprobe another v4l2loopback device,
ah well, this is not possible. having a module loaded in the kernel is a binary thing (very similar to being pregnant): either the module is loaded or it is not: you cannot load more of the same module (or another instance of it).
EDIT: this also means, that you cannot just add new module parameters once the module is loaded. you have to unload the module first, before you can reload it (and in order to unload it, no user-space application must be using the module; so all applications have to be quit first)
this is a fundamental difference to user-space applications (and not an issue of v4l2loopback
itself)
@umlaeute Thanks. And yes, "Duh!" means "obviously" and "no shit sherlock". No, it's got nothing to do with v4l2loopback. Lesson here was, don't just copy/paste scripts without checking you already have the module loaded for another device.
I also ran into this issue (on Ubuntu 20.10). Turns out I my output device was already in use for another camera. Pointing to an unused output device worked smoothly. Run v4l2-ctl --list-device
to get an overview of the active devices.
Not sure if this solves the problem of the OP but it might help others searching for a solution.
For me the commands:
modprobe v4l2loopback
ffmpeg -f x11grab -r 15 -s 1280x720 -i :0.0+0,0 -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/video1
are not working on Fish.
They're working fine on bash, however.
For those who are wondering what went wrong here. You might be using a wrong /dev/video* device
ls -l /dev/video* crw-rw----+ 1 root video 81, 0 Aug 24 10:19 /dev/video0 crw-rw----+ 1 root video 81, 1 Aug 24 10:19 /dev/video1 crw-rw----+ 1 root video 81, 2 Aug 26 22:26 /dev/video2
...
Worked for me as well.. thank you so much!
given there's no activity from the OP and everybody else here seems to be happy with the proposed solution, i think i can close this.
I'm keep running into this
When I boot my PC, then it works fine, this is my iter, I connect my Canon camera, turn it on and:
elect@5800x:~$ ps aux | grep gphoto
elect 7954 0.0 0.0 253336 16420 ? Ssl set07 0:00 /usr/libexec/gvfs-gphoto2-volume-monitor
elect 84406 0.3 0.0 511784 13592 ? Sl 11:09 0:00 /usr/libexec/gvfsd-gphoto2 --spawner :1.3 /org/gtk/gvfs/exec_spaw/4
elect 84449 0.0 0.0 9500 2524 pts/1 S+ 11:09 0:00 grep --color=auto gphoto
and I kill the first two process, and then simply:
elect@5800x:~$ sudo kill 7954
[sudo] password for elect:
elect@5800x:~$ sudo kill 84406
elect@5800x:~$ sudo modprobe v4l2loopback exclusive_caps=1 max_buffers=2
elect@5800x:~$ gphoto2 --stdout --capture-movie | ffmpeg -i - -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/video0
But the next time I want to use my Canon again, then I have to reboot, otherwise I'll get
[video4linux2,v4l2 @ 0x560d95322e80] ioctl(VIDIOC_G_FMT): Invalid argument
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Error initializing output stream 0:0 --
Conversion failed!
@elect86 I have the same issue, I'm using video0 and it works fine the first time and after I finish the gphoto2 process, the issue is the following:
[mjpeg_cuvid @ 0x55cec046ab40] ignoring invalid SAR: 0/0 [video4linux2,v4l2 @ 0x55cec046b300] ioctl(VIDIOC_G_FMT): Invalid argument Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument Error initializing output stream 0:0 --
Same issue
seems only a one time use now for some reason, but the problem is likely more on the v4l2loopback device side, not gphoto2 :(
Any idea how we might investigate further or trying to solve it?
same issue here - can this be reopened?
worked smoothly on Ubuntu 20.04 LTS - since upgrading to 21.10 and kernal 5.15.23-76051523-generic it only works once following reboot..
gphoto2 --stdout --capture-movie | ffmpeg -i - -vcodec rawvideo -pix_fmt yuv420p -f v4l2 /dev/video0
[video4linux2,v4l2 @ 0x5635c5ca4080] ioctl(VIDIOC_G_FMT): Invalid argument
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Error initializing output stream 0:0 --
Conversion failed!
found this thread after posting on ubuntu answers:
Same issue as above - works once per boot...
Small fix to avoid reboot:
sudo modprobe -r v4l2loopback
sudo modprobe v4l2loopback exclusive_caps=1 max_buffers=2
Then rerun your ffmpeg stream.
I am now facing this issue after I've upgraded my Ubuntu 20.04.5 kernel from 5.11.0-37-generic
to 5.15.0-58-generic
. It's happening to me when I stop a ffmpeg process that writes to a v4l2loopback device and start it again.
On the previous version of the kernel - 5.11.0-37-generic
it was working smoothly.
This is pretty much the command I am using in order to write to a v4l2loopback device:
ffmpeg -r 25 -rtsp_transport tcp -i rtsp://192.168.2.15:1935/live/foo -pix_fmt yuyv422 -f v4l2 /dev/video0
This is the error I am getting:
[video4linux2,v4l2 @ 0x55e50c309d80] ioctl(VIDIOC_G_FMT): Invalid argument
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Error initializing output stream 0:0 --
I'm also using the latest v4l2loopback release - 0.12.7
In my case, I can't really perform sudo modprobe -r v4l2loopback
every time after I stop my "writer" ffmpeg because other "reader" ffmpeg processes in my system are reading from the device in parallel.
It looks like an issue in v4l2loopback. Maybe it's something that can be fixed in the next release?
For anyone with the same issue, do check if the video device is already occupied. My camera created video4 out of the blue and broke my whole setup.
According to the info mentioned here
First unload the module with rmmod
sudo rmmod v4l2loopback
Then load it again using
sudo modprobe v4l2loopback video_nr=5 card_label="cam corder" exclusive_caps=1
This creates a virtual output device /dev/video5
and it has the name"cam corder"
as label on it
Use it according to your needs
ffmpeg -stream_loop 10 -re -i cam.mp4 -f v4l2 -vcodec rawvideo -pix_fmt yuv420p /dev/video5
now in this use case , open the camera/webcam and you should see the video playing in loop
Replace
cam.mp4
with any video Replace10
with preferred loop count/dev/video5
is the output device
Same issue as above - works once per boot...
Small fix to avoid reboot:
sudo modprobe -r v4l2loopback sudo modprobe v4l2loopback exclusive_caps=1 max_buffers=2
Then rerun your ffmpeg stream.
you are my hero !
in my case, guvcview was holding it hostage by being in a sleep state. had to kill those processes first
I have same issue in Ubuntu 20.04.6 LTS
and kernel 5.4.0-200-generic
.
Also i use v4l2loopback v0.12.5.
Is there any solution other than just unload/load module or reboot the system?
i am trying to convert landscape mode to portrait mode for my usb camera on ubuntu 18.04, i have kernal version 5.0.0-39- , i am getting above error whenever i run
can anybody help what i am doing wrong here