I have struggled so much to make my 2 cameras working properly with the multicam plugin that I feel like I have to share the working configuration.
Camera 1 = official Raspicam
Camera 2 = Creative Technology, Ltd Live! Cam Socialize [VF0640]
Raspbian version: Raspbian GNU/Linux 10 (buster)
Octoprint version: Version 1.3.11 manually installed using this guide
Required Plugin: Multicam 0.2.6 by Michael Morris
The main struggle is to get both camera streaming at the same time on 2 different ports then getting them being displayed in Octoprint.
I have tried a lot of tricks to start 2 streams with absolutely no luck, I don't know why if one camera USB is connected, it disconnects the raspicam and only streams the USB webcam. So my solution might look dirty but it works for now. I wish I could start both streamings using the same webcamDaemon file. If a script master is present, please give me a tip.
Here are the scripts I modified:
./scripts/webcamDaemon is left untouched
./scripts/webcam is modified as follow:
!/bin/bash
# Start / stop streamer daemon
case "$1" in
start)
/home/pi/scripts/webcamDaemon >/dev/null 2>&1 &
pushd /home/pi/mjpg-streamer/mjpg-streamer-experimental
export LD_LIBRARY_PATH=.
./mjpg_streamer -o "output_http.so -w ./www -p 8081" -i "input_raspicam.so -fps 10" &
popd &
echo "$0: started"
;;
stop)
pkill -x webcamDaemon
pkill -x mjpg_streamer*
echo "$0: stopped"
;;
*)
echo "Usage: $0 {start|stop}" >&2
;;
esac
.octoprint/config.yaml:
section multicam
multicam:
_config_version: 1
multicam_profiles:
- URL: http://My_Octoprint_address:8081/?action=stream
isButtonEnabled: false
name: Raspi
- URL: http://My_Octoprint_address:8080/?action=stream
isButtonEnabled: true
name: USB CAM
Section webcam
webcam:
ffmpeg: /usr/bin/ffmpeg
snapshot: http://127.0.0.1/?action=snapshot
stream: http://My_Octoprint_address:8081/?action=stream
/etc/haproxy/haproxy.cfg
at the end of the file
frontend public
bind :::80 v4v6
use_backend webcam if { path_beg /webcam/ }
use_backend webcam1 if { path_beg /webcam1/ }
default_backend octoprint
backend octoprint
reqrep ^([^\ :]*)\ /(.*) \1\ /\2
option forwardfor
server octoprint1 127.0.0.1:5000
backend webcam
reqrep ^([^\ :]*)\ /webcam/(.*) \1\ /\2
server webcam 127.0.0.1:8080
backend webcam1
reqrep ^([^\ :]*)\ /webcam1/(.*) \1\ /\2
server webcam1 127.0.0.1:8081
reboot the raspberry and enjoy having 2 points of view. Switching views is not super fast but it works!!