Setting up multiple webcams in OctoPi the right way

An update to this guide would be so helpful!

I can no longer have 2 cameras.

I see my USB Camera but I cannot use my raspicam anymore when I try to use multiple cameras since the camera="raspi" has been removed and I don't know which device I have to add to the "camera_usb_options=" via parameter "-d" because this is simply not in the not updated yet guide.
I tried to use the -d dev/v4l/by-path/platform-bcm2835-isp-video-index0 but it doesnt work.

So long I have to go with 1 camera but 2 cameras are so convinient and maybe there could also be a UI within OctoPrint for this instead of having to fiddle around with the files (just a wish for the future).

Thank you for all the great work so far. Enriches my 3D printing life so much!

With the advent of the new camera stack for OctoPi it's not top of my priorities to get out my RPi cam & the old stack now to figure out what it should be. If it's simple and takes me 5 mins (or if someone else knows the answer) that would be good. I can't do it at the moment as I don't have the hardware accessible.

I can definitely recommend the new camera stack, which also makes adding new cameras even easier - it's available in the RPi imager as an additional option.

Has this plugin died :man_shrugging:

Not that I'm aware of. You have to manually install since it's unlisted. Go to plugin manager > get more and at the bottom in the ...from URL field copy/paste this url and click install.

https://github.com/jneilliii/OctoPrint-MultiCamView/archive/refs/heads/master.zip
1 Like

I did as resort from a backup and the plugin didn't reconfigure, try to install it manually, but that also failed.

Forgot about

Cheers works perfectly again :+1:

Is there an updated version for the new stack yet?

It's documented in the FAQ at the bottom.

Thanks for the documentation, unfortunately it doesn't work on the latest nightly octopi image (based on raspian bookworm). I get the error "The webcam server is currently not running".

The reason might be that they changed /boot to /boot/firmware (octopi.txt is also found there). So i tried to place the octopi.conf.d directory also there but it ignores it. Trying to place it in /boot does also not work.

Do you have any hint what should be modified to get it running on bookworm (cam1 is working well here)
I need to use bookworm since it has proper pi5 support and octoprint works there flawlessly.

1 Like

hello everyone, i try follow all the steps , but both cameras never work same time one work the other one just said server error, when i swap the cameras same thing only front camera or nozzle camera but never together

Same issue for me, I do not find working solution... Maybe there is a configuration to define file location for second camera.

I found a solution to get both cameras working.

  1. sudo service webcamd stop
  2. sudo nano /root/bin/webcamd
    Find:
    config_dir="${CONFIG_FILE}/octopi.conf.d"
    Replace:
    config_dir="/boot/firmware/octopi.conf.d"
  3. Save and Exit
  4. sudo service webcamd start

You made my day thanks a lot ! It works nice with this workaround.

Seem to have a number of Issues getting things going on the latest release with Bookworm.

Over previous days I have setup 3 Cameras Successfully on an older Test Version.
(Octopi 0.18.0, OctoPrint 1.8.7 & Multicam Plugin).

Currently working on a Clean Blank Install on the Same Pi with Same 3 Cameras.
Have done nothing but step thru the Wizzard & then log in.

In the interface I see the Logi C922 Working fine.
In my Browser I get the following issue.

http://192.168.59.27/webcam/?action=stream working OK, but
http://192.168.59.27:8080/?action=stream gets a "Connection Refused" Error.

To this point I have not proceeded at all regards adding the other Cams.
Just how it is straight off the freshly written SD card.

I have read the Thread Multiple Times & am aware of others posts, including the different location of Octopi.txt now being in /boot/firmware/ & the additional changes required for webcam2.txt

Almost seems like the Proxy is now blocking external access to the direct port URL.

Any further thoughts?

That seems close, but I suspect the mjpg-streamer config is locking connectivity to the port directly instead of going through haproxy (that's the one you say is working). So the streamer is configured to only accept connections from localhost and haproxy configuration is working correctly.

You could continue to setup the additional cameras and just make sure to update the haproxy to route /webcam1, /webcam2, etc....

Ok,
So I have all 3 working now on the latest version that I restored a backup to a few days ago.
(Not using the Clean Build SD Card right now).

All Visible on my PC at:-
http://192.168.59.27/webcam/?action=stream but not http://192.168.59.27:8080/?action=stream
http://192.168.59.27/webcam2/?action=stream and http://192.168.59.27:8081/?action=stream
http://192.168.59.27/webcam3/?action=stream also http://192.168.59.27:8082/?action=stream

But,

In Octoprint Multicam, I can't access them at 127.0.0.1 or localhost.
They do work there though if I specify the Pi's IP address in the URL.

Edit:- I do wonder if the behaviour is related to the code in haproxy.txt,
While I don't quite understand it, I see things like forwardfor,
and v4v6, which I presume references IPV6, which I've seen cause other local issues in different cases.

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 webcam_hls if { path_beg /hls/ }
        use_backend webcam_hls if { path_beg /jpeg/ }
        default_backend octoprint

This is what I was referring to when I mentioned adding the relative URLs, see the section from the original post OPTIONAL: Haproxy configuration.

I Do Believe I have haproxy setup fine as it appears to be working as mentioned above.
(Note:- I haven't edited the Snapshot URL's & they do not work).

Cameras available as /webcam/, /webcam2/ etc in my PC's Browser.

It's the fact that the Pi can't see its own cameras on 127.0.0.1 or localhost that is different.
Yet it can see them addressing it's own IP address.

My Full haproxy.cfg is as follows.

global
        maxconn 4096
        user haproxy
        group haproxy
        log /dev/log local1 debug
        tune.ssl.default-dh-param 2048

defaults
        log     global
        mode    http
        compression algo gzip
        option  httplog
        option  dontlognull
        retries 3
        option redispatch
        option http-server-close
        option forwardfor
        maxconn 2000
        timeout connect 5s
        timeout client  15m
        timeout server  15m

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/ }
        use_backend webcam3 if { path_beg /webcam3/ }
        use_backend webcam_hls if { path_beg /hls/ }
        use_backend webcam_hls if { path_beg /jpeg/ }
        default_backend octoprint

backend octoprint
        acl needs_scheme req.hdr_cnt(X-Scheme) eq 0

        http-request replace-path ^([^\ :]*)\ /(.*) \1\ /\2
        http-request add-header X-Scheme https if needs_scheme { ssl_fc }
        http-request add-header X-Scheme http if needs_scheme !{ ssl_fc }
        option forwardfor
        server octoprint1 127.0.0.1:5000
        errorfile 503 /etc/haproxy/errors/503-no-octoprint.http

backend webcam
        http-request replace-path /webcam/(.*) /\1
        server webcam1  127.0.0.1:8080
        errorfile 503 /etc/haproxy/errors/503-no-webcam.http

backend webcam2
        http-request replace-path /webcam2/(.*) /\1
        server webcam2  127.0.0.1:8081
        errorfile 503 /etc/haproxy/errors/503-no-webcam.http

backend webcam3
        http-request replace-path /webcam3/(.*) /\1
        server webcam3  127.0.0.1:8082
        errorfile 503 /etc/haproxy/errors/503-no-webcam.http


backend webcam_hls
        server webcam_hls_1 127.0.0.1:28126
        errorfile 503 /etc/haproxy/errors/503-no-webcam-hls.http