camera · photog · howto

$300 Webcam

Something I recently showcased on Facebook was my DSLR webcam setup. Since I purchased a DSLR and noticed I could set the time and control the camera from the gphoto2 command, I wondered if I could do more. Well now I know.

I have now turned my DSLR into a $300 webcam. Good news: it's significantly better than the one I dropped $20 at RadioShack. Bad news: probably a waste of time off.

Posted by Micah Nordland on Wednesday, February 3, 2016

I started messing around with it when I discovered that Darktable, the program I use to edit and develop my RAW images, had a tethering feature. It was very straight forward to connect my camera to the program and I soon had this setup working:

My selfie setup is more complicated than yours.

Posted by Micah Nordland on Tuesday, February 2, 2016

This, however, was not enough for me. I wanted to see if I could take the live view that worked in Darktable and get Skype and Google Hangouts to use it too. Fortunately, I was not (by far) the first person to think of trying this. On Windows (Sparkocam) and Mac (CamTwist) programs exist (for Free!) to make this possible, however on Linux it’s not as straight forward. But it does work excellently. The first thing to do is to make sure you have the v4l2loopback kernel module installed.

Debian and Ubuntu users should use:

sudo apt-get install v4l2loopback-dkms

Arch Linux users can install it from AUR:

yaourt v4l2loopback-dkms

I couldn’t find any package for Fedora, but any Linux distribution can install from source found at Just make sure you have your distribution’s development packages installed with the Linux kernel headers.

You also will need to have GStreamer, which I believe most distributions preinstall. Arch Linux users can get it by installing the gstreamer package.

Now that you have the dependencies just connect your camera to your computer and run the following command in a terminal:

gphoto2 --stdout --capture-movie | gst-launch-0.10 fdsrc ! decodebin2 name=dec ! queue ! ffmpegcolorspace ! xvimagesink

If this outputs an error, make sure your camera cable is connected on both ends and the camera is on with a full battery. If you still get an error then run

sudo modprobe v4l2loopback

to make sure the kernel module is loaded and then try again. You should see a screen like this showing the view from your camera:

Now we know that this will work for your camera.

Lastly, put the following into a file and put it somewhere handy. I suggest somewhere in your $PATH for ease of access.

sudo modprobe v4l2loopback
gphoto2 --stdout --capture-movie | gst-launch-0.10 fdsrc ! decodebin2 name=dec ! queue ! ffmpegcolorspace ! v4l2sink /dev/video1

The first command makes sure the kernel module is loaded and then starts the camera stream. It should now show up in Skype and Hangouts. Just be sure to run this script before starting the app that needs to use the video feed.

comments powered by Disqus