Using Canon EOS 70D DSLR as a USB web cam in Xubuntu Linux 19.04

For a while now, I’ve been interested in using my Canon EOS 70D DSLR as a USB camera so that I can record (and potentially live stream) better quality tutorial videos. The quality of video from the 70D is super and it has a USB connector, so I thought this should be possible. However, although I think Canon provides some kind of software utility to support this kind of thing in Windows and Mac OS, it wasn’t immediately obvious how to do it in Linux. Anyway, I spent a while digging around to figure it, but the solution which finally worked for me (shown below) is basically straight from this post.

One drawback to using the 70D this way is that it doesn’t seem to be possible to power it via the USB connector, so you either need to periodically recharge the battery or buy some kind of AC adapter that plugs into the battery compartment (I think devices like this are available, but I haven’t tried any of them).

The solution is basically:

  • Connect the Canon 70D to the laptop via USB cable.
  • Use gphoto2 to initiate video capture on the camera and receive the data in real time from USB and pipe it onwards via stdout.
  • The output of gphoto2 is piped into gstreamer which does some data format conversion
  • The output of gstreamer is sent to a V4L2 loopback device (e.g. /dev/video2), so that other applications can access it the same way as a normal USB cam.
  • I’ve been using OBS to capture videos from the 70D (including audio), which seems to work extremely well, but in principle any V4L2 compatible software should now be able to access the camera.

First, I had to install a couple of packages:

sudo apt-get install gphoto2 v4l2loopback-utils

Then, the v4l2loopback kernel module needs to be inserted, since that will be used to make the video stream appear as a camera device (e.g. /dev/video2).

sudo modprobe v4l2loopback

Edit (25-7-2019): For some reason, to make the loopback video capture device visible to the Chrome browser, I need to insert the v4l2loopback module with the following additional option specified:

modprobe v4l2loopback exclusive_caps=1

To begin streaming video data:

gphoto2 --stdout --capture-movie | gst-launch-1.0 fdsrc ! decodebin3 name=dec ! queue ! videoconvert ! v4l2sink device=/dev/video2

Incidentally, the following command can be used to capture a still image to a file on the laptop without storing it on the camera’s memory card):

gphoto2 --capture-image-and-download --no-keep
This entry was posted in Uncategorized and tagged , , , , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s