I can't use my digital camera ( Canon ixus 160) as webcam is there an application for that ? or just in the settings?
-
Add more info. You must be getting some error or something.– RahulCommented Dec 3, 2016 at 9:24
-
Are there any clues in the manual that this is possible? A similar question has been asked before askubuntu.com/questions/53889/… but it was closed (for no good reason imho). Also something like that is done in this moreno.marzolla.name/software/linux-webcam-server tutorial.– BruniCommented Dec 3, 2016 at 13:29
4 Answers
Here's another solution.
List of gphoto2 supported cameras: http://gphoto.org/proj/libgphoto2/support.php
You need install gphoto, v4l2loopback-utils and ffmpeg.
Then
sudo modprobe v4l2loopback
and
gphoto2 --stdout --capture-movie | ffmpeg -i - -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/video1
Now you have webcamera from your digital camera.
-
3I get this error (cut at top): Input #0, mjpeg, from 'pipe:': Duration: N/A, bitrate: N/A Stream #0:0: Video: mjpeg, yuvj422p(pc, bt470bg/unknown/unknown), 1056x704, 25 tbr, 1200k tbn, 25 tbc Stream mapping: Stream #0:0 -> #0:0 (mjpeg (native) -> rawvideo (native)) [swscaler @ 0x559c14f77de0] deprecated pixel format used, make sure you did set range correctly [v4l2 @ 0x559c14f42fc0] ioctl(VIDIOC_G_FMT): Invalid argument Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument Error initializing output stream 0:0 -- Conversion failed! ➜ ~– noreabuCommented Nov 4, 2017 at 11:01
-
@noreabu if you have other webcams, the
/dev/video1
may not be the loopback device. You can check type of devices withv4l2-ctl --list-devices
Commented Apr 22, 2020 at 11:38 -
1It worked for me... but the resolution is 1056x704. Is it possible to change it to a 16:9 resolution, such as 720p? I am using a Cannon T3i and this option is available on Entangle... however I don't know how to change your command to switch to a different aspect ratio– RafaelCommented May 5, 2020 at 22:40
This can be done but requires a number of steps. First, you must install gphoto
and v4l2loopback-utils
.
sudo apt-get install gphoto2 v4l2loopback-utils
Plug in your camera via USB (when the camera mounts automatically, unmount it). Then run gphoto2 --abilities
to see if your camera is capable of doing this. Here's the output when connecting a Canon EOS 1200D
Then run sudo modprobe v4l2loopback
to activate the kernel module needed to create a video device from your camera.
I've seen older tutorials on this task that use gst-launch-0.10 to achieve the next step of this task (e.g. this one). I am using Ubuntu 17.04 which uses gst-launch-1.0. Below is the updated command to create a video device from your digital camera:
gphoto2 --stdout --capture-movie | gst-launch-1.0 fdsrc ! decodebin3 name=dec ! queue ! videoconvert ! v4l2sink device=/dev/video1
This will create a video device in /dev/video1
, which you can now use in programs like VLC.
If you see any errors about the device being in use you need to kill the gvfs-gphoto2-volume-monitor
process by running killall gvfs-gphoto2-volume-monitor
.
-
6I get this:
➜ ~ gphoto2 --stdout --capture-movie | gst-launch-1.0 fdsrc ! decodebin3 name=dec ! queue ! videoconvert ! v4l2sink device=/dev/video1 Setting pipeline to PAUSED ... Nehme Vorschaubilder als Film in 'stdout' auf. Drücke Ctrl-C zum abbrechen. ERROR: Pipeline doesn't want to pause. ERROR: from element /GstPipeline:pipeline0/GstV4l2Sink:v4l2sink0: »/dev/video1« ist kein Wiedergabegerät. Additional debug info: v4l2_calls.c(642): gst_v4l2_open (): /GstPipeline:pipeline0/GstV4l2Sink:v4l2sink0: Capabilities: 0x5200001 Setting pipeline to NULL ... Freeing pipeline ...
– noreabuCommented Nov 4, 2017 at 10:57 -
-
1
-
This worked via the ffmpeg answer above. I had to use
guvcview
to see the output– JonathanCommented Jan 15, 2019 at 19:11 -
I'm getting
modprobe: FATAL: Module v4l2loopback not found in directory /lib/modules/4.15.0-36-generic
Commented Jun 25, 2019 at 19:35
I was able to get video & image recording with a Canon DSLR 600D
sudo apt get install guvcview ffmpeg gphoto2 v4l2loopback-dkms v4l2loopback-utils ffmpeg
Plug in camera, any mode seemed to work, test with the basics:
Prep
sudo modprobe v4l2loopback
killall gvfs-gphoto2-volume-monitor
Test
lsusb
gphoto2 --auto-detect
LANG=C gphoto2 --summary
LANG=C gphoto2 --list-all-config
Try
gphoto2 --capture-image
gphoto2 --stdout --capture-movie | ffmpeg -i - -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/video1
Visualize (in another terminal)
guvcview
or
guvcview-brlin.guvcview
You can try different /dev/video1
commands
There's also EOS Movie Recorder
Unzip this: https://sourceforge.net/projects/eos-movrec/files/eos-movrec/0.3.3_beta/eos-movrec-0.3.3_beta.zip/download
cd eos-movrec-0.3.2_beta
sudo apt install libgphoto2-dev
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make
-
3thanks. i use this and then capture the window in OBS "gphoto2 --stdout --capture-movie | ffplay - "– y oCommented Apr 2, 2020 at 2:15
-
Thank you for this. Is it possible to access the camera microphone at the same time (and make it an accessible device)?– azmeukCommented May 24, 2020 at 14:53
-
OBS has microphone capability, and plugins that can expose the whole setup as a webccam too– JonathanCommented Aug 13, 2020 at 2:18
I found this very useful for me and it did work with my Canon 5D Mark 3
How to use you DSLR camera as a webcam
OBS is a great tool for live streaming and recording a presentation or training. It can also be used to create a virtual webcam to act as input to tools such as Jitsi, Skype and Zoom. Lots of us have good DSLR type cameras, and these can act as a webcam for input to OBS (and any other tool that can use a webcam source). This allows you to use a high quality camera for the video input, and gives you the full control that you get with a digital camera. In this video, I show you how to use pretty much any camera as a webcam for OBS without any special software or hardware adapters. All you need is a camera and a USB cable. This is achieved using the combination of gphoto2, ffmpeg, and v42loopback.
Make sure your camera make and model is supported. You will find a list of cameras supported by this method at http://gphoto.org/proj/libgphoto2/support.php Fortunately, my Canon cameras are all supported. You will need a supported camera and a USB cable to connect the camera to your computer.
Set your camera so that it does not automatically power off. On my Canon 6D Mark ii this is "Auto power off: Disable" on the wrench screen 2.
If you have back-button focus enabled, you need to set focus back the the half press of the shutter key. If you use back button-focus you already know how to do this. If you leave back-button focus on, you will get errors relating to shutter button half press.
If you don't have gphoto2 installed, you need to install it first.
sudo apt install -y gphoto2
If you don't have the video loopback driver installed, you need to install it first.
sudo apt install -y v4l2loopback-utils
If you don't have ffmpeg installed, you need to install it first.
sudo apt install -y ffmpeg
Plug in your camera via USB (if the camera mounts automatically, unmount it) by selecting it in your file manager (Nautilus if you are using Gnome) and right click, and select "Unmount" from the popup menu.
Enable and determine the virtual video device First unload v4l2loopback so you can determine which device it is creating.
sudo rmmod v4l2loopback
Ignore any errors.
List all video devices so you know which one is next in line
ls /dev/video*
You will see something like/dev/video0 /dev/video1
which indicates video devices already on my computer. If you see nothing here, then you have no video devices.Activate v4l2loopback Run
sudo modprobe v4l2loopback exclusive_caps=1 max_buffers=2
to activate the kernel module ('loopback driver') that enables the creation of a video device from your DSLR camera.
List all video devices so you know which one is the one to use
ls /dev/video*
You will see something like/dev/video0 /dev/video1 /dev/video2
The last one will be the one used by the loopback driver, in this case video2.TESTING Now you can do some testing using gphoto 2. List auto-detected cameras and the ports to which they have been connected.
gphoto2 --auto-detect
You will see something like:
Model Port ---------------------------------------------------------- Canon EOS 6d Mark II usb:001,013
Capture the video and pipe ot out to the virtual webcam device
gphoto2 --stdout --capture-movie | ffmpeg -i - -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/video2
That is it. Now you can go and add it to your source in OBS.
All simple, and all free thanks to Free and Open Source Software.
-
Same comment as earlier. Is it possible to access the camera microphone at the same time (and make it an accessible device) ?– azmeukCommented May 24, 2020 at 14:54
-
Thanks for this awesome tutorial. It works flawlessly on my EOS 6D. How do I make autofous work?– tcapelleCommented Jan 1, 2021 at 17:35
-
Thanks, key was activated v4l2loopback with parametrs max_buffers and exclusive_caps Commented Jun 2, 2021 at 23:06