Setting up multiple webcams in OctoPi the right way

Follow the instructions. You run ls /dev/v4l/by-id to find the ID of the camera, then put that in the file yourself - it doesn't put itself there.

Hi Charlie.
I did that previously but only the C920 showed, there was no mention of the C270 which is what is holding me up!!
Kev

This is what Shows up :-1:
OctoPrint version : 1.7.3
OctoPi version : 0.18.0

pi@octopi : ~ ** ls /dev/v4l/by-id **usb-046d_0825_6E9E6C90-video-index0** **usb-046d_0825_6E9E6C90-video-index1** **usb-046d_HD_Pro_Webcam_C920_EA8C33AF-video-index0** **usb-046d_HD_Pro_Webcam_C920_EA8C33AF-video-index1** **pi@octopi** : **~

I have plugged the C270 and the C920 in separately and both work but if I plug them in together I only get the feed from the C920

What would you suggest next Charlie?
Cheers
Kev

Hi.
Thanks, I set up two webcams very quickly and easily.
I want to make disable/enable video2.
How can I make the switch?
Thanks.

At first I had a huge number of problems trying to follow this guide. The reason is turned out was that the cheap web cams that I was using are simply not compatible. When I added the second webcam (an endoscope) it wouldn't start every time. Or sometimes it would start and the first webcam (a 1080p cheap one off amazon) would stall.

After having lots of issues, I eventually gave up on both webcams and changed them.

I now have a Logitech C922 as the bed camera, and an Usb Endoscope from AliExpress. The endoscope looks identical to the one I had problems with, but it behaves completely different in software. Have followed the instructions above and it all fired up with out any problems.

I've then gone on to configure the MultiCam plugin for OctoPrint, and the dash board plug in as well. I can now switch camera to my hearts content without issues.

If you are having problems getting this working, I'd suggest take a closer look at the hardware..

use this to find your web cams

ls /dev/v4l/by-id/

and this to list the supported formats.
v4l2-ctl --list-formats-ext --device /dev/v4l/by-id/usb-Generic_USB_Camera_200901010001-video-index0

if it doesn't list MJPG formats, your camera most likely won't work.

1 Like

If it lists YUYV you can add the -y option to the input parameter.

I'm having some real issues with this unfortunately.
I'm using 2x USB webcams so should be exactly as per your tutorial.

I went through the whole thing and didn't get any errors.
However, when it comes to testing the webcams, none of it works.

In OctoPrint, if I go to view the standard webcam that works when the URL is down as

/webcam/?action=stream

but not only does it not work in OctoPi if I change that to either the :8081/?action=stream (or even the 8080 equivalent), I can't access either webcams by typing in any version of the address in my browser.

Again, it works fine in octoprint but only with my first camera and only in octoprint with the address as standard.

Any ideas?

Thanks

Just to check, you need to have the IP address in there as well if you are using the port number, so http://192.168.1.158:8081/?action=stream. Port 8080 is, by default, not exposed to the outside world as it is run through Haproxy as /webcam/.

1 Like

Hi Charlie, thanks for the quick response.

Yep, that's with the IP address in there. So I've tried it like the following:
http://192.168.1.110:8080/?action=stream
as well as:
http://192.168.1.110:8081/?action=stream

But equally, http://192.168.1.110/webcam/?action=stream also brings up nothing.

Hey Charlie ive gotten both streams to run only issue im having is when needing to reboot I have to manually sudo webcamd2 restart to get the second camera stream started i dont have the spaghetti detective installed anyway i can have a script to start the webcamd2 when the system has been rebooted?

If you've ended up with a webcamd2, you haven't followed this guide.

Followed the guide nothing worked til the ha proxy on the back end still could get the stream to work until I copied the webcams service for the second camera hints webcamd2 followed guide to a t from a fresh install of octopi couldn’t get results so ended up using that route stated previously but thanks..

OMG the devil .......

Can't get the second camera to work on my second instance of octoprint. The first one is working, but the second one isn't.

First Camera: Logitech C270 (working)
Second Camera: Logitech QuickCam Pro for Notebooks (not working)

Under ls /dev/v4l/by-id it appears with the camera:
usb-046d_0991_39B69319-video-index0
usb-046d_0991_39B69319-video-index1

Not sure what else to do. Followed Chris Basement video previously on how to do multiple instances and cameras for each one.

We will probably need more information on what's not working and what you have tried already to help. It might be easier to keep discussion organised if you start your own topic for your problem.

I am not sure exactly what edits the Chris' Basement video gets you to make, so I'm not sure if this guide still works after that or not.

Hi, i've been plugging away at this trying to get my secondary camera to work, gone as far as to reimage a few times to see if i missed or messed something up. I'm running on a rPi4 Model B, and i'm using a logitech C922 webcam and some Sonix Technology webcam. I've followed the instructions to the T, and one time i got both of them to work, but then i restarted the pi and it was gone.

I've swapped things back and forth in terms of which one is the first and which one is the second, and they both work and output images when they're in the first slot, but not the second.

Here's my webcamd.log file, note that the select() timeout and cleaning up resources message doesn't pop up until after i try and view the output of the second camera. webcamd.log - Pastebin.com

Here's my config files: Octopi Config x2 - Pastebin.com.

My ls /dev/v4l/by-id is
usb-046d_C922_Pro_Stream_Webcam_E6DFA6AF-video-index0 usb-Sonix_Technology_Co.__Ltd._NexiGo_HD_Webcam_SN0001-video-index0
usb-046d_C922_Pro_Stream_Webcam_E6DFA6AF-video-index1 usb-Sonix_Technology_Co.__Ltd._NexiGo_HD_Webcam_SN0001-video-index1

Also did a systemctl status webcamd
pi@octopi:/boot/octopi.conf.d $ systemctl status webcamd
● webcamd.service - the OctoPi webcam daemon with the user specified config
Loaded: loaded (/etc/systemd/system/webcamd.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2022-08-03 05:53:14 BST; 14min ago
Process: 490 ExecStart=/root/bin/webcamd (code=exited, status=0/SUCCESS)
Tasks: 7 (limit: 4915)
CGroup: /system.slice/webcamd.service
β”œβ”€555 ./mjpg_streamer -o output_http.so -w ./www-octopi -n -p 8080 -i input_uvc.so -r 1920x1080 -f 30 -d /dev/video0
└─583 ./mjpg_streamer -o output_http.so -w ./www-octopi -n -p 8081 -i input_uvc.so -r 1920x1080 -f 60 -d /dev/video2

Aug 03 05:53:13 octopi mjpg_streamer[583]: MJPG-streamer [583]: www-folder-path......: ./www-octopi/
Aug 03 05:53:13 octopi mjpg_streamer[583]: MJPG-streamer [583]: HTTP TCP port........: 8081
Aug 03 05:53:13 octopi mjpg_streamer[583]: MJPG-streamer [583]: HTTP Listen Address..: (null)
Aug 03 05:53:13 octopi mjpg_streamer[583]: MJPG-streamer [583]: username:password....: disabled
Aug 03 05:53:13 octopi mjpg_streamer[583]: MJPG-streamer [583]: commands.............: disabled
Aug 03 05:53:13 octopi mjpg_streamer[583]: MJPG-streamer [583]: starting input plugin input_uvc.so
Aug 03 05:53:13 octopi mjpg_streamer[583]: MJPG-streamer [583]: starting output plugin: output_http.so (ID: 00)
Aug 03 05:53:14 octopi systemd[1]: Started the OctoPi webcam daemon with the user specified config.
Aug 03 05:53:19 octopi mjpg_streamer[583]: MJPG-streamer [583]: select() timeout
Aug 03 05:53:19 octopi mjpg_streamer[583]: MJPG-streamer [583]: cleaning up resources allocated by input thread

Not exactly sure what i'm doing or how to troubleshoot, linux isn't really my forte. Thanks in advance!

Edit: tried lowering the resolution on the second cam...and it works now, obviously it's not optimal (i'd rather have it at 1920x1080 instead of 640x480) but i'm not sure what else i can do to try and change it.

1 Like

Not working - gives me the USB cam feed but not the Pi camera port feed at all.

I plugged in a new USB camera to my OctoPi system, then installed the MultiCam plugin. Then I used this as a guide.

In /boot/octopi.txt I have

camera="raspi"

Before I put that in, there were no uncommented lines in that file. I listed /dev/v4l/b-id and found these two files:

usb-Sonix_Technology_Co.__Ltd._USB_Camera_SN0001-video-index0 usb-Sonix_Technology_Co.__Ltd._USB_Camera_SN0001-video-index1

In /boot/octopi.conf.d/webcam2.txt, I have:
camera="usb" camera_usb_options="-r 640x480 -f 10 -d /dev/v4l/by-id/<device long id>"usb-Sonix_Technology_Co.__Ltd._USB_Camera_SN0001-video-index0" camera_http_options="n -p 8081"

After editing both files I tried restarting the webcam service, but it just sat there, so I rebooted.

When I look under Plugins->MultiCam, it shows one webcam. I can't edit it at all or even copy the links it provides.

When I go to the Control tab, I see the view of the USB webcam.

I have tried various URLs. At /webcam/?option=stream I get the USB webcam. I've tried using ports 8080 and 8081 on the same system, including adding "?option=stream" on them, but they give me "site can't be reached" error in Chrome. (I'm using http and https.)

To summarize:

  • Configuration files are now as described.
  • Camera on the Pi camera port is missing - no indication it exists
  • USB camera is now default webcam
  • Tried the URLs that supposedly will give me a stream and Chrome finds nothing at those locations.

Edit/Addition:
Once I set this up, I couldn't see the original Pi webcam. I had to remove the plugin and remove the USB camera to do that. Now I'm finding that, basically, the USB camera always takes over, so if I put in a USB cam and reboot, that's what I get. The Pi camera interface is ignored. Not put as a 2nd cam, but ignored.

this isn't right, should be

camera="usb" 
camera_usb_options="-r 640x480 -f 10 -d /dev/v4l/by-id/usb-Sonix_Technology_Co.__Ltd._USB_Camera_SN0001-video-index0"

or

camera="usb" 
camera_usb_options="-r 640x480 -f 10 -d /dev/v4l/by-id/usb-Sonix_Technology_Co.__Ltd._USB_Camera_SN0001-video-index1"

@jneilliii : I'm having problems due to editing. Due to my window width when I wrote that, I didn't realize that it put

camera="usb" camera_usb_options="-r 640x480 -f 10 -d /dev/v4l/by-id/<device long id>"usb-Sonix_Technology_Co.__Ltd._USB_Camera_SN0001-video-index0"

as one long line. I have it in my file as:
camera="usb"
on one line and:
camera_usb_options="-r 640x480 -f 10 -d /dev/v4l/by-id/<device long id>"usb-Sonix_Technology_Co.__Ltd._USB_Camera_SN0001-video-index0"

on a second line. I can't see a way, in this editor, to specifically put them on different lines. I hit between them and it doesn't show. But I do see that, without realizing it, I left something in there that I shouldn't.

Still, could you clarify that you have both entries on separate lines? Just being sure I'm reading it correctly!

The issue is not about having them on the same lines, it's that you left '<device long id">' in the entry.

- camera_usb_options="-r 640x480 -f 10 -d /dev/v4l/by-id/<device long id>"usb-Sonix_Technology_Co.__Ltd._USB_Camera_SN0001-video-index0"
+ camera_usb_options="-r 640x480 -f 10 -d /dev/v4l/by-id/usb-Sonix_Technology_Co.__Ltd._USB_Camera_SN0001-video-index0"