Skip to content

Instantly share code, notes, and snippets.

@traverseda
Last active September 13, 2023 16:58
Show Gist options
  • Save traverseda/15b6fb99c7f9f4a177e493fdcd3ba4cb to your computer and use it in GitHub Desktop.
Save traverseda/15b6fb99c7f9f4a177e493fdcd3ba4cb to your computer and use it in GitHub Desktop.
#Playbook to quickly and easily set up your canon camera as a webcam.
# Run with `ansible-playbook dslr-webcam.yaml --ask-become-pass`
# Tested with an old digital rebel XS, a lot of other pixel formats threw errors not sure what cameras
# this will work with.
- hosts: localhost
connection: local
tasks:
- name: set up video loopback device on boot
become: True
copy:
dest: "/etc/modprobe.d/dslr-webcam.conf"
content: |
alias dslr-webcam v4l2loopback
options v4l2loopback exclusive_caps=1 max_buffers=2 card_label="DSLR" video_nr=10
- name: Automatically start stream when dslr turns on
become: True
copy:
dest: "/etc/udev/rules.d/99-dslr_webcam.rules"
content: >
ACTION=="add", SUBSYSTEM=="usb",
ATTR{idVendor}=="04a9",
ATTR{idProduct}=="317b",
RUN+="/bin/sh -c 'gphoto2 --stdout --capture-movie | ffmpeg -i - -vcodec rawvideo -pix_fmt yuv420p -f v4l2 /dev/video10'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment