Install both a Raspberry PI Camera and a USB Camera on Octopi 0.17 and 0.18
Last updated February 27, 2021
I use Octoprint to manage my Prusa MK3 3D printer. To keep an eye on my prints, I have two cameras hooked up to the Raspberry PI on which I have Octoprint installed. The main camera is a Raspberry PI camera that hooks up directly the PI via a ribbon cable, and the second camera is a Logitech C510 webcam that I plug into one of the PI’s USB ports.
When I upgraded Octopi — a Raspberry PI Linux distribution that comes with Octoprint pre-installed — the USB camera stopped working and I couldn’t figure out how to get it working again. Octopi 0.17 is significantly different from previous versions, so I couldn’t rely on the tutorials I had used before.
I searched on YouTube, my favorite DIY resource, and found Chris Riley’s Chris’ Basement channel. He has a series of videos on how to set up an Octoprint multi-instance on one PI on Octopi 0.17. His instructions are great and I wouldn’t have found a solution without his videos, but they are geared toward hooking up USB cameras — not both a Raspberry PI camera and a USB camera.
Prerequisites
In this post I don’t explain how to install Octopi 0.17/0.18, nor how to attach and get working a PI Cam. You’ll need to get that done first before moving on.
You’ll also need to know a little about getting around a Linux command line and using the nano text editor.
Once you have the PI and PI Cam up and running, follow the instructions below to get a second (USB) camera working with your Raspberry PI.
Word of Caution:
You might be tempted to connect 2, 3 or 4 USB webcams to your Raspberry PI. Don’t do it. That path leads to madness. The cameras won’t mount as expected — I suspect because of limitations of Raspberry PIs in general, but I don’t know for sure. You’ll drive yourself crazy. Be content with running the RPI Camera Module and one USB camera.
1: Get information about your USB webcam
Log into your Raspberry PI via ssh. If you followed the standard Octopi setup, ssh’ing into your PI should be as simple as this:
> ssh pi@octopi.local
Make sure your USB webcam is unplugged from Raspberry PI. Type the following command in the terminal:
> tail -f /var/log/messages
Now plug the USB camera back in, and look at the new text that appeared in the logs you’re tailing. You should see bunch of lines that include the text “New USB device found”, or similar. Here’s an example of my log:
May 25 17:43:00 octopi kernel: [ 2.411980] usb 1-1.3: new high-speed USB device number 5 using dwc_otg
May 25 17:43:00 octopi kernel: [ 2.753813] usb 1-1.3: New USB device found, idVendor=046d, idProduct=081b, bcdDevice= 0.12
May 25 17:43:00 octopi kernel: [ 2.759809] usb 1-1.3: New USB device strings: Mfr=0, Product=0, SerialNumber=2May 25 17:43:00 octopi kernel: [ 2.763045] usb 1-1.3: SerialNumber: 61196260
You'll need the values for idVendor, idProduct, and SerialNumber in the next step.
2: Create (or edit if existing) USB rules file
Use the nano text editor to edit (or create) a usb rules file:
> sudo nano /etc/udev/rules.d/99-usb.rules
Add the following line to the file:
SUBSYSTEM=="video4linux", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="081b", ATTRS{serial}=="61196260", SYMLINK+="PrusaWebCam"
These are the values I found in my log for my camera (a Logitech C510 HD webcam) — you’ll need to use your values for idVendor, idProduct and serial. For SYMLINK, use whatever name you want to give your camera. You’ll use the name in upcoming steps.
3: Confirm USB camera is properly set up:
Before moving on to step 4, it’s a good idea to confirm that the camera you configured in the previous udev USB rules step is working properly. If it isn’t, then none of the steps that follow will work.
First, let’s reboot the Raspberry PI to make it read the settings in 99-usb.rules and connect your camera.
> sudo reboot
Once your PI is back up, ssh into it again and type the following command to list all the devices under the /dev directory:
> ls -la /dev
If 99-usb.rules was read correctly at startup, you should find the symlink you created under /dev. Here’s what I see on my PI (I removed lots of entries to keep this short):
drwxr-xr-x 2 root root 60 Feb 11 19:20 net
crw-rw-rw- 1 root root 1, 3 Feb 11 19:20 null
crw------- 1 root root 108, 0 Feb 11 19:20 ppp
lrwxrwxrwx 1 root root 6 Feb 11 19:20 PrusaWebCam -> video0
crw-rw-rw- 1 root tty 5, 2 Feb 11 19:26 ptmx
drwxr-xr-x 2 root root 0 Feb 14 2019 pts
brw-rw---- 1 root disk 1, 0 Feb 11 19:20 ram0
The -> character next to PrusaWebCam indicates that linux set up a symbolic link to the video0 device called PrusaWebCam.
If you see a symbolic link for your camera:
Congratulations! You are the golden child! Move on to step 4.
If you DON’T see a symbolic link for your camera:
Darn it! Something is wrong in 99-usb.rules. Here are some things you can try:
Troubleshooting 1:
Before you start messing around with text editors, try the following: REBOOT AGAIN. This shouldn’t be a serious step, but it’s worked some than once for me.
Troubleshooting 2:
One of the main culprits of issues with udev rules is that some cameras don’t have valid serial numbers.
For example, I bought a cheap USB endoscope on Amazon to test and connected it to my spare Raspberry PI with Octopi 0.18 installed. I tailed the messages log while I plugged the endoscope in and here’s a partial list of the output:
Feb 11 20:04:22 octopi2 kernel: [ 2619.572078] usb 1-1.1.3: new high-speed USB device number 7 using dwc_otg
Feb 11 20:04:23 octopi2 kernel: [ 2619.783159] usb 1-1.1.3: New USB device found, idVendor=1908, idProduct=2311, bcdDevice= 1.00
Feb 11 20:04:23 octopi2 kernel: [ 2619.783177] usb 1-1.1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
SerialNumber=0 was suspicious to me, but I tried using it anyway in a second entry in my 99-usb.rules file, with SYMLINK+="EndoCam". After a reboot, I didn’t find an EndoCam symbolic link under the /dev directory. I rebooted several more times, still no luck.
The fix was easy. I added the EndoCam entry without a serial number attribute. Here’s what my 99-usb.rules file looks like now with both cameras configured:
SUBSYSTEM=="video4linux", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="081b", ATTRS{serial}=="3A108F50", SYMLINK+="PrusaWebCam"
SUBSYSTEM=="video4linux", ATTRS{idVendor}=="1908", ATTRS{idProduct}=="2311", SYMLINK+="EndoCam"
After rebooting, I now saw two video symbolic links under /dev.
lrwxrwxrwx 1 root root 6 Feb 11 20:04 EndoCam -> video5
lrwxrwxrwx 1 root root 6 Feb 11 19:20 PrusaWebCam -> video0
Troubleshooting 3:
Recheck your 99-usb.rules file. Make sure the syntax is correct, that the serial number and vendor ID are correct, and that you don’t have any strange characters like “smart quotes” or anything else that isn’t a standard ASCII character.
4: Prepare octopi.txt file for new webcam:
Under /boot there is an octopi.txt file which is a configuration file for the webcamd service (more on that service later). If you have your Raspberry PI camera running, then octopi.txt is set up to configure your PI cam. We’ll copy that file and use it to configure our webcam.
> cd /boot
> sudo cp octopi.txt octopi2.txt
> sudo nano octopi2.txt
Edit octopi2.txt:
Change the text
camera="raspi"(or it might becamera="auto") tocamera="usb".The line might be commented out, indicated by a “#” (pound, or hash symbol) at the beginning of the line. Make sure to remove the # at the beginning of the line, otherwise changing the line to read
camera="usb"will have no effect.
NOTE: Some people have reported not seeing a “camera” entry at all in their octopi.txt file. If that’s the case, you’ll need to add one yourself.
Remove the
#from in front of the line that starts withcamera_usb_optionsto uncomment it. Currently, it should look something likecamera_usb_options="-r 640x480 -f 10"Change that line to point to your USB camera. You’ll do that by adding a
-dflag with the name you gave your USB camera. Here’s what my camera usb options looks like:
camera_usb_options="-d /dev/PrusaWebCam -r 1280x720 -f 10"NOTE: Be conservative with your resolution and framerate settings. A Logitech C920 can support 1920x1080 at 30 frames per second. However, your Raspberry PI can’t keep up with the camera, especially if it’s running a PI Cam module and Octoprint. So, I recommend setting USB cameras as 1280x720 and 10 fps.
If your camera supports higher resolution you can experiment with changing the -r setting (resolution) from 640x480 to a different resolution, like I did in my example above. The -f flag is for framerate.
Further down in
octopi2.txtyou’ll need to comment out the line that starts withcamera_raspi_optionsby adding a#in front of it.Finally, remove the
#from in front of the line that starts withcamera_http_optionsto uncomment it (should be at the very end of the file) and change it to readcamera_http_options="-p 8081"That sets the port for your webcam to 8081.
You’re done with this file and can save and close it.
Now let’s edit octopi.txt (the config file for your Raspicam):
> sudo nano octopi.txt
To avoid the original octopi.txt from starting up the wrong camera, let’s edit it as well and make sure camera is set to raspi and not auto.
Find the
cameraline and make sure it readscamera="raspi"instead ofautoNOTE: As mentioned above, your octopi.txt file might not have a “camera” entry. If that’s the case for you, add one and set it to
camera="raspi"Set the port of the PI camera to 8080 by uncommenting the last line of the file, which should be
camera_http_optionsby deleting the#in front of the line.Make the line read
camera_http_options="-p 8080"Save and close the file
5: Prepare webcamd service files:
First we’ll duplicate the existing webcamd file.
> cd /root/bin
> sudo cp webcamd webcamd2
Now let’s edit webcamd.
> sudo nano webcamd
Toward the top of the file, make sure the line that starts with
cfg_files+=points tooctopi.txt. It should read:cfg_files+=/boot/octopi.txtFurther down in the file, look for two lines that read:
# add video device into optionsoptions="$options -d /dev/$device"Add a
#in front of theoptionsline to comment it out.#options="$options -d /dev/$device"That line only works when you have a single camera connected, otherwise it causes problems.
We’ll make almost the same edits to webcamd2.
> sudo nano webcamd2
Toward the top of the file, make sure the line that starts with
cfg_files+=points tooctopi2.txt(our second octopi configuration file). It should read:cfg_files+=/boot/octopi2.txtComment out the same
optionsline as you did in webcamd.#options="$options -d /dev/$device"
6: Set up service for webcamd2:
Now that we have our webcamd2 file ready, we need to create a service start file. We’ll copy an existing service file and edit it.
> cd /etc/systemd/system/
> sudo cp webcamd.service webcamd2.service
> sudo nano webcamd2.service
Change the
ExecStartline to readExecStart=/root/bin/webcamd2
Save and close the file.
Now let’s inform Linux about the webcamd2 service so it will get started at boot time:
> sudo systemctl enable webcamd2
7: Set up camera proxy:
The final step for running a second webcam on Octopi, is to set up a proxy. The proxy links the internal webcamd2 camera service to an http port, allowing you (and Octoprint) to view the camera’s mpeg stream from a browser.
> cd /etc/haproxy
> sudo nano haproxy.cfg
Under the
frontend publicheading add the following line:use_backend webcam2 if { path_beg /webcam2/ }There will already be an entry for
webcam. Copy the entirebackend webcamsection and paste it below the first entry. We’ll make a couple of changes to have it point to the second webcam. It should look like this:
backend webcam2
reqrep ^([^\ :]*)\ /webcam2/(.*) \1\ /\2
server webcam1 127.0.0.1:8081
errorfile 503 /etc/haproxy/errors/503-no-webcam.http
Notice a few things:
regrep line changed to read
webcam2serverline port changed to 8081, the port we assigned the second camera in an earlier step.HOWEVER, the server name should remain
webcam1. That’s not a typo above. Tricksy Linux.
Here’s what the two backend entries look like in my haproxy.cfg file.
backend webcam
reqrep ^([^\ :]*)\ /webcam/(.*) \1\ /\2
server webcam1 127.0.0.1:8080
errorfile 503 /etc/haproxy/errors/503-no-webcam.http
backend webcam2
reqrep ^([^\ :]*)\ /webcam2/(.*) \1\ /\2
server webcam1 127.0.0.1:8081
errorfile 503 /etc/haproxy/errors/503-no-webcam.http
Now you can reboot and you should see output from your second camera by pointing a browser to port 8081 on your Octopi box. Example: I have Bonjour setup and called my Raspberry PI box “octopi”, so the URL for the second camera within my home network is: http://octopi.local:8081/?action=stream
If you don’t see your USB camera at port 8081, move on to step 8 for troubleshooting tips.
8: Troubleshooting Services
The most common issue after not seeing your camera listed under /dev is problems with the service that launches mjpg streamer for the USB camera.
If you don’t see your USB webcam show up at port 8081, do you see it under /dev, then the service that starts up mjpg streamer is having a problem. To confirm this, run the following systemctl command:
> systemctl status webcamd2.service
If the service started up correctly, you’ll see something like this:
● webcamd2.service - the OctoPi webcam daemon with the user specified config
Loaded: loaded (/etc/systemd/system/webcamd2.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2021-02-27 15:16:51 PST; 9min ago
Process: 340 ExecStart=/root/bin/webcamd2 (code=exited, status=0/SUCCESS)
Main PID: 486 (mjpg_streamer)
Tasks: 4 (limit: 1939)
CGroup: /system.slice/webcamd2.service
└─486 ./mjpg_streamer -o output_http.so -w ./www-octopi -p 8081 -i input_uvc.so -d /dev/LogiCam -r 640x480 -f 5
Feb 27 15:16:50 octopi2 mjpg_streamer[486]: MJPG-streamer [486]: Format............: JPEG
Feb 27 15:16:50 octopi2 mjpg_streamer[486]: MJPG-streamer [486]: TV-Norm...........: DEFAULT
Feb 27 15:16:50 octopi2 mjpg_streamer[486]: MJPG-streamer [486]: www-folder-path......: ./www-octopi/
Feb 27 15:16:50 octopi2 mjpg_streamer[486]: MJPG-streamer [486]: HTTP TCP port........: 8081
Feb 27 15:16:50 octopi2 mjpg_streamer[486]: MJPG-streamer [486]: HTTP Listen Address..: (null)
Feb 27 15:16:50 octopi2 mjpg_streamer[486]: MJPG-streamer [486]: username:password....: disabled
Feb 27 15:16:50 octopi2 mjpg_streamer[486]: MJPG-streamer [486]: commands.............: enabled
Feb 27 15:16:50 octopi2 mjpg_streamer[486]: MJPG-streamer [486]: starting input plugin input_uvc.so
Feb 27 15:16:50 octopi2 mjpg_streamer[486]: MJPG-streamer [486]: starting output plugin: output_http.so (ID: 00)
Feb 27 15:16:51 octopi2 systemd[1]: Started the OctoPi webcam daemon with the user specified config.
However, if the service failed to start up correctly, you’ll see something like this:
● webcamd2.service - the OctoPi webcam daemon with the user specified config
Loaded: loaded (/etc/systemd/system/webcamd2.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Sat 2021-02-27 15:28:51 PST; 1min 35s ago
Process: 350 ExecStart=/root/bin/webcamd2 (code=exited, status=0/SUCCESS)
Feb 27 15:28:50 octopi2 mjpg_streamer[484]: MJPG-streamer [484]: starting application
Feb 27 15:28:50 octopi2 mjpg_streamer[484]: MJPG-streamer [484]: MJPG Streamer Version: git rev: 5554f42c352ecfa7edaec6fc51e507afce605a34
Feb 27 15:28:50 octopi2 mjpg_streamer[484]: MJPG-streamer [484]: Using V4L2 device.: /dev/video3
Feb 27 15:28:50 octopi2 mjpg_streamer[484]: MJPG-streamer [484]: Desired Resolution: 640 x 480
Feb 27 15:28:50 octopi2 mjpg_streamer[484]: MJPG-streamer [484]: Frames Per Second.: 5
Feb 27 15:28:50 octopi2 mjpg_streamer[484]: MJPG-streamer [484]: Format............: JPEG
Feb 27 15:28:50 octopi2 mjpg_streamer[484]: MJPG-streamer [484]: TV-Norm...........: DEFAULT
Feb 27 15:28:50 octopi2 mjpg_streamer[484]: MJPG-streamer [484]: init_VideoIn failed
Notice the last line. It reads init_VideoIn failed. AND THIS IS WITH THE SAME CAMERA WITH THE SAME SETTINGS.
Troubleshooting Tip 1:
Reduce the resolution and frame rate of both your PI Camera and your USB webcam.
Your Raspberry PI is amazing, but it still must obey the laws of physics, and you just might be asking it to do too much. Remember, your PI is running Linux, Octoprint and two video streaming services.
Here are the settings for my PI Cam and Logitech C510 in octopi.txt and octopi2.txt, respectively:
// octopi.txt -- raspi cam settings
camera_raspi_options="-x 1280 -y 720 -fps 10"
// octopi2.txt -- USB cam settings
camera_usb_options="-d /dev/PrusaWebCam -r 1280x720 -f 10"
Both cameras support resolutions of 1920x1080 and frame rates of 30fps, but setting the cameras to their max values caused the cameras not to start up. Sometimes I’d get one, or the other, but never both at the same time.
NOTE: Don’t set your frame rate to less than 5. While testing, I set my USB camera to -f 1 and discovered in the logs that the value was being pushed up (or “coerced” in video4linux speak) to 5. Seems like Linux doesn’t like frame rates that low.
Troubleshooting Tip 2:
Switch the camera to another USB port.
This shouldn’t matter, but apparently it can make a difference. Follow this procedure:
Boot your PI, confirm that the service didn’t load properly.
Move the USB camera to another port while the PI is still on.
Reboot your PI.
Check the service status.
Troubleshooting Tip 3:
Change the service’s restart delay.
By editing webcamd2.service you can change the delay before the service controller tries to restart a failing service.
sudo nano /etc/systemd/system/webcamd2.service
Change the RestartSec setting to 3, instead of 1, which is the default.
RestartSec=3
UPDATE February 27, 2021:
Added new services troubleshooting section, and updated the camera configuration section with comments about limiting resolution and frame rates.
UPDATE February 11, 2021:
Added a new troubleshooting section with information about confirming the camera set up and configuring cameras without serial numbers.
UPDATE February 7, 2021:
TL;DR:
Because of issues with HTML and Unicode, the code fragments in the instructions below had curly quotes (“) instead of straight quotes ("). Anyone that copied text off this page was unknowingly pasting in curly quotes that caused the Linux configuration files to not work. I’ve gone through and updated all the code sections and confirmed that everything works in Octopi 0.18.
The full story (for those who are curious):
A couple of weeks ago this post started getting a flurry of comments and questions, seemingly related to the instructions below not working when users updated to Octopi 0.18. The most common complaint was that only one camera (typically the PI cam) would work, while the USB camera didn’t connect.
To investigate why Octopi 0.18 didn’t work as expected, I took a spare Raspberry PI and installed a fresh copy of Octopi 0.18. Octoprint 1.5.2 worked correctly, as did a spare Raspberry PI camera module I have.
I followed my own instructions to connect a spare USB camera — I apparently have a lot of spare parts — and it didn’t work. The webcamd2 service I had created tried over and over to connect to the USB camera but failed. For a couple of hours I went down various rabbit holes, reading through comments, trying various approaches and learning more about the vagaries of Linux configuration. At one point, I even compared configuration files from Octopi 0.17 and 0.18, looking for a bug.
After ruling out issues with all the other configuration files I had created or edited, I was left with just one: the 99-usb.rules file. That’s how you tell the USB system about your USB camera and set up a symlink/alias to the camera. The alias/symlink is supposed to show up under /dev with whatever name you gave in your rules file. I had called my USB camera TestCam, but there was no entry under /dev.
I checked my working Octopi 0.17 build and sure enough, I saw a symlinked entry under the /dev directory. When I compared the two 99-usb.rules files from my Octopi 0.17 and 0.18 installations, I saw what was going on. The Octopi 0.18 rules files had curly quotes (“) instead of standard straight quotes ("). Curly quotes — also known as “smart” quotes — are fancy quotes used in word processors and webpages, but they don’t belong in text-only Linux configuration files. Putting curly quotes in configuration files is like putting diesel in a gasoline engine. It don’t work.
The only text I had copied and pasted from this blog entry had been for the usb rules file. And, when I checked, I saw that the usb rules text in the post had curly quotes in it. Once I edited 99-usb.rules, replaced the stupid smart quotes with regular ASCII straight quotes and rebooted, the USB camera showed up under /dev, webcam2 service was able to find it and start up, and the camera worked correctly. I then went through all the code sections in this blog post and ensured that none contained curly quotes.
113 comments
Comments are closed. These were left on the previous version of this site. Questions? Get in touch.
Thanks for this detailed explanation! However, I get no response when connecting to my Logitech C925e on :8081. I've double-checked all of the changes, and they're OK.
I notice that the green light on the camera only flashes once when I plug it into the Pi, as opposed to two flashes when I plug it into my PC. But when I run lsusb, I get "Bus 001 Device 003: ID 046d:085b Logitech, Inc.", so I guess it's connected.
In dmesg I get this series of messages; other searches seem to suggest that these aren't a problem, but do you have any ideas?
Either way, thanks for getting all this info together; it's amazing that this info isn't available (as far as I can tell) anywhere else.
[ 4.455920] uvcvideo: Found UVC 1.00 device Logitech Webcam C925e (046d:085b)
[ 4.467913] uvcvideo 1-1.1:1.0: Entity type for entity Processing 3 was not initialized!
[ 4.467932] uvcvideo 1-1.1:1.0: Entity type for entity Extension 6 was not initialized!
[ 4.467946] uvcvideo 1-1.1:1.0: Entity type for entity Extension 12 was not initialized!
[ 4.467961] uvcvideo 1-1.1:1.0: Entity type for entity Camera 1 was not initialized!
[ 4.467974] uvcvideo 1-1.1:1.0: Entity type for entity Extension 8 was not initialized!
[ 4.467988] uvcvideo 1-1.1:1.0: Entity type for entity Extension 9 was not initialized!
[ 4.468001] uvcvideo 1-1.1:1.0: Entity type for entity Extension 10 was not initialized!
[ 4.468015] uvcvideo 1-1.1:1.0: Entity type for entity Extension 11 was not initialized!
[ 4.468387] input: Logitech Webcam C925e as /devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.1/1-1.1:1.0/input/input0
[ 4.468625] usbcore: registered new interface driver uvcvideo
I had similar issues when working through getting both cameras set up. There are a few things I would try:
1. I know you double-checked everything, but check again. More than once I had an errant space or semicolon make its way into the scripts which made them not work correctly.
2. Try lowering the resolution of your webcam to 640x480. It just might be set to something that's making it choke.
3. Try getting the webcam to work by itself, without the PI cam.
4. See if you can successfully switch the PI cam to a different port.
5. Reboot between changes.
Hope one of those helps!
A related post at https://community.octoprint.org/t/how-can-i-configure-dual-cameras-1-pi-camera-and-1-usb-camera-on-a-dual-printer-setup/694/14 suggests the need to add the following two lines to crontab (with different port numbers). Do you think this step is necessary?
@reboot /home/pi/mjpg-streamer/mjpg_streamer -i "/home/pi/mjpg-streamer/input_raspicam.so -x 1024 -y 768 -mm matrix -fps 3" -o "/home/pi/mjpg-streamer/output_http.so -w ./www -p 8801"
@reboot /home/pi/mjpg-streamer/mjpg_streamer -i "/home/pi/mjpg-streamer/input_uvc.so -f 15 -r 1280x720" -o "/home/pi/mjpg-streamer/output_http.so -w ./www -p 8800"
I don't think this step is necessary, but it's probably a nice to have. Whenever I was working on getting the cameras to work, I had to reboot often.
Thanks for your replies, Federico!
The issue i am seeing is that when i open up webcamd it doesn't show me:
add video device into options
options=”$options -d /dev/$device”
I wound up skipping this and everything else was able to be edited. The pi cam works on the instance it should, but the usb camera doesn't.
I have a question in step 6 backend webcam
do I need to replace the entry or should there be backend webcam and backend webcam2?
when I got finished I was not able to connect to the PI getting a network error.
I was able to see in a web browser both cameras.
not sure what I did wrong
Hi David.
You should create a new entry for "webcam2", leaving the "webcam" untouched. Here are the two entries in my haproxy.cfg file:
backend webcam
reqrep ^([^\ :]*)\ /webcam/(.*) \1\ /\2
server webcam1 127.0.0.1:8080
errorfile 503 /etc/haproxy/errors/503-no-webcam.http
backend webcam2
reqrep ^([^\ :]*)\ /webcam2/(.*) \1\ /\2
server webcam1 127.0.0.1:8081
errorfile 503 /etc/haproxy/errors/503-no-webcam.http
I did everything you said, but it didn't work, I'm getting this error when I do "systemctl status webcamd2.service"
● webcamd2.service - the OctoPi webcam daemon with the user specified config
Loaded: loaded (/etc/systemd/system/webcamd2.service; enabled; vendor preset: enabled)
Active: failed (Result: start-limit-hit) since Mon 2021-01-18 18:49:52 GMT; 16min ago
Process: 593 ExecStart=/root/bin/webcamd2 (code=exited, status=0/SUCCESS)
Jan 18 18:49:52 octopi systemd[1]: webcamd2.service: Service RestartSec=100ms expired, scheduling restart.
Jan 18 18:49:52 octopi systemd[1]: webcamd2.service: Scheduled restart job, restart counter is at 5.
Jan 18 18:49:52 octopi systemd[1]: Stopped the OctoPi webcam daemon with the user specified config.
Jan 18 18:49:52 octopi systemd[1]: webcamd2.service: Start request repeated too quickly.
Jan 18 18:49:52 octopi systemd[1]: webcamd2.service: Failed with result 'start-limit-hit'.
Jan 18 18:49:52 octopi systemd[1]: Failed to start the OctoPi webcam daemon with the user specified config.
Ayyyyyyyyyyyyyyyyyyyyyyyyyyyy it worked!!!!!!!!!
TYSM
(I had to remove the -f parameter on the webcamd2, after that it worked :p)
Glad you got it working, Elias!
Question for you... did you remove the "-f" parameter from octopi2.txt? What kind of camera is it?
In my case 2 cameras (pi + USB) are not working together.
I can see that webcamd2.service filed to start.
If I stop webcamd.service and start webcamd2 and switch to USB but still using port 8080.
Of Course I can start both streams manually with mjpeg_streamer with correct ports setting.
After long research I've found problem in webcamd/webcamd2 script.
When settings from octopi.txt are imported to array looks like every space/" " is recognized as end of string so
camera_http_options=”-p 8080”
just send "-p" and in this case both services try to put stream on the same port.
it can be observed when ./webcamd
I have just base knowledge of linux base systems but maybe someone can repair it.
PS sorry for my bad english...
I have found another problem
Hi m3iaz!
Your English is great. :D Thank you for the information.
The settings I listed in the post work for me, so I'd like to figure out why you're having problems. Ex: When I go to http://octopi.local:8080/ and http://octopi.local:8081/ on my local network, I can see images from both cameras.
So, I have couple of questions for you to see if we can figure out what's going on:
1. Are you using Octopi 0.17?
2. Did you create a new octopi2.txt file?
3. Are you copying and pasting values from the blog post into your octopi.txt and webcamd.service files, or are you typing them in directly when you edit the files? Sometimes copying and pasting causes strange errors because invisible characters get copied over.
Hi federico
I did it in all possible ways.
At the end, due to problem with raspi cam (made a lot of test with connected/unconnected and at the end I flip flat cable...), I've also reinstall Octoprint in total.
As USB it is connected endoscope camera which is found as 2 devices: Video1 and Video2. SN was 0 so I had to use /dev/video1 instead of Your device.
I have found that ANY fault done in configuration files put all in default where raspi camera only worked.
My final solution
octopi.txt - USB camera with pointed -d /device/video1 @8080
octopi2.txt - raspi @8081
webcamd - I just add port no in script next to final camera type recognition.
options=”$options -d /dev/$device”
-----------------------------------------------------------------------
function startRaspi {
logger -s "Starting Raspberry Pi camera"
runMjpgStreamer "$MJPGSTREAMER_INPUT_RASPICAM $camera_raspi_options 8081"
}
}
cfg_files+=/boot/octopi2.txt
all other points from Your solution
I believe there is more clean way to add port no directly from octopi.txt than what I did.
Anyway in my place there is an sentence: "if something is stupid but working means that it is NOT stupid"...
Thank you for listing your solution, m3iaz!
can You please clean a bit my last post? I used some markers to made it a bit more clear but it looks like some custom bbcode made bad job...
Unfortunately, I'm not able to edit your post.
This guide is great! Everything worked as it's written except I had to go back to my original octopi.txt and set "camera=”auto”" to "camera=”raspi”".
Good job!
Well, everything was working fine until I disconnected it. I'm not sure why it work and then suddenly quit. The "raspi" camera is still working fine on port 8080 but the USB endoscope seems to be having issues.
Here is my webcamd2 log:
pi@octopi:~ $ systemctl status webcamd2.service
● webcamd2.service - the OctoPi webcam daemon with the user specified config
Loaded: loaded (/etc/systemd/system/webcamd2.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2021-01-24 21:29:52 GMT; 2min 30s ago
Process: 303 ExecStart=/root/bin/webcamd2 (code=exited, status=0/SUCCESS)
Main PID: 411 (mjpg_streamer)
Tasks: 23 (limit: 2077)
Memory: 3.1M
CGroup: /system.slice/webcamd2.service
└─411 ./mjpg_streamer -o output_http.so -w ./www-octopi -p 8081 -i input_uvc.so -r 640x480 -f 10
Jan 24 21:29:51 octopi mjpg_streamer[411]: MJPG-streamer [411]: commands.............: enabled
Jan 24 21:29:51 octopi mjpg_streamer[411]: MJPG-streamer [411]: starting input plugin input_uvc.so
Jan 24 21:29:51 octopi mjpg_streamer[411]: MJPG-streamer [411]: starting output plugin: output_http.so (ID: 00)
Jan 24 21:29:52 octopi webcamd2[303]: Done bring up all configured video device
Jan 24 21:29:52 octopi webcamd2[303]: Goodbye...
Jan 24 21:29:52 octopi systemd[1]: Started the OctoPi webcam daemon with the user specified config.
Jan 24 21:29:58 octopi webcamd2[303]: i: select() timeout
Jan 24 21:29:58 octopi webcamd2[303]: i: cleaning up resources allocated by input thread
Jan 24 21:29:58 octopi mjpg_streamer[411]: MJPG-streamer [411]: select() timeout
Jan 24 21:29:58 octopi mjpg_streamer[411]: MJPG-streamer [411]: cleaning up resources allocated by input thread
Nothing stands out to me as being a problem.
Here is my octopi2.txt file
camera="usb"
camera_usb_options=”-d /dev/Nozzlecam -r 640x480 -f 10”
camera_http_webroot="./www-octopi"
camera_http_options="-p 8081"
Have any advice or other things I could look at to troubleshoot?
Hi Jeremy,
Looking at your log, nothing comes to mind. However, I just noticed that you're connecting an endoscope like m3iaz in the comments below.
He ended up having to put his endoscope first (via octopi.txt) and his raspi cam second (in octopi2.txt). I don't know why that was necessary for him, but perhaps his comments would be helpful to you.
i followed all the sets now i cant access the webend of OctoPi. I can still SHH in, any ideas?
Happened to me. I've been messing with this stuff for days. I think its safe to say this process of now dated as Octoprint updates has broken it.
Hi Jeremy,
Like I asked David, can you answer a few questions so that I can update the blog post?
1. What version of OctoPi are you running? I see that version 0.18 came out recently, which I haven't installed yet. I'm still running 0.17
2. What version of OctoPrint are you running? I'm running 1.5.3.
3. When you say "happened to me", what do you mean exactly?
Both of the cameras I have connected to my Pi are working correctly, so I'm looking for configuration differences that would account for the issues that people are experiencing.
I just upgraded to OctoPi 18 last night but when trying your guide for the first time using 17 (not sure the version of Octoprint) I lost the ability to access the GUi altogether even though I could still access the Pi via SSH.
I'm going to assume it was something I did incorrectly involving the haproxy.cfg.
I tried using this guide with Octopi 18 last night and tried setting up the usb endoscope first (using octopi.txt) but when the raspi cam is plugged in neither cams work. When I just have the USB endoscope plugged in neither work.
I haven't done any troubleshooting on the latest attempt yet as it was getting late.
I have been reading all the comments from Chris's latest video and did try adding ATTR{index}==0 to the USB-99 rules file thinking it may help but obviously it did not in my case.
It seems like lots of people in the comments are also having problems with it either not working or webcam services not always starting correctly.
For now I'm just going to run my USB endoscope on a completely separate Pi until a better and more reliable option is available....unless you have a better option?
I meant to say when I have both cameras plugged in neither work. But when I have just the USB endoscope it works.
Thank you, Jeremy. This is very helpful.
I'll set some time aside this weekend and see if I can replicate what people are seeing and then update the post.
Sounds good. For what it's worth I found your guide to be the easiest to follow and the fact you wrote it while explaining what each step does was very helpful with learning how this stuff works.
Also, thanks for getting back to me. I still can't believe that I had both cameras working at one time and then they only stopped because I had to unplug one to tidy up the cables.
Hi David,
So that I can investigate and update the blog post, I have a few questions for you:
1. What version of OctoPi are you running? I see that version 0.18 came out recently, which I haven't installed yet.
2. What version of OctoPrint are you running? I'm running 1.5.3.
3. When you say that you can't access the webend of OctoPi, do you mean OctoPi or OctoPrint?
I'm getting the same problem, have you managed to sort it out?
God damn me!!!
found out what was wrong.
Inside the Haproxy file.
use_backend webcam2 if { path_beg /webcam2/ }It's USE
not USB
why am I stupid? IDK.
We all make mistakes like that! The important thing is that you caught it.
I just wanted to let you know that your steps were flawless. Thanks! I'm using this with the multicam plugin and it works great.
Thank you for the feedback, Andrew! Out of curiosity, are you running Octopi 0.17?
Hello im new to all this tbh but im having some issues and i think it might be related to octopi 0.18. i follow these steps and double checked everything. cant get both streams to work.
Hello, thanks for the detailed instructions!, i have octopi 0.17 and unfortunately it's not corking for me, the original pi webcam continues to work, but the C920 I'm trying to add does not work.. it seems like there might be an issue on starting the port on 8081, cause if i go to the 8080 port it works, but the 8081 port is unresponsive... I have checked the configs twice and I think i'm following to the step but not sure what i'm lacking.
one interesting thing i noticed is that my original octopi.txt file did not have an entry with
camera="auto"
or
camera="raspi"
to be changed, so i just added the entry and used the parameters as indicated....
Hi Gabriel
When you say the C920 works on port 8080, but not 8081, is the PI cam also connected both times? And, how are you switching the port?
Regarding the camera property in octopi.txt, that makes sense. Those properties are set when you configure Octopi using a script.
And, if you didn't use the config script, the properties won't be there.
My apologies, Federico, what i meant is that the raspberry cam is still working, but the logitech c920 is not. i can share the files if you want to take a look?
thanks!
Gabe
I sent you an email so that you can share the files with me. Let's see if I can help.
BTW, iI forgot to mention, i get to the step 4 no issues, i see the device listed under /dev
it might be an issue on starting the service:
> sudo systemctl status webcamd2
● webcamd2.service - the OctoPi webcam daemon with the user specified config
Loaded: loaded (/etc/systemd/system/webcamd2.service; enabled; vendor preset: enabled)
Active: failed (Result: start-limit-hit) since Sun 2021-02-21 13:58:28 CST; 22h ago
Process: 598 ExecStart=/root/bin/webcamd2 (code=exited, status=0/SUCCESS)
Feb 21 13:58:28 octopi systemd[1]: webcamd2.service: Service RestartSec=100ms expired, scheduling restart.
Feb 21 13:58:28 octopi systemd[1]: webcamd2.service: Scheduled restart job, restart counter is at 5.
Feb 21 13:58:28 octopi systemd[1]: Stopped the OctoPi webcam daemon with the user specified config.
Feb 21 13:58:28 octopi systemd[1]: webcamd2.service: Start request repeated too quickly.
Feb 21 13:58:28 octopi systemd[1]: webcamd2.service: Failed with result 'start-limit-hit'.
Feb 21 13:58:28 octopi systemd[1]: Failed to start the OctoPi webcam daemon with the user specified config.
working now! it seemed like the service was not starting for some reason.. i dunno why!
Oh, good! Yeah...I had the same experience and it's very unsatisfying to not know why it worked.
Oh, good! Yeah...I had the same experience and it's very unsatisfying to not know why it worked.
Incredibly well written and worked flawlessly to set up a cheap endoscope for me using OctoPrint 0.18. Thank you so much!
Thanks for the feedback, Kyle! I really appreciate it and am glad you got it working. 😀
Boss, could you explain me why sometimes my usb camera changed video1 to video2 or even video 3 without usb port change?. Of course while Im not using my printer I switch off pi.
I'm not 100% certain, but my understanding is that the order in which devices and ports are visible to linux at startup is not guaranteed. So, whichever usb camera is "sees" first will be assigned to whichever usb port it "sees" first.
So we cannot assign it permamently....
No, we can't. However, video for linux (v4l), which is the process/system that the cameras run on, does give them permanent IDs.
Problem is that the octopi scripts don't know how to read those values. This is why we set up those simlinks in 99-USB using device and vendor IDs.
Ok lets say that for me does not matter which camera will be first (pi or usb) but I need to make it very reliable. Currently, one time, pi can wake up with both cameras actived but after restart, only pi camera is available (I have led indication on usb camera so its easy to check that it works or not). Maybe usb cable is damaged... need to replace. Anyway Thank you for this tutorial - its very useful
I share your frustration with video for linux (v4l) -- which is the system that manages the cameras. I've experienced these kinds of issues as well.
One possible solution is using "static" paths to cameras that v4l creates. When you attach a v4l device to a PI, v4l creates entries under
/dev/v4l/by-path. I tried using those paths, as they are unchanging, even if you move a camera to a different USB port. Unfortunately, the octopi scripts that manage camera connections don't work in the non-standard/dev/videoXpaths.Thank you for this guide. I got it working with octoprint version 1.5.3 and octopi version 0.17.0 and a cheap endoscope off of amazon. Weirdly I had to edit /etc/udev/rules.d/99-com.rules instead of 99-usb.rules. But following your instructions worked perfectly.
One hiccup I had was when I put the micro usb that connects to my printer from the pi on the other usb 3.0 it stopped recognizing the hub my endoscope was on. Which was another oddity, it seems to require a hub to be recognized.
This is a terrific tutiorial, thank you so much! So, following your steps I was able to get a webcam up and running, and can see it at :8081, but I can't figure out how to get octoprint to use this usb camera instead of the picam. How can I get this to be the "main" camera? Is there a way to use this cam to create the timelapses?? Can you create a timelapse from both cams??
Thank you and congrats on getting the cameras working. :D
To make the usb cam the main webcam, either change the "Webcam" Stream URL under Settings: Features: Webcam & Timelapse, or install the MultiCam Octoprint plugin. (https://plugins.octoprint.org/plugins/multicam/)
You can configure which camera is used for timelapses under the same config tab, but you can only make timelapses from one camera at a time.
Amazing, thanks again!
Just in case anyone else is a little confused after this, the url to add to the multicam extension would be: http://192.168.1.72:8081/?action=stream.
Federico, much appreciated, truly helpful and well done!!
👍🏼😀
Thank you for this! I was following the video you mentioned, he does have a few of them, and I found it rather frustrating having to pause and rewind at each step. I found your instructions though and they worked perfectly!
I did get tied up at one part, simply because I wasn't using my critical thinking skills lol but on the steps outlining the adjustments that needed to be made to the octopi.txt and octopi2.txt files, it was never specified to uncomment the camera="raspi" and camera="usb" lines even though we were directed to change them, sooooo I didn't and I broke it. It was a silly mistake on my part, and a very easy thing to assume to do. But after going back through the steps I figured it out and it all looks great now! I was able to adjust the resolution of the pi cam as well and they're both perfect.
Very well written and excellent help in the comments! Thank you!
Thank you for the feedback, Thomas. Good suggestion. I added a comment about making sure the camera line is uncommented.
Absolutely amazing tutorial... Thank you...
I did have one problem at first and couldn't access the USB cam due to me putting camera_http_options="-r 8080" in octopi.txt once this was change to camera_http_options="-p 8080" it works great. Even better with mulitcam.
For all people that are having problems check and recheck all the edited lines that have been done.
Thanks Richard. I'm glad you found the tutorial useful. And thank you for sharing your experience. As you saw, configuration files are tricky and putting a "-r" flag where a "-p" flag should go will break everything.
A quick question, if i wanted to revert back to just the USB cam.. what would be the procedure? Would i reverse the tutorial?
The very simplest way is to disconnect the Raspberry PI Camera from your RPI, and removing the RaspiCam entry from Octoprint's Multicam plugin and restart your PI.
The scripts you created using the tutorial will still run, but since the RaspiCam is no longer connected, it will get ignored.
Don't set the FPS flag for the sub cam, remove that option all together.
It disables mjpeg streaming from the camera and crucifies frame rate. TBH i have no clue why every article says to use it when they should say remove it. https://github.com/jacksonliam/mjpg-streamer/blob/master/mjpg-streamer-experimental/plugins/input_uvc/README.md
Not sure what to tell you, but I just tested my octopi install by setting the frame rate on the USB camera to various values and removing it completely. mjpeg was not disabled with any setting.
Also, the -f flag doesn't "crucify" frame rate -- it lowers it from a maximum, in order to lower CPU usage -- as it's designed to do.
That said, CPU usage was only slightly lower when I set the framerate to 10 fps compared to not having the flag on at all.
Federico, thank you very much. It is brilliant tutorial and how to. I have 2 printers and only one OctoPrint, but now I have one camera (RaspiCam) for one printer and another camera (USB) for second printer. It is quite perfect. Zdenek Hornych
You're welcome Zdeněk! I'm glad you found it useful. Enjoy your two printers. I'm jealous! 😀
Hello,
I just followed your tutorial to manage 2 webcams. I have a Picam V2 and a logitech C922 Pro USB installed on a Raspberry Pi3B +, Octoprint 1.6.1 and Octopi 0.18.0 + Octodash, and SUPER everything worked the first time ! Super Tuto and that allowed me to understand a lot more. At TOP !
Jean luc.G FRANCE
Merci, Jean Luc! I've thought about using Octodash because it's so cool, but never got around to it. Glad you found the tutorial useful!
I installed Octodash with a 7 "Raspberry screen, more expensive but it's easier to install, less conflict to manage.
If you are interested, I will indicate 2 links to watch: https://maker-tutorials.com/en/official-raspberry-pi-7-touch-screen-lcd-display-assembly-guide-install-and-tips/
+ https://github.com/UnchartedBull/OctoDash + a link on my GoogleDrive : https://drive.google.com/file/d/1YeUh0NmcKM_7a-j6ApAg_dRrIAvQs4R1/view?usp=sharing
to download the tuto I followed but it is French ! and operation of the first blow.
I'll take a look, Jean luc. Thank you!
Fantastic instructions, which i believe I have followed perfectly but unfortunately still not working.
I have an issue where when I
systemctl status webcamd2.service
it shows the HTTP TCP Port to be 8080 and I have gone back and checked everything and cannot find where I have made the mistake.
Any help would be greatly appreciated.
After several reboots and checking everything several times (but not changing anything) it has started to work.
WOW it is exactly what I wanted.
Now for some reason I cannot get the USB camera to work in the MultiCam plugin for OctoPrint.
Any tips or tricks?
I've had that experience too: changes only take effect after multiple reboots. I don't know why that's the case.
Regarding the MultiCam plugin...
First, confirm that you can view output from both cameras in a browser by visiting the stream URLs for your PI Cam and your USB camera. Then, you add the stream URLs to your MultiCam configuration. Here are my URL strings. If you don't have a local domain set up, you can use your PI's IP address:
http://octopi.local:8080/?action=stream
http://octopi.local:8081/?action=stream
Everything explained very nicely. Unfortunately, it doesn't work for me anyway. I did everything exactly as described. I even reinstalled octopi several times, unfortunately it still doesn't work.
What doesn't work, specifically? The PI cam, the USB cam?
Have you tried different troubleshooting steps? For example, do you see the symbolic link for your USB camera in the /dev directory? What happens when you visit the streaming webpage for your cameras? (ex: http://octopi.local:8081/?action=stream).
You need to methodically step through the tutorial, making sure that each step was successful before moving on to the next.
By the way, reinstalling octopi is not necessary. Once it's installed, reinstalling just makes you lose all your progress.
Ive follow this step by step twice and both times by Pi cam works ok but when i search for 8081 port it cannot see the NexiGo N660 camera.
The info i get from the system status is:
pi@octopi:~ $ systemctl status webcamd2.service
● webcamd2.service - the OctoPi webcam daemon with the user specified config
Loaded: loaded (/etc/systemd/system/webcamd2.service; enabled; vendor pre
Active: failed (Result: start-limit-hit) since Wed 2021-10-06 15:24:52 BS
Process: 583 ExecStart=/root/bin/webcamd2 (code=exited, status=0/SUCCESS)
Oct 06 15:24:52 octopi systemd[1]: webcamd2.service: Service RestartSec=100m
Oct 06 15:24:52 octopi systemd[1]: webcamd2.service: Scheduled restart job,
Oct 06 15:24:52 octopi systemd[1]: Stopped the OctoPi webcam daemon with the
Oct 06 15:24:52 octopi systemd[1]: webcamd2.service: Start request repeated
Oct 06 15:24:52 octopi systemd[1]: webcamd2.service: Failed with result 'sta
Oct 06 15:24:52 octopi systemd[1]: Failed to start the OctoPi webcam daemon
lines 1-11/11 (END)
● webcamd2.service - the OctoPi webcam daemon with the user specified config
Loaded: loaded (/etc/systemd/system/webcamd2.service; enabled; vendor preset: enabled)
Active: failed (Result: start-limit-hit) since Wed 2021-10-06 15:24:52 BST; 6min ago
Process: 583 ExecStart=/root/bin/webcamd2 (code=exited, status=0/SUCCESS)
Oct 06 15:24:52 octopi systemd[1]: webcamd2.service: Service RestartSec=100ms expired, scheduling restart.
Oct 06 15:24:52 octopi systemd[1]: webcamd2.service: Scheduled restart job, restart counter is at 5.
Oct 06 15:24:52 octopi systemd[1]: Stopped the OctoPi webcam daemon with the user specified config.
Oct 06 15:24:52 octopi systemd[1]: webcamd2.service: Start request repeated too quickly.
Oct 06 15:24:52 octopi systemd[1]: webcamd2.service: Failed with result 'start-limit-hit'.
Oct 06 15:24:52 octopi systemd[1]: Failed to start the OctoPi webcam daemon with the user specified config.
Do you see the symbolic link for your USB camera in the /dev directory? That needs to be working before the rest of it can work.
Fantastic! Your tutorial is amazing!!! Thx man you saved my day
Thank you!
Like you, I went through a tonne of Youtube videos to no avail. Followed your instructions, picam and C270 now doing as required. You absolute legend. Great write up and thank you very much
Yay! I'm glad the write up was so useful. :D
Thank you so much for this tutorial, ive got an issue though, I can no longer get my pi cam to turn on. The little red light is off and I'm not sure what caused it. I do have my endoscop camera working now though!
That sounds like a hardware issue, not software. Have you tried reseating the ribbon cable for the pi cam? Maybe it pulled out a bit while you were setting up everything.
Hi, everything is working for me but my stream URL does not work and the snapshot URL does. how do I fix this? So this overall does not let my camera work.
Thanks very much for these good instructions.
My borescope USB2.0 camera has no serialNumber, as stated here under troubleshooting removing serial entry worked.
Then webcamd2 service did not start (init_VideoIn failed), as stated above I powered my Pi3A+ down, switched USB cables in mini USB hub (Pi3A+ has only 1 USB interface by default) and powered again.
After that borescope camera works on port 8081 !!
Until now I used gstreamer pipeline on my OctoPi (https://forum.prusaprinters.org/forum/user-mods-octoprint-enclosures-nozzles/simple-nozzle-camera-borescope-holder-for-prusa-mini/#post-582439) and viewed it with vlc (tcp://octopi3ap:8887) on Linux, or vlc app on smartphone (the borescope camera provides detailed nozzle view).
So now both cameras are served with mjpg-streamer.
I hoped to have either both camera views shown in OctoPrint webgui, or have a toggle there to switch between both cameras ...
Congratulations Hermann! I'm glad to hear that you got your borescope camera working. To view both of my cameras in the OctoPi UI, I use the MultiCam plugin.
Thanks, I did that, and it works perfectly. See the animated .gif at end of this posting — cool:
https://forum.prusaprinters.org/forum/user-mods-octoprint-enclosures-nozzles/simple-nozzle-camera-borescope-holder-for-prusa-mini/#post-585166
Thanks Frederico, MultiCam worked nice, with only small default camera quirk. Find at bottom of that posting a nice (scaled to 50% size) peek screenrecorder animation. It shows switching between Raspberry v1 scene camera and borescope nozzle camera view by pressing on "RaspberrySceneCam" or "BorescopeNozzleCam" buttons (bottom right):
https://forum.prusaprinters.org/forum/user-mods-octoprint-enclosures-nozzles/simple-nozzle-camera-borescope-holder-for-prusa-mini/#post-585166
That's great! I'm glad it worked for you. And thank you for linking to my blog post on prusaprinters.org. 😀
Hi Frederico,
I added another borescope, and it has identical values to first borescope. After reboot the udev rule now selectes newly added camera, and not nozzle camera anymore. Find current udev rule and both camera dmesg entries here — any chance to get both matched and being able to toggle between 3 cameras in OctoPrint?
https://stamm-wilbrandt.de/en/forum/udev_borescope_identical.png
Hi Hermann. I looked into this, but didn't find a good solution. There is supposedly a way to map cameras to a specific USB port, so that you can differentiate between two cameras that either have the same serial number or no serial number. However, I wasn't able to get that working.
thank u very much . you did great job. Very clearly and very accuarately .
after spending a lot of days on this problem i mange to solved it succeeded thanks to you
thank a lot
Hi itzik,
I'm glad it worked for you!
I really tried everything now... Complete new system, all files new, checked everything a 100 times... My second won't startup!
This is the failure i got now:
● webcamd2.service - the OctoPi webcam daemon with the user specified config
Loaded: loaded (/etc/systemd/system/webcamd2.service; enabled; vendor preset: enabled)
Active: activating (start) since Wed 2022-03-16 14:24:04 CET; 1s ago
Cntrl PID: 12368 (webcamd2)
Tasks: 2 (limit: 3596)
CGroup: /system.slice/webcamd2.service
├─12368 /bin/bash /root/bin/webcamd2
└─12403 sleep 1
Mar 16 14:24:05 octopi mjpg_streamer[12402]: MJPG-streamer [12402]: Format............: JPEG
Mar 16 14:24:05 octopi mjpg_streamer[12402]: MJPG-streamer [12402]: TV-Norm...........: DEFAULT
Mar 16 14:24:05 octopi mjpg_streamer[12402]: MJPG-streamer [12402]: www-folder-path......: ./www-octopi/
Mar 16 14:24:05 octopi mjpg_streamer[12402]: MJPG-streamer [12402]: HTTP TCP port........: 8080
Mar 16 14:24:05 octopi mjpg_streamer[12402]: MJPG-streamer [12402]: HTTP Listen Address..: 127.0.0.1
Mar 16 14:24:05 octopi mjpg_streamer[12402]: MJPG-streamer [12402]: username:password....: disabled
Mar 16 14:24:05 octopi mjpg_streamer[12402]: MJPG-streamer [12402]: commands.............: disabled
Mar 16 14:24:05 octopi mjpg_streamer[12402]: MJPG-streamer [12402]: starting input plugin input_uvc.so
Mar 16 14:24:05 octopi mjpg_streamer[12402]: MJPG-streamer [12402]: starting output plugin: output_http.so (ID: 00)
Mar 16 14:24:05 octopi mjpg_streamer[12402]: MJPG-streamer [12402]: server_thread(): bind(8080) failed
Hi Max. What are the ports you have assigned to both cameras? In the instructions, I set camera 1 to port 8080 and camera 2 to port 8081. The output above shows an issue binding to port 8080. If you accidentally have both cameras bound to port 8080, then the second one won't work for sure.
Thank you for this amazing step by step tutorial. Really spectacular work. I have one issue though, tried searching through comments to see if there were similar ones, but couldnt find one, so here it goes.
I have Raspi cam and a cheap USB endoscope one. There seems to be about 50/50 chance the endscope will work after I boot up Pi. Any reason for this? It can be pretty annoying starting up a print and finding out that the endoscope doesnt work. Although Raspi cam works 100% of the time.
Hi Adam. I have experienced the same issue. It seems to happen more with cheap cameras that don't have serial numbers. Unfortunately, I haven't found a solution to the problem.
Man! I have to say to you thank you so much for helping out with this! I was pulling my hair out trying to get everything to work, in having the PiCam and my Logitech USB cam working. But then this bible of yours you've written just blew my pants off with working the first time. Thank you immensely!
Glad you found it useful!
Have an issue. After done everything I'm no longer able to connect to octoprint via octopi.local neighter ip. However I have octoeverywhere plugin instaled and there is no problem what so ever to conect to octoprint using this option. Where have I gone wrong? Pi version 0.18.0
I'm not sure what the cause of that would be. In my testing, while writing my post, I didn't experience any issues with bonjour discoverability. As far as I know, .local discoverability and video4linux setups are completely separate.
Hi Federico, have the same issue. Only difference is, I don't have octoeverywhere installed. I can reach the pi via ssh but cant access Octoprint via the webbrowser anymore. Could you figure out what the problem was?
Greetings Just wanted to say I followed your instructions here and everything worked perfectly! I was pulling my hair out trying to get two cameras to work, (and that means something if you knew how little hair I have....). But your method worked perfect! Thank you for sharing!
Thank you! I'm glad it worked for you.
it worked great! i modified it a bit since i don't have a raspberry cam but i do have usb camera, as of now it works but freezes i suspecting that it doesn't have enough power, if anyone could suggest the specs of a good raspberry pi power supply that would be great
Can this process be applied to Klipper on Raspberry Pi and MainsailOS?
Amazing explanation! Thank you so much.... but...
After checking absolutely everything, I got this:
I'm trying to get an endoscopy camera to run besides the raspi cam on my Octoprint setup.
I have a resolution in both of 640 and a Frame rate of 10.
Any ideas?
Thank you so much in advance!
pi@Ender3v2:/etc/systemd/system $ systemctl status webcamd2.service
● webcamd2.service - the OctoPi webcam daemon with the user specified config
Loaded: loaded (/etc/systemd/system/webcamd2.service; enabled; vendor preset: enabled)
Active: activating (start) since Mon 2022-08-01 02:12:53 EDT; 1s ago
Cntrl PID: 4856 (webcamd2)
Tasks: 2 (limit: 4915)
CGroup: /system.slice/webcamd2.service
├─4856 /bin/bash /root/bin/webcamd2
└─4881 sleep 1
Aug 01 02:12:53 Ender3v2 systemd[1]: Starting the OctoPi webcam daemon with the user specified config...
Aug 01 02:12:53 Ender3v2 root[4879]: Starting USB webcam
Aug 01 02:12:53 Ender3v2 mjpg_streamer[4880]: MJPG-streamer [4880]: starting application
Aug 01 02:12:53 Ender3v2 mjpg_streamer[4880]: MJPG-streamer [4880]: MJPG Streamer Version: git rev: 5554f42c352ecfa7edaec6f
Aug 01 02:12:53 Ender3v2 mjpg_streamer[4880]: MJPG-streamer [4880]: Using V4L2 device.: (null)
Aug 01 02:12:53 Ender3v2 mjpg_streamer[4880]: MJPG-streamer [4880]: Desired Resolution: 640 x 480
Aug 01 02:12:53 Ender3v2 mjpg_streamer[4880]: MJPG-streamer [4880]: Frames Per Second.: 10
Aug 01 02:12:53 Ender3v2 mjpg_streamer[4880]: MJPG-streamer [4880]: Format............: JPEG
Aug 01 02:12:53 Ender3v2 mjpg_streamer[4880]: MJPG-streamer [4880]: TV-Norm...........: DEFAULT
Aug 01 02:12:53 Ender3v2 mjpg_streamer[4880]: MJPG-streamer [4880]: init_VideoIn failed
lines 1-19/19 (END)
Hi, excellent breakdown and instruction, though im having an issue i hope you can help me with.
I keep getting a fail with my raspi hq cam
This is what im getting below-
pi@octopi:~ $ systemctl status webcamd2.service
● webcamd2.service - the OctoPi webcam daemon with the user specified config
Loaded: loaded (/etc/systemd/system/webcamd2.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) since Fri 2022-09-16 20:07:46 BST; 2s ago
Process: 5410 ExecStart=/root/bin/webcamd2 (code=exited, status=0/SUCCESS)
pi@octopi:~ $ systemctl status webcamd.service
● webcamd.service - the OctoPi webcam daemon with the user specified config
Loaded: loaded (/etc/systemd/system/webcamd.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Fri 2022-09-16 20:07:58 BST; 2s a
Process: 5496 ExecStart=/root/bin/webcamd (code=exited, status=203/EXEC)
pi@octopi:~ $
I got the 2 cameras working if I connect to the port just fine. I then added the multicam plugin and setup the second camera with /webcam2/?action=stream similar to how the raspi cam was showing. In the settings screen it shows fine but on my control screen when I click on the webcam nothing happens. any ideas on what i'm missing for multicam?
I checked in my Multicam setup to see how it was configured, and my cams are listed like this:
* http://octopi.local:8080/?action=stream
* http://octopi.local:8081/?action=stream
Make sure that you can view both streams in browser and to use that stream in the Multicam settings.
For those who had issues getting to octopi at all after following this, I think it has something to do with the octopi.txt modification. I had set camera_http_options="-p 8080" and had similar issues. When I just left #camera_http_options commented out it worked as expected.
This setup is working for me, but the USB webcam is pulling down the voltage and giving me undervoltage alarms. When I unplug the USB webcam both cameras fail to load. Is there a simple way to disable this USB webcam without backtracking all these changes?