Video Capture Device (v4l2) plugin

thobl

New Member
Hi! My device does not work but in "Qt V4L2 Test Utility" (and other programs) it works, so I hope this is the right thread (although the initial comment from leonhard was some years ago).

My device is a Victure AC800 (an action cam). In other application like Zoom it just works out of the box. When I add it as device in OBS, the device dialog lags heavily and I don't get a picture. I did a little bit of debugging and here is what I believe is happening: With pixel format MJPG and 720p resolution, the camera works and I successfully get a preview in the Qt V4L2 Test Utility. However, when trying to run it with higher resolution or with pixel format YUYV, the camera just crashes. The only way to get it running again is restarting it. This seems to be an issue with the camera and not with OBS.
Now the problem is: I cannot add the camera to OBS, without OBS trying to show me a preview with some default settings for the camera, which appears to be with pixel format YUYV. This then crashes the camera and I can't change the settings to anything that would work. If my interpretation is correct, then it would already help me, if I could deactivate the preview in the "add video source"-dialog. Or if I could set the pixel format in some configuration file. Is that possible?

OBS log: https://obsproject.com/logs/mUBK2yDdq4bcjAJo

Code:
$ v4l2-ctl --list-formats
ioctl: VIDIOC_ENUM_FMT
    Type: Video Capture

    [0]: 'YUYV' (YUYV 4:2:2)
    [1]: 'MJPG' (Motion-JPEG, compressed)
    [2]: 'H264' (H.264, compressed)
 

thobl

New Member
Hi! My device does not work but in "Qt V4L2 Test Utility" (and other programs) it works, so I hope this is the right thread (although the initial comment from leonhard was some years ago).

My device is a Victure AC800 (an action cam). In other application like Zoom it just works out of the box. When I add it as device in OBS, the device dialog lags heavily and I don't get a picture. I did a little bit of debugging and here is what I believe is happening: With pixel format MJPG and 720p resolution, the camera works and I successfully get a preview in the Qt V4L2 Test Utility. However, when trying to run it with higher resolution or with pixel format YUYV, the camera just crashes. The only way to get it running again is restarting it. This seems to be an issue with the camera and not with OBS.
Now the problem is: I cannot add the camera to OBS, without OBS trying to show me a preview with some default settings for the camera, which appears to be with pixel format YUYV. This then crashes the camera and I can't change the settings to anything that would work. If my interpretation is correct, then it would already help me, if I could deactivate the preview in the "add video source"-dialog. Or if I could set the pixel format in some configuration file. Is that possible?

OBS log: https://obsproject.com/logs/mUBK2yDdq4bcjAJo

Code:
$ v4l2-ctl --list-formats
ioctl: VIDIOC_ENUM_FMT
    Type: Video Capture

    [0]: 'YUYV' (YUYV 4:2:2)
    [1]: 'MJPG' (Motion-JPEG, compressed)
    [2]: 'H264' (H.264, compressed)

I found out how (and to what value) to change the pixel format in the configuration file. In ~/.config/obs-studio/basic/scenes/<scene-name>.json, one has to change the line with "pixelformat" from 1448695129 (which represents YUYV) to one of 861030210 (for BGR3), 842093913 (for YU12), or 842094169 (for YV12). With this, the Victure AC800 now works in OBS :-).
 

mxa

New Member
It says no space left on device.

Usually "no space left on device" means the USB bandwidth is exceeded for this USB bus. This might happen because the devices allocate more bandwidth then they actually need, so multiple cameras on the same bus actually would work but since their allocation is too greedy the sum of the allocations exceeds the total bandwidth.
 

ethaniel

Member
Hello!

I have a USB HDMI Encoder card. After some time it freezes up, so I have to deauthorize/authorize it again. This leads to recreation of the /dev/video0 entry and I also reset the video source in OBS. However, it's not enough and I have to restart OBS completely to get it to work.

Before restarting OBS:
07:40:39 AM.886: v4l2-input: Start capture from /dev/video0
07:40:39 AM.886: v4l2-input: Unable to open device
07:40:39 AM.886: v4l2-input: Initialization failed

After restarting OBS:
07:43:14 AM.497: v4l2-input: Start capture from /dev/video0
07:43:14 AM.498: v4l2-input: Input: 0
07:43:14 AM.523: v4l2-input: Resolution: 1920x1080
07:43:14 AM.523: v4l2-input: Pixelformat: 3RGB
07:43:14 AM.523: v4l2-input: Linesize: 5760 Bytes
07:43:14 AM.546: v4l2-input: Framerate: 30.00 fps

Any ideas?
 

ethaniel

Member
I have a USB HDMI Encoder card. After some time it freezes up, so I have to deauthorize/authorize it again. This leads to recreation of the /dev/video0 entry and I also reset the video source in OBS. However, it's not enough and I have to restart OBS completely to get it to work.

I ended up switch to the gstreamer plugin with a virtual v4l2 loopback device which gave me more freedom in handling errors.
 

Peter N

New Member
Having found this thread, I'll repeat the problem I raised last week under the title "Zoom sees v42lsink virtual webcam but doesn't display video". (Beginner's question: Is it possible to delete my earlier message? I don't see any mechanism for this.)

The background is that owing to restricted supplies of webcams in the UK when I first needed to connect to Zoom, I set up a system in which video output from a PiCamera on a Raspberry Pi 4B was sent by a Python script over SSH to my main PC running PCLinuxOS and displayed in a Firefox browser window. OBS-Studio picked this up in its "Window Capture" mode, and my intention was to use V4L2sink to generate a virtual webcam for input to Zoom.

I've set up v4l2loopback as root with OBS-Studio and obs-v4l2sink (both at version 25.0.8-4) with the command

modprobe v4l2loopback devices=1 label="OBSoutput" exclusive_caps=1

The 'Path to V4L2 Device' in Tools is shown as "/dev/video0" and its mode is RGB. However, while Zoom sees a webcam which it identifies as "Dummy video device (0x0000)" the Zoom screen is totally black. I've tested the output from OBS-Studio in Qt V4L2 video capture utility, and the video is clearly there. It feels a bit 'so near and yet so far' so if anybody can help a relative beginner to work out what needs to be done, I would be very grateful
 

Sensi_claudio

New Member
I have a MyGica Video Capture in Kubuntu 20.04 i would register only 720x480 and not 720x 576 :

Screenshot_20200706_220138a.jpg


Screenshot_20200706_220233a.jpg


how can I do ?

In Windows 10 it's ok
 

Valentina sfs

New Member
¡Hola! Acabo de instalar v4l2 en obs para usar la cámara virtual para hacer zoom, el zoom reconoce la cámara pero se ve negra :(, prueba vlc y se ve perfecta pero en el zoom es solo negro! Alguien que me pueda ayudar por favor :(
 

Leonpm

New Member
Hi, I'm new to the forum, this November 6, v4l2loopback was updated and I can no longer transmit webcam with obs, in obs it works but when you enter zoom or Google meet the option of Obs webcam does not appear, does anyone know something?
Reinstall the whole system and it still does not work when entering such video calling platforms.
my system information
Ubuntu studio 20.04
Obs 26.0.2
V4l2loopback-dkms 0.12.3-1 ubuntu0.1
 

Leonpm

New Member
¡Hola! Acabo de instalar v4l2 en obs para usar la cámara virtual para hacer zoom, el zoom reconoce la cámara pero se ve negra :(, prueba vlc y se ve perfecta pero en el zoom es solo negro! Alguien que me pueda ayudar por favor :(

Te comparto un pequeño manual que diseñe es una recopilación para hacer funcionar el v4l2, solo que actualmente no lo detectan las plataformas ya que este 6 de noviembre se actualizo y algo pasó estoy investigando pero no encuentro información al respecto.

Proceso de instalación de V4L2.(abres un terminal y ejecutas linea por linea).
sudo apt install v4l2loopback-dkms
sudo modprobe v4l2loopback devices=1 video_nr=10 card_label="OBS Cam"
sudo apt install qtbase5-dev
git clone --recursive https://github.com/obsproject/obs-studio.git
git clone https://github.com/CatxFish/obs-v4l2sink.git
cd obs-v4l2sink
mkdir build && cd build
cmake -DLIBOBS_INCLUDE_DIR="../../obs-studio/libobs" -DCMAKE_INSTALL_PREFIX=/usr ..
make -j4
sudo make install

Abres Obs y configuras en ->Herramientas -> v4l2 video output -> /dev/video10
YUV420 y presionas Start
Debería aparecer en las opciones de cámara de la plataformas que uses para video llamada
si al presionar start marca error cierra todo y abres un terminal y ejecutas la siguiente línea actualmente ya no es necesario usarla
pero antes de la actualización si solía usarla.
sudo modprobe v4l2loopback video_nr=10 card_label="OBS Video Source" exclusive_caps=1

Si alguna línea te arroja error checa que te pide y lo solucionas con estas siguientes línea en otro terminal y continuas con la instalación.
1.- Instalar previamente para evitar errores o falta de dependencias: git
sudo apt-get install git
2.- cmake
sudo apt-get install cmake
3.- Qt5
sudo apt-get install qtbase5-dev
4.- libobs-dev
sudo apt-get install libobs-dev
5.- Esto evita el error LIBOBS no encontrado en el momento en que cmake está recopilando todas las dependencias: ffmpeg
sudo apt-get install ffmpeg
 

Mvube

New Member
Hi, I'm new to the forum, this November 6, v4l2loopback was updated and I can no longer transmit webcam with obs, in obs it works but when you enter zoom or Google meet the option of Obs webcam does not appear, does anyone know something?
Reinstall the whole system and it still does not work when entering such video calling platforms.
my system information
Ubuntu studio 20.04
Obs 26.0.2
V4l2loopback-dkms 0.12.3-1 ubuntu0.1
I have the same problem! I did a reinstall and got OBS working on Skype (720p) and VLC but cannot get working on Zoom or Messenger. I need it for Zoom urgently. All was well in my last conference on 1 November 2020 but since the 7th all has been lost.
Ubuntu 20.04
OBS 26.0.2-modified (linux)
Zoom 5.4.2 (53391.1108)
obs-v4l2sink 0.1.0
V4l2loopback-dkms 0.12.5-1
 

vicissitude

New Member
Issues:
1/ Frame rate settings allow me only 20fps for Aukey PC-W1 although the webcam is capable of 60fps
2/ Camera preview is delayed at anything higher than 848x480 (I can see my eyes blinking)
CPU usage 10%
OBS 26.0.2. Ubuntu
Thanks for any help.

v4l2-ctl --list-formats
ioctl: VIDIOC_ENUM_FMT
Type: Video Capture
 
Last edited:

AlpineSkate

New Member
For those who are trying to set a fixed device for each time the machine reboots and the USB ordering gets randomised; I found a way to force it;

Edit the json file in your scenes folder (in my case, Untitled.json) and where you see /dev/video0 (1, 2, 3 etc) replace it with the /dev/v4l/by-id/ name path instead, eg;

"name": "Facecam",
"private_settings": {},
"push-to-mute": false,
"push-to-mute-delay": 0,
"push-to-talk": false,
"push-to-talk-delay": 0,
"settings": {
"device_id": "/dev/v4l/by-id/usb-046d_C922_Pro_Stream_Webcam_424D78DF-video-index0",
"framerate": 65566,
"input": 0,
"pixelformat": 842094169,
"resolution": 125830200
},


A 'fix' for this would be for OBS to let us pick the device source from paths other than /dev/video* ?
Even with the current latest version, the hack you describe is still necessary. Anyhow, I'm hopeful it will get fixed in the next release - https://github.com/obsproject/obs-studio/issues/3003
 

ykpur

New Member
Hi, I created a virtual device using v4l2loopback in linux ubuntu and I'm using obs and this v4l2 plugin to stream an image or video to the /dev/video2 that v4l2loopback created. Now everything works so far, but I have issues with the resolution. The image I'm sending is in 1920x1080, the base canvas is in 1920x1080 and the output of obs is in 1920x1080 aswell. The image that can be seen under /dev/video2 e.g. using ffplay is only in 320x240
(if I understand this output of ffplay correctly:
Input #0, video4linux2,v4l2, from '/dev/video2':B sq= 0B f=0/0
Duration: N/A, start: 1650.347834, bitrate: 27648 kb/s
Stream #0:0: Video: rawvideo (NV12 / 0x3231564E), nv12, 320x240, 27648 kb/s, 30 fps, 30 tbr, 1000k tbn, 1000k tbc
)

I'm starting the v4l2loopback using this command:
sudo modprobe v4l2loopback exclusive_caps=1 video_nr=$videoNumber card_label="virtualCam"
and then this to set the format to NV12:
v4l2loopback-ctl set-caps "video/x-raw, format=NV12, width=1920, height=1080" "/dev/video2"

Then in the obs plugin I choose NV12 aswell.

Using Gstreamer instead of obs I did not have this issue (instead I got other issues with the android emulator...).

How can I fix this issue? Any help is very welcomed!
 

JohnDee

New Member
Previously, I could select which v4l2loopback device to output to. After updating to OBS 26, with the new "Start Virtual Camera", I can only output to the first v4l2loopback device. Is there a setting somewhere? How can I select the output path of the virtual camera?

Details:
I'm using a Canon DSLR to USB3 via g2photo & v4l2loopback. This is itself a v4l2loopback device. When I run "v4l2-ctl --list-devices", it lists two devices. I then use g2photo to send a stream from the camera to /dev/video0 . For OBS to detect the camera, it has to be running into a loopback device BEFORE OBS starts. The issue is that since I can't select where to send OBS virtual camera output path, it is overwriting the camera with the output. This is how I output OBS into something like Zoom. It was working fine with OBS 25.
 

frisco

New Member
Previously, I could select which v4l2loopback device to output to. After updating to OBS 26, with the new "Start Virtual Camera", I can only output to the first v4l2loopback device. Is there a setting somewhere? How can I select the output path of the virtual camera?

It still works for me. I can go to Tools->V4L2 Video Output, stop the output, change the path, and re-start with a different path. I tested switching between `/dev/video0` and `/dev/video1`. That said, when I switch to `/dev/video1` I still see a still image when I peek at `/dev/video0`, which is strange, but the live video feed is definitely going to `/dev/video1`. Can you maybe elaborate on what you are doing to experience the problem?
 
Top