Webcam stops working after a few minutes

Camera model
ELP Night Vision Camera 1080P Webcam Mini Infrared USB Camera Module

(perfect as it automatically switches between night vision and normal mode)

What is the problem?
Camera works, then after a while (usually a few minutes) it doesn't.
Logs suggest the Webcam disconnects and reconnects (for whatever reason) and the webcam stream does not catch up.

What did you already try to solve it?
sudo service webcamd restart fixes the problem again for a few minutes.
Tried finding a plugin for issuing this command via Web-UI as a workaround :wink:

Logs (/var/log/webcamd.log, syslog, dmesg, ... no logs, no support)

Syslog:

Jun 19 18:02:39 octopi kernel: [ 2504.678597] usb 1-1.3: USB disconnect, device number 4
Jun 19 18:02:39 octopi kernel: [ 2504.681055] uvcvideo: Failed to resubmit video URB (-19).
Jun 19 18:02:39 octopi kernel: [ 2504.685046] uvcvideo: Failed to resubmit video URB (-19).
Jun 19 18:02:39 octopi kernel: [ 2504.689028] uvcvideo: Failed to resubmit video URB (-19).
Jun 19 18:02:39 octopi kernel: [ 2504.693162] uvcvideo: Failed to resubmit video URB (-19).
Jun 19 18:02:39 octopi kernel: [ 2504.697154] uvcvideo: Failed to resubmit video URB (-19).
Jun 19 18:02:39 octopi thd[345]: Error reading device '/dev/input/event0'
Jun 19 18:02:39 octopi kernel: [ 2504.770224] xhci_hcd 0000:01:00.0: ERROR Transfer event for disabled endpoint slot 3 ep 2
Jun 19 18:02:39 octopi kernel: [ 2504.770232] xhci_hcd 0000:01:00.0: @000000001ed0a9a0 00000000 00000000 0f000000 03038000
Jun 19 18:02:39 octopi kernel: [ 2505.069591] usb 1-1.3: new high-speed USB device number 5 using xhci_hcd
Jun 19 18:02:39 octopi kernel: [ 2505.609800] usb 1-1.3: device descriptor read/64, error -71
Jun 19 18:02:40 octopi octoprint[1129]: 2022-06-19 18:02:40,068 - octoprint.util.comm - INFO - Printer seems to support the busy protocol, will adjust timeouts and set busy interval accordingly#033[0m
Jun 19 18:02:40 octopi kernel: [ 2506.059768] usb 1-1.3: device descriptor read/64, error -71
Jun 19 18:02:40 octopi kernel: [ 2506.279559] usb 1-1.3: new high-speed USB device number 6 using xhci_hcd
Jun 19 18:02:40 octopi kernel: [ 2506.482208] usb 1-1.3: New USB device found, idVendor=32e4, idProduct=9230, bcdDevice= 1.00
Jun 19 18:02:40 octopi kernel: [ 2506.482228] usb 1-1.3: New USB device strings: Mfr=2, Product=1, SerialNumber=0
Jun 19 18:02:40 octopi kernel: [ 2506.482246] usb 1-1.3: Product: HD USB Camera
Jun 19 18:02:40 octopi kernel: [ 2506.482262] usb 1-1.3: Manufacturer: HD USB Camera
Jun 19 18:02:40 octopi kernel: [ 2506.489734] uvcvideo: Found UVC 1.00 device HD USB Camera (32e4:9230)
Jun 19 18:02:40 octopi kernel: [ 2506.545493] input: HD USB Camera: HD USB Camera as /devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.3/1-1.3:1.0/input/input1
Jun 19 18:02:40 octopi mtp-probe: checking bus 1, device 6: "/sys/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.3"
Jun 19 18:02:40 octopi mtp-probe: bus: 1, device: 6 was not an MTP device
Jun 19 18:02:41 octopi systemd-udevd[1475]: Process '/usr/sbin/th-cmd --socket /var/run/thd.socket --passfd --udev' failed with exit code 1.
Jun 19 18:02:41 octopi mtp-probe: checking bus 1, device 6: "/sys/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.3"
Jun 19 18:02:41 octopi mtp-probe: bus: 1, device: 6 was not an MTP device
Jun 19 18:02:43 octopi kernel: [ 2508.775495] usb 1-1.3: USB disconnect, device number 6
Jun 19 18:02:43 octopi kernel: [ 2509.169606] usb 1-1.3: new high-speed USB device number 7 using xhci_hcd
Jun 19 18:02:43 octopi kernel: [ 2509.372280] usb 1-1.3: New USB device found, idVendor=32e4, idProduct=9230, bcdDevice= 1.00
Jun 19 18:02:43 octopi kernel: [ 2509.372301] usb 1-1.3: New USB device strings: Mfr=2, Product=1, SerialNumber=0
Jun 19 18:02:43 octopi kernel: [ 2509.372319] usb 1-1.3: Product: HD USB Camera
Jun 19 18:02:43 octopi kernel: [ 2509.372335] usb 1-1.3: Manufacturer: HD USB Camera
Jun 19 18:02:43 octopi kernel: [ 2509.381644] uvcvideo: Found UVC 1.00 device HD USB Camera (32e4:9230)
Jun 19 18:02:43 octopi kernel: [ 2509.437179] input: HD USB Camera: HD USB Camera as /devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.3/1-1.3:1.0/input/input2
Jun 19 18:02:43 octopi mtp-probe: checking bus 1, device 7: "/sys/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.3"
Jun 19 18:02:43 octopi mtp-probe: bus: 1, device: 7 was not an MTP device
Jun 19 18:02:43 octopi MJPG-streamer [487]: Error grabbing frames
Jun 19 18:02:43 octopi MJPG-streamer [487]: cleaning up resources allocated by input thread
Jun 19 18:02:44 octopi systemd-udevd[1475]: Process '/usr/sbin/th-cmd --socket /var/run/thd.socket --passfd --udev' failed with exit code 1.
Jun 19 18:02:44 octopi mtp-probe: checking bus 1, device 7: "/sys/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.3"
Jun 19 18:02:44 octopi mtp-probe: bus: 1, device: 7 was not an MTP device

When I then do a sudo service webcamd restart everything starts working again:

Jun 19 18:07:41 octopi systemd[1]: Stopping the OctoPi webcam daemon with the user specified config...
Jun 19 18:07:41 octopi systemd[1]: webcamd.service: Main process exited, code=killed, status=15/TERM
Jun 19 18:07:41 octopi systemd[1]: webcamd.service: Succeeded.
Jun 19 18:07:41 octopi systemd[1]: Stopped the OctoPi webcam daemon with the user specified config.
Jun 19 18:07:41 octopi systemd[1]: Starting the OctoPi webcam daemon with the user specified config...
Jun 19 18:07:41 octopi root: Starting USB webcam
Jun 19 18:07:41 octopi MJPG-streamer [1587]: starting application
Jun 19 18:07:41 octopi MJPG-streamer [1587]: MJPG Streamer Version: git rev: 5554f42c352ecfa7edaec6fc51e507afce605a34
Jun 19 18:07:41 octopi MJPG-streamer [1587]: Using V4L2 device.: /dev/video1
Jun 19 18:07:41 octopi MJPG-streamer [1587]: Desired Resolution: 640 x 480
Jun 19 18:07:41 octopi MJPG-streamer [1587]: Frames Per Second.: 10
Jun 19 18:07:41 octopi MJPG-streamer [1587]: Format............: JPEG
Jun 19 18:07:41 octopi MJPG-streamer [1587]: TV-Norm...........: DEFAULT
Jun 19 18:07:42 octopi MJPG-streamer [1587]: FPS coerced ......: from 10 to 61612
Jun 19 18:07:42 octopi systemd[1]: Started the OctoPi webcam daemon with the user specified config.
Jun 19 18:07:42 octopi systemd[1]: session-3.scope: Succeeded.
Jun 19 18:07:42 octopi MJPG-streamer [1587]: www-folder-path......: ./www-octopi/
Jun 19 18:07:42 octopi MJPG-streamer [1587]: HTTP TCP port........: 8080
Jun 19 18:07:42 octopi MJPG-streamer [1587]: HTTP Listen Address..: 127.0.0.1
Jun 19 18:07:42 octopi MJPG-streamer [1587]: username:password....: disabled
Jun 19 18:07:42 octopi MJPG-streamer [1587]: commands.............: disabled
Jun 19 18:07:42 octopi MJPG-streamer [1587]: starting input plugin input_uvc.so
Jun 19 18:07:42 octopi MJPG-streamer [1587]: starting output plugin: output_http.so (ID: 00)

Additional information about your setup (OctoPrint version, OctoPi version, ...)
OctoPrint version : 1.8.1
OctoPi version : 0.18.0

mhmm
does that also happen when no other device (like the printer) is connected to the usb ports of the pi?

You can add this to your config.yaml:

system:
  actions:
  - action: restartwebcam
    command: sudo systemctl restart webcamd
    confirm: You are about to restart the webcam
    name: Restart Webcam

which will give you a new entry in the system menue to restart the webcamd from the ui.

1 Like

If I knew it was that easy :rofl:. Will try this after the current print has finished...

Good point. I tried running the system without printing, with the camera always running without problems.

Then I did an hour-long print from the SD card with the Prusa MKS3+ disconnected from USB, and it died fast. Since it is pretty hot in Munich at the moment, this might indicate a thermal issue for the dis- and reconnecting cam.
However, I think a webcamd should be able to recover autonomously from this (when a simple restart can also do the trick?