Using DSLR camera as a webcam
I am trying to use my Canon DSLR as a webcam, on an Ubuntu machine. The camera does not show up as /dev/video*
.
The camera shows up in hwinfo --usb
:
19: USB 00.0: 10f01 WebCam
[Created at usb.122]
Unique ID: R8DB._ROX1vreGqF
Parent ID: FKGF.4Nx_qoDfSd7
SysFS ID: /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.1/2-1.1:1.0
SysFS BusID: 2-1.1:1.0
Hardware Class: camera
Model: "Canon EOS 100D"
Hotplug: USB
Vendor: usb 0x04a9 "Canon"
Device: usb 0x3270 "EOS 100D"
Revision: "0.02"
Driver: "usbfs"
Driver Modules: "usbcore"
Speed: 480 Mbps
Module Alias: "usb:v04A9p3270d0002dc00dsc00dp00ic06isc01ip01in00"
Config Status: cfg=new, avail=yes, need=no, active=unknown
Attached to: #4 (Hub)
USB-related lsmod
shows this:
$ lsmod | grep usb
wusbcore 45056 0 # I activated this manually, shot in the dark
uwb 73728 1 wusbcore
snd_usb_audio 204800 4
snd_usbmidi_lib 32768 1 snd_usb_audio
snd_hwdep 20480 2 snd_usb_audio,snd_hda_codec
btusb 45056 0
btrtl 16384 1 btusb
btbcm 16384 1 btusb
btintel 16384 1 btusb
bluetooth 548864 46 btrtl,hidp,btintel,btbcm,bnep,btusb,rfcomm
snd_pcm 98304 5 snd_hda_codec_hdmi,snd_hda_intel,snd_usb_audio,snd_hda_codec,snd_hda_core
snd_rawmidi 32768 2 snd_seq_midi,snd_usbmidi_lib
snd 81920 34 snd_hda_codec_generic,snd_seq,snd_seq_device,snd_hda_codec_hdmi,snd_hwdep,snd_hda_intel,snd_usb_audio,snd_usbmidi_lib,snd_hda_codec,snd_hda_codec_realtek,snd_timer,snd_pcm,snd_rawmidi
usbhid 49152 0
hid 118784 3 hidp,usbhid,hid_generic
Here is the tail of dmesg
:
[ 530.523684] media: Linux media interface: v0.10
[ 530.530299] Linux video capture interface: v2.00
[ 530.540171] usbcore: registered new interface driver uvcvideo
[ 530.540172] USB Video Class driver (1.1.1)
[ 878.930024] usb 2-1.1: USB disconnect, device number 6
[ 973.616657] usb 2-1.1: new high-speed USB device number 7 using ehci-pci
[ 973.818855] usb 2-1.1: New USB device found, idVendor=04a9, idProduct=3270
[ 973.818859] usb 2-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 973.818861] usb 2-1.1: Product: Canon Digital Camera
[ 973.818862] usb 2-1.1: Manufacturer: Canon Inc.
Trying to find something about usbcore to modprobe
:
$ ls -R /lib/modules/$(uname -r)/kernel | grep usbcor
wusbcore
/lib/modules/4.15.0-91-generic/kernel/drivers/usb/wusbcore:
wusbcore.ko
As said before, the camera does not show up as /dev/video*
, and I don't know what I should do next!
Solution 1:
I got it working thanks to this:
$ sudo apt-get install gphoto2 v4l2loopback-utils ffmpeg
$ sudo modprobe v4l2loopback exclusive_caps=1 max_buffers=2
(some advice there as how to make this more automatic)
Then some running process needs to get killed:
$ ps aux|grep gphoto
$ kill <the PID for the process gvfsd-gphoto2, or something like that>
And running this in the background:
$ gphoto2 --stdout --capture-movie | ffmpeg -i - -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/video
All this makes the /dev/video0
appear, and work as a video input. Although right now, I'm getting poor fps.