17

I have 1 webcam connected to my computer but I want to use it in multiple programs.
The problem is when I launch a second program, it tells me the webcam is already used.

The programs which will use the webcam are : motion, pam_face_authentification, and some communication software like skype, google hangout ...

How can I duplicate the flow of my webcam to simulate a second webcam?

  • I do not understand what you are telling me ? – user244552 Feb 5 '14 at 17:28
  • stream to a file, and to the display. you could do this with vlc, possibly cheese. once you have a stream, anything could use it. – j0h Feb 5 '14 at 23:02
  • Why not do it on OS start? Through "Startup Applications". – Gtx Feb 7 '14 at 10:05
9

My first thoughts were, I wonder if anyone has come up with a way to have a video appear as a webcam (e.g. I'm skyping with someone, but the video and audio they see is some video I chose instead). After searching around a bit, it looks like people have done this video piping (as discussed on Manipulating Dev Video and Fake a webcam using a video loopback device?

As mentioned in your comment, gst-launch v4l2src device=/dev/video0 ! v4l2sink device=/dev/video1 allows you to duplicate video0 to video1, and video1 is readable by some software.

In order to have this run when your computer starts, you can follow the UbuntuBootupHowto to come up with something like:

# /etc/init/videocloner.conf
description "VideoCloner"
start on runlevel [2345]
stop on runlevel [06]
respawn
exec gst-launch v4l2src device=/dev/video0 ! v4l2sink device=/dev/video1

This script should start when the computer boots and also allows you to run sudo service videocloner start|stop (Note: if my example script doesn't work, try moving gst-launch v4l2src device=/dev/video0 ! v4l2sink device=/dev/video1 into a shell script, and changing the exec line to call your shell script instead).

| improve this answer | |
  • 1
    I want to add something to Dolan's answer. You also need to install the v4l2loopback-dkms package and run the v4l2loopback module: sudo apt-get install v4l2loopback-dkms and then sudo modprobe v4l2loopback – Tarek Loubani May 11 '14 at 22:44
  • I have tried this, but the result is I have a usable /dev/video1, but an unsusable /dev/video0, so it doesn't allow me to have two programs use the same physical webcam. I tried modifying the command to create /dev/vidoe1 and /dev/video2 so I have 2 endpoints, but no luck. – unfa Jan 1 '18 at 21:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.