Skip to content

Instantly share code, notes, and snippets.

@IamNaN
Created March 3, 2023 06:11
Show Gist options
  • Save IamNaN/9934aa2fbd64e3c05b3603c3592c3163 to your computer and use it in GitHub Desktop.
Save IamNaN/9934aa2fbd64e3c05b3603c3592c3163 to your computer and use it in GitHub Desktop.
Ruby script to reset and start a DSLR or Mirrorless camera as a webcam using gphoto2, v4l2loopback, and ffmpeg
#!/usr/bin/env ruby
system("sudo modprobe -r v4l2loopback")
system("pkill gphoto")
system("sudo modprobe v4l2loopback exclusive_caps=1 max_buffers=2")
system("gphoto2 --stdout --capture-movie | ffmpeg -i - -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/video0")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment