After a reboot, everything works great. I have the multicam plugin and I can see all three cameras. However, after about 10 minutes or so, none of my cameras work. When I try to open the stream, it just hangs.
Anyone have a clue what could be the problem? I used to have a bunch of hacked up files to support multiple cameras, based on how older versions of OctoPi worked. These problems started happening after I switched to the "proper" method for OctoPi 0.18. It's possible that I might have some vestige of the old method lying around.
It looks like it's below the webcam streaming software - the dmesg log tells most of the story here:
[ 825.253366] usb usb1-port1: disabled by hub (EMI?), re-enabling...
[ 825.253401] usb 1-1: USB disconnect, device number 2
[ 825.253423] usb 1-1.1: USB disconnect, device number 3
[ 825.253443] usb 1-1.1.1: USB disconnect, device number 8
[ 825.253881] lan78xx 1-1.1.1:1.0 eth0: Failed to read register index 0x00000120. ret = -19
[ 825.253922] lan78xx 1-1.1.1:1.0 eth0: Failed to read register index 0x00000120. ret = -19
[ 825.253951] lan78xx 1-1.1.1:1.0 eth0: Failed to read register index 0x00000120. ret = -19
[ 825.253981] lan78xx 1-1.1.1:1.0 eth0: Failed to read register index 0x00000098. ret = -19
[ 825.254002] lan78xx 1-1.1.1:1.0 eth0: Failed to write register index 0x00000098. ret = -19
[ 825.254140] lan78xx 1-1.1.1:1.0 eth0: Failed to read register index 0x00000098. ret = -19
[ 825.254161] lan78xx 1-1.1.1:1.0 eth0: Failed to write register index 0x00000098. ret = -19
[ 825.255142] lan78xx 1-1.1.1:1.0 eth0 (unregistering): Failed to read register index 0x00000024. ret = -19
[ 825.305745] usb 1-1.1.2: USB disconnect, device number 5
[ 825.447492] usb 1-1.1.3: USB disconnect, device number 7
[ 825.451409] usb 1-1.2: USB disconnect, device number 6
[ 825.534611] usb 1-1.3: USB disconnect, device number 4
It looks like the USB hub resets itself. The log itself is questioning EMI, but that's not necessarily the issue. Maybe with 3 webcams the USB controller is getting too warm and resetting? Not completely obvious but at least we can see a problem in the logs.
If you run with just one webcam connected, does it last for longer? Or still quitting after 13 minutes as this one is doing.
If I do "service webcamd restart", the problem appears to fix itself until the next reboot.
When I disconnect once of the cameras, it seems to work.
I then tried connecting all the cameras to a powered USB hub, but that just made things worse. After a few minutes, all of the cameras stopped working.
[ 51.554240] usb 1-1.1.2.1: reset high-speed USB device number 6 using dwc_otg
[ 56.834211] usb 1-1.1.2.1: device descriptor read/64, error -110
[ 72.274225] usb 1-1.1.2.1: device descriptor read/64, error -110
Anyway, it's obviously a USB power problem. I'll try a few different things. Maybe the hub is broken.
What's the best way to have OctoPi run "sudo service webcamd restart" a few minutes after OctoPrint starts?
You can have that with a systemd timer and onBootSec=6min or so, plus a cooresponding .service which has a bash script in exec which in turn does the restart
But there is an alternative, add an entry to restart webcamd to OctoPrint's system menu.
For this you need to edit config.yaml and add:
system:
actions:
- action: restartwebcam
command: sudo systemctl restart webcamd
confirm: You are about to restart the webcam
name: Restart Webcam
and here are the scripts for a systemd timer to restart the webcamd.service 6 minutes after boot - it was easier to post them from the other computer.
It takes three tiny files, #1 is a bash script that does the work.
The example creates and edits the files with nano sudo nano /usr/local/bin/restart_webcamd.sh