Skip to content

Instantly share code, notes, and snippets.

@sepastian
Last active March 25, 2020 11:21
Show Gist options
  • Save sepastian/0ed6e05d42d0b34d7704ac6a0c5bf538 to your computer and use it in GitHub Desktop.
Save sepastian/0ed6e05d42d0b34d7704ac6a0c5bf538 to your computer and use it in GitHub Desktop.
# Use a DSLR camera as a webcam, in Zoom and other applications.
# Inputs from https://gist.github.com/ianmackinnon/cf8a4d6cdb08852a818fc34bd4e1882f
# See # https://gstreamer.freedesktop.org/documentation/video4linux2/v4l2sink.html?gi-language=c#v4l2sink
# Install dependencies.
sudo apt install v4l2loopback-dkms gphoto2 gstreamer1.0-tools
# Load and verify module.
sudo modprobe v4l2loopback
sudo lsmod | grep v4l2loopback
#v4l2loopback 45056 0
#videodev 249856 4 videobuf2_v4l2,v4l2loopback,uvcvideo,videobuf2_common
# Grab JPEG frames from Nikon D7000 using gphoto2;
# use gstreamer to stream video to v4l2 device.
#
# Make sure to pipe through videoconvert, v4l2sink complains otherwise;
# setting sync=false seems to prevent the video getting slow after a while, due to frame drop.
#
# Specify a non-existing video device to v4l2sink;
# if specifying an existing device, gst-launch will complain about that device not being an output device.
gphoto2 --capture-movie --stdout \
| gst-launch-1.0 -v -e fdsrc \
! image/jpeg,framerate='(fraction)'24/1,width=640,height=480 \
! jpegdec \
! videoconvert \
! v4l2sink device=/dev/video2 sync=false
# Now it should be possible to use the new video device /dev/video2 in Zoom and other applications.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment