[WIP] Multiple Webcam streams in Control (Multicam)

Have you also added something in your frontend to tell haproxy to use the alternative webcam backend when encountering the webcam-alt prefix? The config snippet you shared only shows that you configured a backend, but not that you also added a rule to the frontend.

Nope, I hadn't done that yet. I've never worked with haproxy before, just apache and nginx for reverse-proxy stuff. I'll go look at the config file again. Thanks for the tip!

edit: tadaaaaa, that did it. Config for anyone else who might need it:

frontend public
        bind :::80 v4v6
        bind :::443 v4v6 ssl crt /etc/ssl/snakeoil.pem
        option forwardfor except 127.0.0.1
        use_backend webcam if { path_beg /webcam/ }
        use_backend webcam2 if { path_beg /webcam2/ }
        default_backend octoprint

backend webcam2
        reqrep ^([^\ :]*)\ /webcam2/(.*)     \1\ /\2
        server webcam2  127.0.0.1:8081
        errorfile 503 /etc/haproxy/errors/503-no-webcam.http

Also if anyone else is interested in using mjpg_streamer for both cameras:

#!/bin/sh
export LD_LIBRARY_PATH="$(pwd)"
./mjpg_streamer -i "./input_uvc.so -d /dev/video0 -r 1920x1080" -o "./output_http.so -p 8080 -w ./www/" & ./mjpg_streamer -i "./input_uvc.so -d /dev/video1 -r 640x480" -o "./output_http.so -p 8081 -w ./www/"

I haven't yet figured out how to use the octopi.txt config to allow multiple instances to run, so for now I'm using a cron to kill the original mjpg_streamer instance and run this script

Edit2:

Found a more acceptable way to configure the second stream: https://printoid.net/2017/04/29/trick-12-support-two-cameras-in-printoid-premium/

Edit3:
looks like in the current iteration of Octopi, the above linked method is depreciated. Instead it's invoked from webcamd: https://github.com/guysoft/OctoPi/blob/91380e2a12b96f5bcbf9314fcaf1f0c04b830f49/src/modules/octopi/filesystem/home/root/bin/webcamd

Hi All,

Based on Alan_Weinstocks Edit1, I hacked the /root/bin/webcamd to play with the dual instance of mjpg-streamer. That way OctoPi starts up as normal but both webcams are working. Just a sloppy hack for now to see if it'd work and if it'll affect my print work stability. In my case I know my cams are without issues and that they were at /dev/video0 and /dev/video1.

Seems to work at least for playing around. Printing a few tests to see if anything happens weird.

My edits for those interested:

pi@octopi:/root/bin $ diff webcamd xxx_webcamd.orig 
60,70c60,61
< #        echo Running ./mjpg_streamer -o "output_http.so -w $camera_http_webroot $camera_http_options" -i "$input"
< #        LD_LIBRARY_PATH=. ./mjpg_streamer -o "output_http.so -w $camera_http_webroot $camera_http_options" -i "$input" &
< 
< 
<         LD_LIBRARY_PATH=. 
<         echo Running ./mjpg_streamer -i "./input_uvc.so -d /dev/video0 -r 1920x1080" -o "./output_http.so -p 8080 -w $camera_http_webroot" &
<         ./mjpg_streamer -i "./input_uvc.so -d /dev/video0 -r 1920x1080" -o "./output_http.so -p 8080 -w $camera_http_webroot" &
< 
<         echo Running ./mjpg_streamer -i "./input_uvc.so -d /dev/video1 -r 1920x1080" -o "./output_http.so -p 8081 -w $camera_http_webroot" &
<         ./mjpg_streamer -i "./input_uvc.so -d /dev/video1 -r 1920x1080" -o "./output_http.so -p 8081 -w $camera_http_webroot" &
< 
---
>         echo Running ./mjpg_streamer -o "output_http.so -w $camera_http_webroot $camera_http_options" -i "$input"
>         LD_LIBRARY_PATH=. ./mjpg_streamer -o "output_http.so -w $camera_http_webroot $camera_http_options" -i "$input" &
198d188
< 

I configure the multicam plugin to find the streams as follows:

http://[octopi.ip.address]:8080/?action=stream

and

http://[octopi.ip.address]:8081/?action=stream

I'll send a pull request to OctoPi/src/modules/octopi/filesystem/home/root/bin/webcamd with a real "fix"/Feature-add in a bit, I need some time to think about it.

Thanks Guys!

don't mind my noobness, but as I understand it.

basically for a 2nd camera to work I will need to assign it to a "video1" with the hardware number xxxx:xxxx? im guessing in the dev/video1 folder?

then assign it in mjpg streamer.?

I feel im understanding the process, but not sure.

Bonjour,
Débutant dans le domaine, je serais intéressé de pouvoir obtenir le même résultat (deux webcam, avec deux boutons comme sur votre exemple)
(ou deux écrans simultanés, côte à côte)
J'essaie d'utiliser le plugins ( multicam) et à l'action sur le bouton, l'écran de la webcam affiche
"" peut ne pas être configuré correctement ou nécessiter une authentification. Vous pouvez modifier l'URL du flux sous "Paramètres"> "Webcam & Accéléré"> "Webcam"> "URL du flux". Si vous n'avez pas de webcam, vous pouvez également désactiver la prise en charge de la webcam.""
"http://192.168.0.26/webcam/?action=stream"

Merci
de m'éclairer
2020-05-28T22:00:00Z

I recently ran the update on multicam that popped up on my browser in Octopi. It never ran correctly so figured I would try it out. After the update, and reboot Octopi browser takes FOREVER to load on a Pi 3b. WinSCP times out..