Using v4l2loopback virtual cam with google-chrome or chromium on linux while having real webcam in use

0 votes

(I hope posting an answer to own question is not against TOS here, I made it because I discovered the solution while writing this post, and extensive googling didn't help, so I hope I can help some people looking for solution.)

Problem: Google chrome / chromium doesn't open v4l2loopback virtual camera device (won't access it) and report "No camera available", even if it is listed and selected in settings page sometimes.

Observed cause of problem: (noticed when using OBS Cam Studio) Google chrome / chromium WILL NOT access (open) virtual camera device if it finds real camera device being in use (busy).

Solution (short version):

  • find out which device your physical webcam is (it may be multiple devices) if your camera is pluggable you can disconnect it, then observe the result of ls /dev/video*, connect it, and try ls /dev/video* again to see which devices appeared (in my case it's /dev/video0 and /dev/video1) - in most cases it will be /dev/video0
  • start your capturing program (the one that uses physical webcam and outputs to virtual camera) and make it output to virtual camera (virtual camera has to be fed with input to be opened by chrome)
  • disable access to physical webcam, which (in my case) can be done with:
sudo chmod 000 /dev/video0
sudo chmod 000 /dev/video1

(use the device names that you discovered your physical webcam is)

  • start the video capture in google chrome/chromium (by opening the webpage or pressing some sort of "Start webcam", it depends on the webpage)
  • you should see virtual camera feed in chrome now
  • enable access to physical webcam back, done (in my case) with:
sudo chmod 660 /dev/video0
sudo chmod 660 /dev/video1
  • and done! have fun camming on the web!

Solution (long version): Description, step by step, how to make OBS Cam Studio virtual output be visible in google chrome/chromium.

  • if you didn't do it yet, unload v4l2loopback module (do it if you weren't aware of "exclusive_caps" parameter):
sudo modprobe -r v4l2loopback

(you need to stop any virual camera feed and stop application that uses virtual cam, otherwise you will get modprobe: FATAL: Module v4l2loopback is in use. error)

  • load v4l2loopback module (only "exclusive_caps" parameter matters):
sudo modprobe v4l2loopback devices=1 video_nr=21 exclusive_caps=1 card_label="Virtual Webcam"

(this command will create one loopback device with name /dev/video21 and name (caption) "Virtual Webcam") simpler version of the command, that really matters:

sudo modprobe v4l2loopback exclusive_caps=1
  • start video capture program that uses your physical webcam and outputs to virtual webcam device (in my case it's OBS Cam Studio) - physical webcam should be busy (in use) now and virtual webcam should be fed input (important)
  • disable physical webcam devices access by (in my case):
sudo chmod 000 /dev/video0
sudo chmod 000 /dev/video1

(device names may be different in your case and there may be just one of them) (if you have no sudo access and your camera is pluggable you can just unplug it)

  • start using webcam with google chrome or chromium (enter the web page and open the webcam on it, for example by button "Use my webcam" on the web page - it is different from page to page)
  • you should see the virtual webcam feed now (if not, click the camera icon on the right of address bar, click "Manage" and select your virtual webcam by name in settings, make web page use webcam again)
  • enable physical webcam devices access back by (in my case):
sudo chmod 660 /dev/video0
sudo chmod 660 /dev/video1

(in case you unplugged the webcam plug it back and (possibly) reopen it in your program)

  • enjoy virtual webcam in chrome!

I hope it helps as I struggled for a long time with no effect to make google chrome open virtual webcam in OBS Cam Studio.

Edited: Found working solution that is based on similar principle, it's here: https://www.scs.stanford.edu/~dm/blog/hide-webcam.html It hides physical webcam from the list of visible webcams, so you need to enter the path to it manually or in the config settings of the program.

Apr 21, 2022 in Linux Administration by Edureka
• 13,690 points
2,226 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Linux Administration

0 votes
1 answer

generating a list of files with their absolute path in Linux

If you find an absolute path to start with, ...READ MORE

answered May 16, 2019 in Linux Administration by Upasana
• 8,620 points
1,376 views
0 votes
1 answer

How to find the group associated with a user in linux?

To list all the groups groups or to list ...READ MORE

answered Jun 21, 2019 in Linux Administration by DareDev
• 6,890 points
939 views
0 votes
1 answer

To attach a file using mail command on Linux

$ echo | mutt -a syslogs.tar.gz admin@domain.org READ MORE

answered Jun 28, 2019 in Linux Administration by Upasana
• 8,620 points
2,843 views
0 votes
0 answers

Error while opening Edureka VM on virtual box

Hi Team, I am using windows 10 machine ...READ MORE

Sep 24, 2019 in Linux Administration by Kiran
• 120 points
899 views
0 votes
1 answer

Dynamic real-time view of the running system in Linux.

Hi@akhtar, The top command is used to show the ...READ MORE

answered Oct 12, 2020 in Linux Administration by MD
• 95,460 points
2,182 views
0 votes
1 answer

How to create nested directories with a single command in linux?

Try this command. mkdir -p /parent_dir/son_dir READ MORE

answered Oct 19, 2020 in Linux Administration by anonymous
• 19,610 points
2,193 views
0 votes
1 answer

Select unique lines along with their count in Linux.

Hi@akhtar, You can find the unique entries from ...READ MORE

answered Oct 20, 2020 in Linux Administration by MD
• 95,460 points
624 views
0 votes
1 answer

How to create directory of current username in ruby on Linux server

Hi, The command whoami is used to know ...READ MORE

answered Nov 25, 2020 in Linux Administration by MD
• 95,460 points
786 views
0 votes
0 answers

How do I copy folder with files to another folder in Unix/Linux?

I am having some issues copying a ...READ MORE

Apr 13, 2022 in Linux Administration by Soham
• 9,710 points
379 views
0 votes
0 answers

How to compile for Windows on Linux with gcc/g++?

I have written some effects in C++ ...READ MORE

Apr 13, 2022 in Linux Administration by Rahul
• 9,680 points
766 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP