How can I configure dual cameras 1 Pi camera and 1 USB camera on a dual printer setup

I have configured Octopi for use with 2 printers the problem I am having is trying to get 1 pi cam working with printer A and a USB camera on printer B.

I cannot find a way to identify the pi cam to make it unique in the 99-usb.rules file

Can you run these commands and then post the results stored in /home/pi/devVideo0 and /home/pi/devVideo1?

udevadm info -a -n /dev/video0 > /home/pi/devVideo0
udevadm info -a -n /dev/video1 > /home/pi/devVideo1

Run the first command with only the raspi camera module hooked up and then before running the second one plug in the other camera so I know which is which

I can only run udevadm info -a -n /dev/video0 it says video1 does not exist. I do notice on boot the rasp pi cam comes on as soon as i plug the usb cam in thepi cam shuts down and the usb cam is live

Then post the output of lsusb and dmesg.

the pi cam is good but I cannot get the usb cam up unless I type this

cd ~/mjpg-streamer

./mjpg_streamer -i "./ -fps 10" -o "./ -p 8081"&

I think this may be the issue haproxy fails to start

pi@octopi:~ $ sudo /etc/init.d/haproxy restart
[....] Restarting haproxy (via systemctl): haproxy.serviceJob for haproxy.service failed. See 'systemctl status haproxy.service' and 'journalctl -xn' for details.
maxconn 4096
user haproxy
group haproxy
log local1 debug

log global
mode http
option httplog
option dontlognull
retries 3
option redispatch
option http-server-close
option forwardfor
maxconn 2000
timeout connect 5s
timeout client 15min
timeout server 15min

frontend public
bind *:80
bind ssl crt /etc/ssl/snakeoil.pem
option forwardfor except

use_backend webcam if { path_beg /webcam/ }

use_backend webcam2 if { path_beg /webcam2/ }
use_backend mkc if { path_beg /mk3/ }
use_backend anet if { path_beg /cr10/ }
default_backend webcam

backend mk3
reqrep ^([^\ :])\ /mk3/(.) \1\ /\2
option forwardfor
server octoprint1
acl needs_scheme req.hdr_cnt(X-Scheme) eq 0
reqadd X-Scheme:\ https if needs_scheme { ssl_fc }
reqadd X-Scheme:\ http if needs_scheme !{ ssl_fc }
reqadd X-Script-Name:\ /mk3

backend cr10
reqrep ^([^\ :])\ /cr10/(.) \1\ /\2
option forwardfor
server octoprint1
acl needs_scheme req.hdr_cnt(X-Scheme) eq 0
reqadd X-Scheme:\ https if needs_scheme { ssl_fc }
reqadd X-Scheme:\ http if needs_scheme !{ ssl_fc }
reqadd X-Script-Name:\ /cr10

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

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

I'm almost in the same case, i want put my Pi camera V2 and one USB caméra also, but in the same printer.

I install octoprint in a Raspberry Pi3 B+, all works fine, but i can't have the two caméras with the MULTICAM plugin in octoprint,

If you can help me that can be great

Thank you

1 Like

You could put two cameras on the same Raspi that's managing your print job but then it's also burdened to stream two videos as well. That's a lot of processing. It's possible that it could bog down your Raspi and affect print quality.

Consider pushing one of the cameras off on an Raspberry Pi Zero W which works nicely as a dedicated webcam server. It works great. It's portable. You can borrow it from your printer and it can be used for other projects without affecting it.

I am running into a similar issue. I have a Pi 3+, a Pi camera module, and USB web cam (Logitech c270).

Following instructions elsewhere, I added the following line to my crontab (using "crontab -e"):

reboot /home/pi/mjpg-streamer/mjpg_streamer -i "/home/pi/mjpg-streamer/ -f 15 -r 1280x720" -o "/home/pi/mjpg-streamer/ -w ./www -p 8800"

In Octoprint, on the regular "Webcam & Timlapse" settings screen, I have the Stream URL set to the default "/webcam/?action=stream"

On the multicam plugin settings screen, I have the second camera set to ""

When both cameras are plugged in, I get the USB correctly in the second camera image, but the primary image doesn't work.

If I unplug the USB camera and reboot, the pi camera module works correctly in the primary image.

I suspect that my setting in crontab somehow overrode the default values, but I'm not enough of a Liunux guy to know what the issue is.

I am wondering, are both cameras actually on or does the R-Pi shut one down due to power limitations ? I have never used 2 cams but I had a Startech R-Pi SSD adapter and the Pi cam on the CSI interface, the cam would shut down due to power issues, once I provided dedicated 5 V to the SSD card adapter the CSI cam worked no issues.

Jan P.

1 Like

I don't know how I would be able to tell.

With the R-Pi CSI cam I don't actually know. You should be measuring 3.3 V between the two most outer pins of the CSI interface (1 and 15). just I don't know if the 3.3V are there only if the camera is taking video footage or in stand by. I can't check that right now because my Pi Cam is not here. What should definitely show is the LED on the R-Pi cam, that should be on if the cam takes video footage. You would have to manually turn that off. With a USB cam you can always issue:


on the CLI, thats should list all attached USB devices, if the USB cam does not show there its off.

Jan P.

The USB camera is definitely on, since when it's plugged in I get the video stream! :slight_smile:

Sorry, I had a suggestion but on Octoprint it does not work what I was going to suggest. I have mjpg-streamer build from source and installed system wide, on Octoprint the following CLI issued command wont work:

mjpg_streamer -i '' -o ' --port 8081'

Once I am home I have a look how I can do the same on Octopi, this would allow to check the R-Pi cam if it works alongside the USB cam.

Will be back soon.....
Jan P.

Right..... I think I have it, its all residing in the pi home directory.

cd mjpg-streamer/
./mjpg_streamer -i "./" -o "./ --port 8081"

If it starts without error, just some informational output you should be able to watch your R-Pi cam on this URL with your Pi's IP Address:


If not or if the start on the mjpg_streamer fails just try with sudo before. If still no luck disable and unplug your USB cam and try again. If it works then its likely you are exceeding the power limitations of the R-Pi and it will disable the CSI cam.

If power is the issue there may be a way around that as well but try above 1st, just to be sure the Pi CSI cam is at least operational and the problem is not with hardware or cables etc.

Jan P.

I've found the solution I needed here:

To make it easier for others, here's what I did, it worked on a RPi 3B+ with one RPi Camera Module v2 and one USB Webcam (a Logitech c270)

ssh into the RPi running OctoPi and run:

sudo crontab -e

(Note the sudo is important - there appear to be two different crontabs, perhaps one for system and one for user account? Not sure, not a Linux expert, but if you drop the 'sudo' it'll seem to work but the cameras won't come up right in OctoPrint.)

If you've not done this before, it'll ask you what editor to use. I use Nano, but that's personal choice. In the editor, go to the end of the file, and add the following lines:

@reboot /home/pi/mjpg-streamer/mjpg_streamer -i "/home/pi/mjpg-streamer/ -x 1024 -y 768 -mm matrix -fps 3" -o "/home/pi/mjpg-streamer/ -w ./www -p 8801"
@reboot /home/pi/mjpg-streamer/mjpg_streamer -i "/home/pi/mjpg-streamer/ -f 15 -r 1280x720" -o "/home/pi/mjpg-streamer/ -w ./www -p 8800"

This will cause mjpg streamer to start on reboot, and will put the RPi module on port 8801 and the USB camera on port 8800. You can use whatever ports you want. Note also that this sets the Camera Module resolution to 1024x768 and limits it to 3 frames per second, while the usb camera is set to 1280x720 and 15fps. Those are the settings I happened to cut and paste from elsewhere, and they don't seem to bog down the Pi at all, it still prints and streams great. I've not tried more aggressive settings.

Make sure to reboot the Pi at this point, either via the command line or through OctoPi.

Note that you'll need to change settings on the OctoPrint timelapse and multicam. I have the RPi camera module being used for the time lapse (because of where it's placed). With my ports, on the "Webcam and Timelapse" settings page, the "Stream URL" (from the camera module) is:


For "Snapshot URL" I have:


Finally, on the multicam settings page, for the second camera's URL I have:


This is for the USB camera.

I've not played with this beyond getting it working, and have not tried it with OctoLapse. Hope this helps someone else.


@jgalak Did you mean to say sudo crontab -e there?

1 Like

Sure did! Fixed, thanks.

Thank you for the great write up. I do have an issue when following your instructions. I did everything you said to do, but it still doesn't work. I am wondering if my issue is with the pi camera. I am not using a original pi camera but am using a arducam from amazon. Would that change anything? Thanks in advance.

1 Like

Thanks worked great, took me a sec to realize the port number was slightly different than the 8080 default.

edit: omg necrobump, didn't realize this was so old.