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.

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

  1. jeremie says:

    Hi,

    It’s working for me, after unmounting the DSLR.

    The image quality is way much better, but at like 10FPS.

    VLC, for the codec information, report 30FPS.

    What could be the problem? I’m in Ubuntu 20.04.

    Regards,

    • batchloaf says:

      Hi Jeremie,

      I wouldn’t expect a very high frame rate using the camera this way over USB. I don’t think Canon really want you to live stream from this camera (maybe for commercial reasons – like they want you to buy a more expensive camera?). Anyway, what I described above is a bit of a hack to allow you to use the 70D (and probably similar models) as a USB webcam. It works, but the frame rate and latency probably won’t be very good. Depending on your application, it may or may not be adequate.

      For what it’s worth, I had a Canon 70D and a Canon 700D (aka Rebel t5i), but I couldn’t get either one to work to my satisfaction as a live streaming webcam, so I ended up buying a Panasonic Lumix GH5, which offers clean HDMI output at 1080p.

      Ted

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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