Updated: Apr 24, 2019
Multiple webcams are possible with OctoPrint and there are a number of reasons to have multiple cams on your prints. I personally recommend an endoscopic camera as it gives you remarkable insight to why prints don't adhere or why they fail. It gives you the ability to adjust flow and feed rate to help your prints mid stream. This article however is going to cover only the installation of multiple webcams not specifically any type of webcam. You can apply it to virtually any number of cameras.
Before you dive into the attempting to set this up you should be aware of some challenges for multiple webcams.
USB Bus Capacity
These three things are going to greatly impact your ability to run multiple cameras. Lets dive right into them.
If you have OctoPrint installed on a traditional PC then you're way ahead of the game and can likely just skip to the USB Bus capacity section. If you like many others are running a Raspberry PI for OctoPrint then you can likely still run a couple of web cams but the odds are stacked against you. Most modern webcams (usb type) tend to have some encoding features on them already. This is called USB Video Class or UVC. In this case the web cam does a lot of the heavy lifting and it is widely supported for Linux, Mac and Windows. Other web cams without it are going to require far more CPU from your PI. Choosing UVC webcams will allow you to have multiple cams on your Raspberry PI, maybe...
The next challenge you are going to have if you're using a Raspberry PI is power. The Pi and the USB ports will likely not support 2 active web cams. I was able to successfully get 2 of them running but they ran into power drops all the time. If you run the command "vcgencmd get_throttled" and get a non zero return code you're likely running into power drops. Again hope is not lost because a good (and finding one was hard) USB hub can power the device completely. Cheap hubs don't cut it. I was able to use the RPi Powered USB Hubs list to find one that worked well.
USB Bus Capacity
Lastly you need to be concerned about the overall capacity of the USB bus for these webcams. On a traditional PC you're slightly better off because chances are you have 2 USB hubs internally. Not always the case but if you have USB 3.0 you'll get much better bandwidth. Otherwise you may max out at 2 webcams. Under Linux you'll receive a no space left on device error if you use up all the bandwidth on the bus when setting up the second cam.
This guide presumes you're running linux in some fashion. This guide could be applied for Mac Or Windows Octoprint installs but I wont cover them in this guide.
Once you have two cams plugged in you'll noticed at least on linux that you now have a
These are your respecitve webcams 1 and 2. If you have a 3rd you'll see this increase for the number of cameras installed in the system. It should be noted that these are not always assigned the way you want them to be. My previous primary camera became the second camera and that will affect the way OctoPrint operates. Once you the second camera go into OctoPrint and confirm which camera is your default camera. You'll be able to change this inside OctoPrint later if you find they are assigned to the wrong camera.
Once you know now which camera is which we need to get the second camera up and running. Before we start to setup the configuration files you'll need to test the cam. Move to the /root/bin directory and you'll find webcamd.
You now need to copy that file to webcam2d. Then you need to copy a file in /boot/ which will contain the configuration settings.
Next you're going to edit the newly created octopi-cam2.txt file
Locate the camera_usb_options line in the file and point this to your second webcam. The one that is not working yet. This will be the /dev/video2