Skip to content

Instantly share code, notes, and snippets.

@logich
Last active April 8, 2021 21:01
Show Gist options
  • Save logich/a8c757338959af57ad46ac96cade47e9 to your computer and use it in GitHub Desktop.
Save logich/a8c757338959af57ad46ac96cade47e9 to your computer and use it in GitHub Desktop.
octopi multicam support with raspicam, usbcam, and systemd
roughly based on data from teaching tech tutorial at https://www.youtube.com/watch?v=pcFBsciSdEw
cd /boot/
sudo cp octopi.txt octopi-cam2.txt
cd /root/bin/
sudo cp webcamd webcamd2
modify the octopi.txt to default to raspicam by specifying camera="raspi"
modify the http option:
camera_http_options="-p 8080"
modify the octopi-cam2.txt to default to usb by specifying camera="usb"
modify the http option:
camera_http_options="-p 8081"
enable the raspi cam in raspi-config (Interface Options -> Camera)
create the startup files to use systemd
cd /etc/systemd/system
sudo cp webcamd.service webcamd2.service
edit webcamd2 to point to the webcamd2 script and new log files
cat webcamd.service | sed -e's/webcamd/webcamd2/g' > webcamd2.service
sudo systemctl enable webcamd2.service
reboot to verify proper startup
modify haproxy
sudo vi /etc/haproxy/haproxy.cfg
in "frontend public" add line
use_backend webcam2 if { path_beg /webcam2/ }
create new section "webcam2" with content duplciated from "webcam"
backend webcam2
reqrep ^([^\ :]*)\ /webcam2/(.*) \1\ /\2
server webcam2 127.0.0.1:8081
errorfile 503 /etc/haproxy/errors/503-no-webcam.http
restart haproxy service with "sudo service haproxy restart"
Then add multicam config to say "/webcam2/?action=stream"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment