Setting up multiple webcams in OctoPi the right way

octopi:~$ systemctl status webcamd

e[?1he=
● webcamd.service - the OctoPi webcam daemon with the user specified confige[m
   Loaded: loaded (/etc/systemd/system/webcamd.service; enabled; vendor preset: e[m
   Active: inactive (dead) since Fri 2021-07-30 06:20:00 EDT; 2h 0min agoe[m
  Process: 709 ExecStart=/root/bin/webcamd (code=exited, status=0/SUCCESS)e[m
e[m
Jul 30 06:19:51 octopi mjpg_streamer[755]: MJPG-streamer [755]: www-folder-path.e[m
Jul 30 06:19:51 octopi mjpg_streamer[755]: MJPG-streamer [755]: HTTP TCP port...e[m
Jul 30 06:19:51 octopi mjpg_streamer[755]: MJPG-streamer [755]: HTTP Listen Addre[m
Jul 30 06:19:51 octopi mjpg_streamer[755]: MJPG-streamer [755]: username:passwore[m
Jul 30 06:19:51 octopi mjpg_streamer[755]: MJPG-streamer [755]: commands........e[m
Jul 30 06:19:51 octopi mjpg_streamer[755]: MJPG-streamer [755]: starting input pe[m
Jul 30 06:19:51 octopi mjpg_streamer[755]: MJPG-streamer [755]: starting output e[m
Jul 30 06:19:51 octopi mjpg_streamer[755]: MJPG-streamer [755]: Starting Camerae[m
Jul 30 06:20:00 octopi systemd[1]: webcamd.service: Succeeded.e[m
Jul 30 06:20:00 octopi systemd[1]: Stopped the OctoPi webcam daemon with the usee[m
e[7mlines 1-15/15 (END)e[me[K

Do you have The Spaghetti Detective plugin installed? If it's premium webcam option is enabled it will stop the webcamd service like that.

1 Like

Turning off premium, seems to have fixed it. THANK YOU!

I've added a note to the guide about TSD premium, since there's been a few people confused by this.

I'm trying to configure a raspi cam and a USB cam. If I do nothing other than edit the default octopi.txt to camera="raspi" my setup starts failing. If I edit the default to camera="usb" the raspi cam works?? Is there some kind of way that my raspberry PI cam became a USB device?

Also I should mention that ls /dev/v4l/by-id/ does not exist. I have "by-path".

A raspicam can be accessed as either, the system does represent it as a USB camera so that it's compatible with applications that work with USB cameras.

Using it as a USB camera means that you lose the specific raspicam options, however since you are then limited to the USB camera options. It does, however, mean that you can use USB camera things, like the Camera Settings plugin.

Any idea why I can't address it as a raspberry pi camera?

I'm having trouble with getting my cheap unbranded usb webcam to work. I put this in:

camera_usb_options="-r 640x480 -f 10 -d usb-Ruision_UVC_Camera_20200416-video-index0"

but I'm seeing in the webcamd.log:

config file='/boot/octopi.conf.d/webcam2.txt':USB device was not set in options, start MJPG-streamer with the first found video device: /dev/video0

and

Running ./mjpg_streamer -o output_http.so -w ./www-octopi -n -p 8081 -i input_uvc.so -r 640x480 -f 10 -d usb-Ruision_UVC_Camera_20200416-video-index0 -d /dev/video0

note that it's showing the -d that I put in, but also a -d /dev/video0 (which is my raspi cam, when it's installed). This results in both 8080 and 8081 showing the raspi cam. If the raspi isn't plugged in, it doesn't find anything and the web stream won't connect.

Any ideas? I'm on Octopi 0.18 on a 4gb Pi 4B

NEVERMIND... didn't have the /dev/v41/by-id/ in the device path.

you have to include this in front of the id...

camera_usb_options="-r 640x480 -f 10 -d /dev/v4l/by-id/usb-Ruision_UVC_Camera_20200416-video-index0"

OK, a bunch of water under the bridge... had my USB camera unplugged for a while during installing a new board in my Ender3. Now, it doesn't work, where it did (at least for a short time) after I had the above issue. Now there's nothing on :8081, and seeing something similar to the above in the webcamd log (with the v41 path included). However, when I go to see if the webcam's ID is the same, I can't view the v41 folder. It tells me

pi@octopi:~ $ ls /dev/v41/by-id
ls: cannot access '/dev/v41/by-id': No such file or directory
pi@octopi:~ $ ls /dev/v41
ls: cannot access '/dev/v41': No such file or directory

I look at /dev, and I can see a v41 that's colored the same as all the other folders. If I do "ls /dev/v* -l" I get a lot of v* files, along with:

crw-rw---- 1 root video  81,   9 Sep  8 17:12 /dev/video2

/dev/v4l:
total 0
drwxr-xr-x 2 root root  80 Sep  8 17:12 by-id
drwxr-xr-x 2 root root 180 Sep  8 17:12 by-path

So there's something, there, but I can't figure out how to look at it.

I'm at the limits of my linux admin knowledge. Any suggestions?

p.s. not that it matters, because it doesn't seem to look at the folder yet (just tells me I didn't set it in options), webcam2.txt has

camera_usb_options="-r 1024x768 -f 10 -d /dev/v41/by-id/usb-Ruision_UVC_Camera_20200416-video-index0"

and the log has

config file='/home/pi/klipper_config/webcam2.txt':USB device was not set in options, start MJPG-streamer with the first found video device: /dev/video0
<13>Sep  8 17:25:14 pi: Starting USB webcam
Checking for VL805 (Raspberry Pi 4)...
  - It seems that you don't have VL805 (Raspberry Pi 4).
    There should be no problems with USB (a.k.a. select() timeout)
Running ./mjpg_streamer -o output_http.so -w ./www-mjpgstreamer -n -p 8081 -i input_uvc.so -r 1024x768 -f 10 -d /dev/v41/by-id/usb-Ruision_UVC_Camera_20200416-video-index0 -d /dev/video0

There's a typo in your /dev/v4l path. It a lowercase L, not a 1. Then you'll be able to find the correct device.

1 Like

Hrm. I blame putty for using a font with indistinguishable 1's and L's. Ah well. Now to figure out why it can't find input_raspicam.so...

BTW: You can choose the fonts in putty...

I may do that soon.

OK.... next problem (like I mentioned above) is that there isn't an "input_raspicam.so". Somewhere along the line I'd used kiauh (klipper install script) to remove & reinstall mjpg-streamer. seems that it didn't build that input plugin. I'm looking through things looking for how to build it ... in the meantime, if anyone knows how, please let me know.

This guide is written for the MJPG streamer install in OctoPi - if you have a different setup & issue, please open a new thread in the forums rather than filling this one up.

My apologies.

I can get a snapshot but can't stream is there any fix to this.

I finally got my duel webcam stream working with the help of this tutorial. Thanks for the help! I was wondering if it is possible to have a webcam tab in octoprint, which shows both webcam streams at once. Something like this:
(Currently I/m importing both webcam streams in a OBS scene to accomplish this)

1 Like

The multicam plugin should do that, but note I don't use it so can't help if it doesn't work:

I also made the multicam view plugin (unlisted).

3 Likes