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

OBS v4l2 plugin can't see the loopback camera device #105

Closed
ali1234 opened this issue Aug 28, 2021 · 10 comments
Closed

OBS v4l2 plugin can't see the loopback camera device #105

ali1234 opened this issue Aug 28, 2021 · 10 comments
Labels
documentation Improvements or additions to documentation wontfix This will not be worked on
Milestone

Comments

@ali1234
Copy link

ali1234 commented Aug 28, 2021

When selecting a v4l2 input device, only my real cameras are listed.

This is not a permissions problem - that would also prevent the gstreamer plugin from working. The virtual camera also has no problems working with mpv or web browsers, skype etc.

This can be worked around within OBS by using the gstreamer plugin instead of v4l2. Then use a pipeline like this:

v4l2src device=/dev/video10 ! video.

I realise you probably can't fix this but I think it would be helpful to add the workaround to the documentation.

@phlash
Copy link
Collaborator

phlash commented Aug 29, 2021

Thanks! Looks like this is a result of how the OBS v4l2 plugin finds inputs:
https://github.com/obsproject/obs-studio/blob/7ae6f328a1784954b96abcb8d4247207251192df/plugins/linux-v4l2/v4l2-input.c#L337
[edit to correct poor assumption!]
in particular it enumerates /sys/class/video4linux which only contains physical devices. Worth reporting as a bug to OBS?
/sys/class/video4linux contains my virtual devices (once I have loaded the v4l2loopback module! Not sure why OBS doesn't offer these as inputs.. testing

In case you haven't found it, I have an experimental OBS plugin that uses backscrub, it works for me..
https://github.com/phlash/obs-backscrub

@phlash phlash added documentation Improvements or additions to documentation wontfix This will not be worked on labels Aug 29, 2021
@floe floe added this to the v0.3 milestone Aug 29, 2021
@phlash
Copy link
Collaborator

phlash commented Aug 29, 2021

So, I've tried this myself, and OBS only lists inputs with a valid video stream at the time it is started. If I have backscrub running, then I can select my virtual camera and it all just works. If I don't have backscrub running, then I only get the option of physical camera.

@phlash phlash closed this as completed Aug 29, 2021
@ali1234
Copy link
Author

ali1234 commented Aug 29, 2021

I tried starting backscrub before OBS and it did not make any difference. It is still not listed in the list of inputs. I am using 27.0.1.

@phlash
Copy link
Collaborator

phlash commented Aug 29, 2021

OK, reopening this as something is different ❓

@phlash phlash reopened this Aug 29, 2021
@phlash
Copy link
Collaborator

phlash commented Aug 29, 2021

Righto - I'm running OBS 26.1.2 (stock Debian 11 / stable), here's what I have configured and see:

  • v4l2 configuration:
 (/etc/modules-load.d/v4l2loopback)
v4l2loopback
(/etc/modprobe.d/v4l2loopback-options)
options v4l2loopback video_nr=10,11 exclusive_caps=1 card_label="Virtual Camera,Test Loopback"

this gives me four devices at boot, two from my camera (/dev/video0, /dev/video1) and two virtual (/dev/video10, /dev/video11)

  • the following sym-links appear in /sys/class/video4linux:
rwxrwxrwx 1 root root 0 Aug 29 18:43 video0 -> ../../devices/pci0000:00/0000:00:14.0/usb1/1-6/1-6:1.0/video4linux/video0
lrwxrwxrwx 1 root root 0 Aug 29 18:43 video1 -> ../../devices/pci0000:00/0000:00:14.0/usb1/1-6/1-6:1.0/video4linux/video1
lrwxrwxrwx 1 root root 0 Aug 29 18:43 video10 -> ../../devices/virtual/video4linux/video10
lrwxrwxrwx 1 root root 0 Aug 29 18:43 video11 -> ../../devices/virtual/video4linux/video11
  • I start backscrub as follows, input from first camera device, output to first virtual device:
% backscrub -c /dev/video0 -v /dev/video10
  • Running OBS from a terminal (so I can see the logs):
% obs
...(add a V4L2 source)
info: v4l2-input: Start capture from 
error: v4l2-input: Unable to open device
error: v4l2-input: Initialization failed
info: User added source 'Video Capture Device (V4L2)' (v4l2_input) to scene 'Scene'
info: v4l2-input: /dev/video1 seems to not support video capture
libv4l2: error getting pixformat: Invalid argument
info: v4l2-input: Unable to open /dev/video11
info: v4l2-input: Found device 'Integrated Camera: Integrated C' at /dev/video0
info: v4l2-input: Found device 'Virtual Camera' at /dev/video10
info: v4l2-input: Found input 'Camera 1' (Index 0)
info: v4l2-controls: setting default for Power Line Frequency to 1
info: v4l2-controls: setting default for Exposure, Auto to 3
info: v4l2-input: Pixelformat: Motion-JPEG (unavailable)
info: v4l2-input: Pixelformat: YUYV 4:2:2 (available)
info: v4l2-input: Pixelformat: RGB3 (Emulated) (unavailable)
info: v4l2-input: Pixelformat: BGR3 (Emulated) (available)
info: v4l2-input: Pixelformat: YU12 (Emulated) (available)
info: v4l2-input: Pixelformat: YV12 (Emulated) (available)
info: v4l2-input: Stepwise and Continuous framesizes are currently hardcoded
info: v4l2-input: Stepwise and Continuous framerates are currently hardcoded
info: v4l2-input: Pixelformat: Motion-JPEG (unavailable)
info: v4l2-input: Pixelformat: YUYV 4:2:2 (available)
info: v4l2-input: Pixelformat: RGB3 (Emulated) (unavailable)
info: v4l2-input: Pixelformat: BGR3 (Emulated) (available)
info: v4l2-input: Pixelformat: YU12 (Emulated) (available)
info: v4l2-input: Pixelformat: YV12 (Emulated) (available)
info: v4l2-input: Stepwise and Continuous framesizes are currently hardcoded
info: v4l2-input: Stepwise and Continuous framerates are currently hardcoded
info: v4l2-input: Stepwise and Continuous framerates are currently hardcoded
info: v4l2-input: Start capture from /dev/video0
error: v4l2-input: Unable to set input 0
error: v4l2-input: Initialization failed
info: v4l2-input: Found input 'loopback' (Index 0)
info: v4l2-input: Pixelformat: YUYV 4:2:2 (available)
info: v4l2-input: Pixelformat: RGB3 (Emulated) (unavailable)
info: v4l2-input: Pixelformat: BGR3 (Emulated) (available)
info: v4l2-input: Pixelformat: YU12 (Emulated) (available)
info: v4l2-input: Pixelformat: YV12 (Emulated) (available)
info: v4l2-input: Stepwise and Continuous framerates are currently hardcoded
info: v4l2-input: Start capture from /dev/video10
info: v4l2-input: Input: 0
info: v4l2-input: Resolution: 640x480
info: v4l2-input: Pixelformat: YUYV
info: v4l2-input: Linesize: 1280 Bytes
info: v4l2-input: Framerate: 30.00 fps

..which seems to indicate that it cannot open /dev/video1 (some weird alias for my camera) nor /dev/video11 as there is no source feeding it. I can select (see screenshots below) either /dev/video0 or /dev/video10.

  • adding a 'Chroma Key' filter then converts the green screen from backscrub into an alpha channel to blend my video over whatever other sources are feeding OBS.

Screenshot from 2021-08-29 21-25-56
Screenshot from 2021-08-29 21-26-37
Screenshot from 2021-08-29 21-27-16

@phlash
Copy link
Collaborator

phlash commented Sep 10, 2021

Test repeated using OBS Studio 27.0.1-dfsg1-1 (from Debian bookworm / testing), and everything still works as above.

@ali1234
Copy link
Author

ali1234 commented Sep 10, 2021

This is likely to be caused by the snap container then.

@phlash
Copy link
Collaborator

phlash commented Sep 11, 2021

I think so, thanks for raising the issue with snapcrafters, are we ok to close this here (possibly with a note in the docs and link to this ticket?)

@BenBE
Copy link
Collaborator

BenBE commented Sep 11, 2021

@phlash Once somebody™ added the note in the docs I'm fine with closing this.

@phlash phlash closed this as completed Sep 11, 2021
@phlash
Copy link
Collaborator

phlash commented Sep 11, 2021

docs updated in README.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

4 participants