Mjpg-streamer requires many reboots to start-up 2 cameras

Camera model

  1. Generic (no label) endoscope
  2. LogiLink LL1

What is the problem?
I followed this video in order to setup my multicam: https://youtu.be/FzpBgEG_ksw
It is mentioned in the video that mjpg-streamer doesn't like to run two instances at the same time and we might to do several reboots to make both cams working. That's exactly what i'm experiencing and I was wondering if there's a fix for this issue.

After pi reboot, cameras randomly fail to start:

pi@octopi:~ $ sudo service webcamd_OverviewCAM status
● webcamd_OverviewCAM.service - the OctoPi webcam daemon with the user specified config
Loaded: loaded (/etc/systemd/system/webcamd_OverviewCAM.service; enabled; vendor preset: enabled)
Active: failed (Result: start-limit-hit) since Sat 2021-05-01 02:08:06 EEST; 45s ago
Process: 731 ExecStart=/root/bin/webcamd_OverviewCAM (code=exited, status=0/SUCCESS)

May 01 02:08:06 octopi systemd[1]: webcamd_OverviewCAM.service: Service RestartSec=100ms expired, scheduling restart.
May 01 02:08:06 octopi systemd[1]: webcamd_OverviewCAM.service: Scheduled restart job, restart counter is at 5.
May 01 02:08:06 octopi systemd[1]: Stopped the OctoPi webcam daemon with the user specified config.
May 01 02:08:06 octopi systemd[1]: webcamd_OverviewCAM.service: Start request repeated too quickly.
May 01 02:08:06 octopi systemd[1]: webcamd_OverviewCAM.service: Failed with result 'start-limit-hit'.
May 01 02:08:06 octopi systemd[1]: Failed to start the OctoPi webcam daemon with the user specified config.

pi@octopi:~ $ sudo service webcamd status
● webcamd.service - the OctoPi webcam daemon with the user specified config
Loaded: loaded (/etc/systemd/system/webcamd.service; enabled; vendor preset: enabled)
Active: failed (Result: start-limit-hit) since Sat 2021-05-01 02:08:06 EEST; 50s ago
Process: 730 ExecStart=/root/bin/webcamd (code=exited, status=0/SUCCESS)

May 01 02:08:06 octopi systemd[1]: webcamd.service: Service RestartSec=100ms expired, scheduling restart.
May 01 02:08:06 octopi systemd[1]: webcamd.service: Scheduled restart job, restart counter is at 5.
May 01 02:08:06 octopi systemd[1]: Stopped the OctoPi webcam daemon with the user specified config.
May 01 02:08:06 octopi systemd[1]: webcamd.service: Start request repeated too quickly.
May 01 02:08:06 octopi systemd[1]: webcamd.service: Failed with result 'start-limit-hit'.
May 01 02:08:06 octopi systemd[1]: Failed to start the OctoPi webcam daemon with the user specified config.

After random amount of reboots (and different combinations of running/failing cameras), they both startup:

pi@octopi:~ $ sudo service webcamd status
● 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 Sat 2021-05-01 02:09:19 EEST; 2min 2s ago
Process: 373 ExecStart=/root/bin/webcamd (code=exited, status=0/SUCCESS)
Main PID: 507 (mjpg_streamer)
Tasks: 3 (limit: 4915)
Memory: 3.0M
CGroup: /system.slice/webcamd.service
└─507 ./mjpg_streamer -o output_http.so -w ./www-octopi -p 8080 -i input_uvc.so -d /dev/endoscopecam -r 640x480 -f 30

May 01 02:09:18 octopi mjpg_streamer[507]: MJPG-streamer [507]: www-folder-path......: ./www-octopi/
May 01 02:09:18 octopi mjpg_streamer[507]: MJPG-streamer [507]: HTTP TCP port........: 8080
May 01 02:09:18 octopi mjpg_streamer[507]: MJPG-streamer [507]: HTTP Listen Address..: (null)
May 01 02:09:18 octopi mjpg_streamer[507]: MJPG-streamer [507]: username:password....: disabled
May 01 02:09:18 octopi mjpg_streamer[507]: MJPG-streamer [507]: commands.............: enabled
May 01 02:09:18 octopi mjpg_streamer[507]: MJPG-streamer [507]: starting input plugin input_uvc.so
May 01 02:09:18 octopi mjpg_streamer[507]: MJPG-streamer [507]: starting output plugin: output_http.so (ID: 00)
May 01 02:09:19 octopi webcamd[373]: Done bring up all configured video device
May 01 02:09:19 octopi webcamd[373]: Goodbye...
May 01 02:09:19 octopi systemd[1]: Started the OctoPi webcam daemon with the user specified config.
pi@octopi:~ $ sudo service webcamd_OverviewCAM status
● webcamd_OverviewCAM.service - the OctoPi webcam daemon with the user specified config
Loaded: loaded (/etc/systemd/system/webcamd_OverviewCAM.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2021-05-01 02:09:19 EEST; 2min 7s ago
Process: 379 ExecStart=/root/bin/webcamd_OverviewCAM (code=exited, status=0/SUCCESS)
Main PID: 506 (mjpg_streamer)
Tasks: 4 (limit: 4915)
Memory: 3.0M
CGroup: /system.slice/webcamd_OverviewCAM.service
└─506 ./mjpg_streamer -o output_http.so -w ./www-octopi -p 8081 -i input_uvc.so -d /dev/overviewcam -r 1280x720 -f 30

May 01 02:09:18 octopi mjpg_streamer[506]: MJPG-streamer [506]: www-folder-path......: ./www-octopi/
May 01 02:09:18 octopi mjpg_streamer[506]: MJPG-streamer [506]: HTTP TCP port........: 8081
May 01 02:09:18 octopi mjpg_streamer[506]: MJPG-streamer [506]: HTTP Listen Address..: (null)
May 01 02:09:18 octopi mjpg_streamer[506]: MJPG-streamer [506]: username:password....: disabled
May 01 02:09:18 octopi mjpg_streamer[506]: MJPG-streamer [506]: commands.............: enabled
May 01 02:09:18 octopi mjpg_streamer[506]: MJPG-streamer [506]: starting input plugin input_uvc.so
May 01 02:09:18 octopi mjpg_streamer[506]: MJPG-streamer [506]: starting output plugin: output_http.so (ID: 00)
May 01 02:09:19 octopi webcamd_OverviewCAM[379]: Done bring up all configured video device
May 01 02:09:19 octopi webcamd_OverviewCAM[379]: Goodbye...
May 01 02:09:19 octopi systemd[1]: Started the OctoPi webcam daemon with the user specified config.

What did you already try to solve it?

  • In "journalctl -u webcamd" I saw that mjpg is not supported by my endoscope camera so I switched to YUYV. However, even without the "-y" usb option, I noticed that it switched automatically to YUYV so my change shouldn't have made any difference
  • I tried many resolutions and framerates
  • I read many suggestions to run "vcgencmd get_camera" but when both my cams are running, the result of that command is "supported=1 detected=0"
  • I measured the power consumption of the cameras and I am (almost) confident there is no power issue (I saw people suggesting to plug the cameras to a seperately-powered usb hub). My raspberry pi has the 2 cameras and my Ender 3 connected on it (it's a 4B model btw with the official power brick).

Please note that before I switched to multicam, I had only the endoscope camera and it was working properly. I could do "sudo service webcamd restart" and it would work flawlessly. Currently, no matter how many service restarts I execute, the stopped camera(s) will never startup.

Logs (/var/log/webcamd.log, syslog, dmesg, ... no logs, no support)
Example of a "journalctl -u webcamd" output of a failed startup of my endoscope camera:

pi@octopi:~ $ journalctl -u webcamd
-- Logs begin at Sat 2021-05-01 02:27:29 EEST, end at Sat 2021-05-01 02:28:28 EEST. --
May 01 02:27:33 octopi systemd[1]: Starting the OctoPi webcam daemon with the user specified config...
May 01 02:27:33 octopi webcamd[366]: Starting up webcamDaemon...
May 01 02:27:33 octopi webcamd[366]: --- Configuration: ----------------------------
May 01 02:27:33 octopi webcamd[366]: cfg_file: /boot/octopi.txt
May 01 02:27:33 octopi webcamd[366]: camera: usb
May 01 02:27:33 octopi webcamd[366]: usb options: -d /dev/endoscopecam -r 640x480 -f 30 -y
May 01 02:27:33 octopi webcamd[366]: raspi options: -fps 10
May 01 02:27:33 octopi webcamd[366]: http options: -w ./www-octopi -p 8080
May 01 02:27:33 octopi webcamd[366]: Explicitly USB device:
May 01 02:27:33 octopi webcamd[366]: -----------------------------------------------
May 01 02:27:34 octopi webcamd[366]: Found video devices:
May 01 02:27:34 octopi webcamd[366]: /dev/video0
May 01 02:27:34 octopi webcamd[366]: /dev/video1
May 01 02:27:34 octopi webcamd[366]: /dev/video10
May 01 02:27:34 octopi webcamd[366]: /dev/video11
May 01 02:27:34 octopi webcamd[366]: /dev/video12
May 01 02:27:34 octopi webcamd[366]: /dev/video2
May 01 02:27:34 octopi webcamd[366]: /dev/video3
May 01 02:27:34 octopi webcamd[366]: config file='/boot/octopi.txt':USB device was not set in options, start MJPG-streamer with the first found video device: /dev/video0
May 01 02:27:34 octopi root[489]: Starting USB webcam
May 01 02:27:34 octopi webcamd[366]: <13>May 1 02:27:34 root: Starting USB webcam
May 01 02:27:34 octopi webcamd[366]: Running ./mjpg_streamer -o output_http.so -w ./www-octopi -p 8080 -i input_uvc.so -d /dev/endoscopecam -r 640x480 -f 30 -y
May 01 02:27:34 octopi webcamd[366]: MJPG Streamer Version: git rev: 501f6362c5afddcfb41055f97ae484252c85c912
May 01 02:27:34 octopi mjpg_streamer[491]: MJPG-streamer [491]: starting application
May 01 02:27:34 octopi mjpg_streamer[491]: MJPG-streamer [491]: MJPG Streamer Version: git rev: 501f6362c5afddcfb41055f97ae484252c85c912
May 01 02:27:34 octopi webcamd[366]: i: Using V4L2 device.: /dev/video3
May 01 02:27:34 octopi webcamd[366]: i: Desired Resolution: 640 x 480
May 01 02:27:34 octopi webcamd[366]: i: Frames Per Second.: 30
May 01 02:27:34 octopi webcamd[366]: i: Format............: YUYV
May 01 02:27:34 octopi webcamd[366]: i: JPEG Quality......: 80
May 01 02:27:34 octopi webcamd[366]: i: TV-Norm...........: DEFAULT
May 01 02:27:34 octopi mjpg_streamer[491]: MJPG-streamer [491]: Using V4L2 device.: /dev/video3
May 01 02:27:34 octopi mjpg_streamer[491]: MJPG-streamer [491]: Desired Resolution: 640 x 480
May 01 02:27:34 octopi mjpg_streamer[491]: MJPG-streamer [491]: Frames Per Second.: 30
May 01 02:27:34 octopi mjpg_streamer[491]: MJPG-streamer [491]: Format............: YUYV
May 01 02:27:34 octopi mjpg_streamer[491]: MJPG-streamer [491]: JPEG Quality......: 80
May 01 02:27:34 octopi mjpg_streamer[491]: MJPG-streamer [491]: TV-Norm...........: DEFAULT
May 01 02:27:34 octopi webcamd[366]: Unable to set format: 1448695129 res: 640x480
May 01 02:27:34 octopi webcamd[366]: Init v4L2 failed !! exit fatal
May 01 02:27:34 octopi webcamd[366]: i: init_VideoIn failed
May 01 02:27:34 octopi mjpg_streamer[491]: MJPG-streamer [491]: init_VideoIn failed
May 01 02:27:35 octopi webcamd[366]: Done bring up all configured video device
May 01 02:27:35 octopi webcamd[366]: Goodbye...
May 01 02:27:35 octopi systemd[1]: webcamd.service: Succeeded.
May 01 02:27:35 octopi systemd[1]: Started the OctoPi webcam daemon with the user specified config.
May 01 02:27:35 octopi systemd[1]: webcamd.service: Service RestartSec=100ms expired, scheduling restart.
May 01 02:27:35 octopi systemd[1]: webcamd.service: Scheduled restart job, restart counter is at 1.
May 01 02:27:35 octopi systemd[1]: Stopped the OctoPi webcam daemon with the user specified config.
May 01 02:27:35 octopi systemd[1]: Starting the OctoPi webcam daemon with the user specified config...
May 01 02:27:35 octopi webcamd[571]: Starting up webcamDaemon...
May 01 02:27:35 octopi webcamd[571]: --- Configuration: ----------------------------
May 01 02:27:35 octopi webcamd[571]: cfg_file: /boot/octopi.txt
May 01 02:27:35 octopi webcamd[571]: camera: usb
May 01 02:27:35 octopi webcamd[571]: usb options: -d /dev/endoscopecam -r 640x480 -f 30 -y
May 01 02:27:35 octopi webcamd[571]: raspi options: -fps 10
May 01 02:27:35 octopi webcamd[571]: http options: -w ./www-octopi -p 8080
May 01 02:27:35 octopi webcamd[571]: Explicitly USB device:
May 01 02:27:35 octopi webcamd[571]: -----------------------------------------------
May 01 02:27:35 octopi webcamd[571]: Found video devices:
May 01 02:27:35 octopi webcamd[571]: /dev/video0
May 01 02:27:35 octopi webcamd[571]: /dev/video1
May 01 02:27:35 octopi webcamd[571]: /dev/video10
May 01 02:27:35 octopi webcamd[571]: /dev/video11
May 01 02:27:35 octopi webcamd[571]: /dev/video12
May 01 02:27:35 octopi webcamd[571]: /dev/video2
May 01 02:27:35 octopi webcamd[571]: /dev/video3
May 01 02:27:35 octopi webcamd[571]: config file='/boot/octopi.txt':USB device was not set in options, start MJPG-streamer with the first found video device: /dev/video0
May 01 02:27:35 octopi root[617]: Starting USB webcam
May 01 02:27:35 octopi webcamd[571]: <13>May 1 02:27:35 root: Starting USB webcam
May 01 02:27:35 octopi webcamd[571]: Running ./mjpg_streamer -o output_http.so -w ./www-octopi -p 8080 -i input_uvc.so -d /dev/endoscopecam -r 640x480 -f 30 -y
May 01 02:27:35 octopi mjpg_streamer[618]: MJPG-streamer [618]: starting application
May 01 02:27:35 octopi mjpg_streamer[618]: MJPG-streamer [618]: MJPG Streamer Version: git rev: 501f6362c5afddcfb41055f97ae484252c85c912
May 01 02:27:35 octopi webcamd[571]: MJPG Streamer Version: git rev: 501f6362c5afddcfb41055f97ae484252c85c912
May 01 02:27:35 octopi webcamd[571]: i: Using V4L2 device.: /dev/video3
May 01 02:27:35 octopi webcamd[571]: i: Desired Resolution: 640 x 480
May 01 02:27:35 octopi webcamd[571]: i: Frames Per Second.: 30
May 01 02:27:35 octopi webcamd[571]: i: Format............: YUYV
May 01 02:27:35 octopi webcamd[571]: i: JPEG Quality......: 80
May 01 02:27:35 octopi webcamd[571]: i: TV-Norm...........: DEFAULT
May 01 02:27:35 octopi webcamd[571]: Unable to set format: 1448695129 res: 640x480
May 01 02:27:35 octopi webcamd[571]: Init v4L2 failed !! exit fatal
May 01 02:27:35 octopi webcamd[571]: i: init_VideoIn failed
May 01 02:27:35 octopi mjpg_streamer[618]: MJPG-streamer [618]: Using V4L2 device.: /dev/video3
May 01 02:27:35 octopi mjpg_streamer[618]: MJPG-streamer [618]: Desired Resolution: 640 x 480
May 01 02:27:35 octopi mjpg_streamer[618]: MJPG-streamer [618]: Frames Per Second.: 30
May 01 02:27:35 octopi mjpg_streamer[618]: MJPG-streamer [618]: Format............: YUYV
May 01 02:27:35 octopi mjpg_streamer[618]: MJPG-streamer [618]: JPEG Quality......: 80
May 01 02:27:35 octopi mjpg_streamer[618]: MJPG-streamer [618]: TV-Norm...........: DEFAULT
May 01 02:27:35 octopi mjpg_streamer[618]: MJPG-streamer [618]: init_VideoIn failed
May 01 02:27:36 octopi webcamd[571]: Done bring up all configured video device
May 01 02:27:36 octopi webcamd[571]: Goodbye...
May 01 02:27:36 octopi systemd[1]: webcamd.service: Succeeded.
May 01 02:27:36 octopi systemd[1]: Started the OctoPi webcam daemon with the user specified config.
May 01 02:27:37 octopi systemd[1]: webcamd.service: Service RestartSec=100ms expired, scheduling restart.
May 01 02:27:37 octopi systemd[1]: webcamd.service: Scheduled restart job, restart counter is at 2.
May 01 02:27:37 octopi systemd[1]: Stopped the OctoPi webcam daemon with the user specified config.
May 01 02:27:37 octopi systemd[1]: Starting the OctoPi webcam daemon with the user specified config...
May 01 02:27:37 octopi webcamd[625]: Starting up webcamDaemon...
May 01 02:27:37 octopi webcamd[625]: --- Configuration: ----------------------------
May 01 02:27:37 octopi webcamd[625]: cfg_file: /boot/octopi.txt
May 01 02:27:37 octopi webcamd[625]: camera: usb
May 01 02:27:37 octopi webcamd[625]: usb options: -d /dev/endoscopecam -r 640x480 -f 30 -y
May 01 02:27:37 octopi webcamd[625]: raspi options: -fps 10
May 01 02:27:37 octopi webcamd[625]: http options: -w ./www-octopi -p 8080
May 01 02:27:37 octopi webcamd[625]: Explicitly USB device:
May 01 02:27:37 octopi webcamd[625]: -----------------------------------------------
May 01 02:27:37 octopi webcamd[625]: Found video devices:
May 01 02:27:37 octopi webcamd[625]: /dev/video0
May 01 02:27:37 octopi webcamd[625]: /dev/video1
May 01 02:27:37 octopi webcamd[625]: /dev/video10
May 01 02:27:37 octopi webcamd[625]: /dev/video11
May 01 02:27:37 octopi webcamd[625]: /dev/video12
May 01 02:27:37 octopi webcamd[625]: /dev/video2
May 01 02:27:37 octopi webcamd[625]: /dev/video3
May 01 02:27:37 octopi webcamd[625]: config file='/boot/octopi.txt':USB device was not set in options, start MJPG-streamer with the first found video device: /dev/video0
May 01 02:27:37 octopi root[673]: Starting USB webcam
May 01 02:27:37 octopi webcamd[625]: <13>May 1 02:27:37 root: Starting USB webcam
May 01 02:27:37 octopi webcamd[625]: Running ./mjpg_streamer -o output_http.so -w ./www-octopi -p 8080 -i input_uvc.so -d /dev/endoscopecam -r 640x480 -f 30 -y
May 01 02:27:37 octopi mjpg_streamer[674]: MJPG-streamer [674]: starting application
May 01 02:27:37 octopi webcamd[625]: MJPG Streamer Version: git rev: 501f6362c5afddcfb41055f97ae484252c85c912
May 01 02:27:37 octopi mjpg_streamer[674]: MJPG-streamer [674]: MJPG Streamer Version: git rev: 501f6362c5afddcfb41055f97ae484252c85c912
May 01 02:27:37 octopi webcamd[625]: i: Using V4L2 device.: /dev/video3
May 01 02:27:37 octopi webcamd[625]: i: Desired Resolution: 640 x 480
May 01 02:27:37 octopi webcamd[625]: i: Frames Per Second.: 30
May 01 02:27:37 octopi webcamd[625]: i: Format............: YUYV
May 01 02:27:37 octopi webcamd[625]: i: JPEG Quality......: 80
May 01 02:27:37 octopi webcamd[625]: i: TV-Norm...........: DEFAULT
May 01 02:27:37 octopi mjpg_streamer[674]: MJPG-streamer [674]: Using V4L2 device.: /dev/video3
May 01 02:27:37 octopi webcamd[625]: Unable to set format: 1448695129 res: 640x480
May 01 02:27:37 octopi webcamd[625]: Init v4L2 failed !! exit fatal
May 01 02:27:37 octopi webcamd[625]: i: init_VideoIn failed
May 01 02:27:37 octopi mjpg_streamer[674]: MJPG-streamer [674]: Desired Resolution: 640 x 480
May 01 02:27:37 octopi mjpg_streamer[674]: MJPG-streamer [674]: Frames Per Second.: 30
May 01 02:27:37 octopi mjpg_streamer[674]: MJPG-streamer [674]: Format............: YUYV
May 01 02:27:37 octopi mjpg_streamer[674]: MJPG-streamer [674]: JPEG Quality......: 80
May 01 02:27:37 octopi mjpg_streamer[674]: MJPG-streamer [674]: TV-Norm...........: DEFAULT
May 01 02:27:37 octopi mjpg_streamer[674]: MJPG-streamer [674]: init_VideoIn failed
May 01 02:27:38 octopi webcamd[625]: Done bring up all configured video device
May 01 02:27:38 octopi webcamd[625]: Goodbye...
May 01 02:27:38 octopi systemd[1]: webcamd.service: Succeeded.
May 01 02:27:38 octopi systemd[1]: Started the OctoPi webcam daemon with the user specified config.
May 01 02:27:38 octopi systemd[1]: webcamd.service: Service RestartSec=100ms expired, scheduling restart.
May 01 02:27:38 octopi systemd[1]: webcamd.service: Scheduled restart job, restart counter is at 3.
May 01 02:27:38 octopi systemd[1]: Stopped the OctoPi webcam daemon with the user specified config.
May 01 02:27:38 octopi systemd[1]: Starting the OctoPi webcam daemon with the user specified config...
May 01 02:27:38 octopi webcamd[678]: Starting up webcamDaemon...
May 01 02:27:38 octopi webcamd[678]: --- Configuration: ----------------------------
May 01 02:27:38 octopi webcamd[678]: cfg_file: /boot/octopi.txt
May 01 02:27:38 octopi webcamd[678]: camera: usb
May 01 02:27:38 octopi webcamd[678]: usb options: -d /dev/endoscopecam -r 640x480 -f 30 -y
May 01 02:27:38 octopi webcamd[678]: raspi options: -fps 10
May 01 02:27:38 octopi webcamd[678]: http options: -w ./www-octopi -p 8080
May 01 02:27:38 octopi webcamd[678]: Explicitly USB device:
May 01 02:27:38 octopi webcamd[678]: -----------------------------------------------
May 01 02:27:38 octopi webcamd[678]: Found video devices:
May 01 02:27:38 octopi webcamd[678]: /dev/video0
May 01 02:27:38 octopi webcamd[678]: /dev/video1
May 01 02:27:38 octopi webcamd[678]: /dev/video10
May 01 02:27:38 octopi webcamd[678]: /dev/video11
May 01 02:27:38 octopi webcamd[678]: /dev/video12
May 01 02:27:38 octopi webcamd[678]: /dev/video2
May 01 02:27:38 octopi webcamd[678]: /dev/video3
May 01 02:27:38 octopi webcamd[678]: config file='/boot/octopi.txt':USB device was not set in options, start MJPG-streamer with the first found video device: /dev/video0
May 01 02:27:38 octopi root[723]: Starting USB webcam
May 01 02:27:38 octopi webcamd[678]: <13>May 1 02:27:38 root: Starting USB webcam
May 01 02:27:38 octopi webcamd[678]: Running ./mjpg_streamer -o output_http.so -w ./www-octopi -p 8080 -i input_uvc.so -d /dev/endoscopecam -r 640x480 -f 30 -y
May 01 02:27:38 octopi mjpg_streamer[726]: MJPG-streamer [726]: starting application
May 01 02:27:38 octopi webcamd[678]: MJPG Streamer Version: git rev: 501f6362c5afddcfb41055f97ae484252c85c912
May 01 02:27:38 octopi mjpg_streamer[726]: MJPG-streamer [726]: MJPG Streamer Version: git rev: 501f6362c5afddcfb41055f97ae484252c85c912
May 01 02:27:38 octopi webcamd[678]: i: Using V4L2 device.: /dev/video3
May 01 02:27:38 octopi webcamd[678]: i: Desired Resolution: 640 x 480
May 01 02:27:38 octopi webcamd[678]: i: Frames Per Second.: 30
May 01 02:27:38 octopi webcamd[678]: i: Format............: YUYV
May 01 02:27:38 octopi webcamd[678]: i: JPEG Quality......: 80
May 01 02:27:38 octopi webcamd[678]: i: TV-Norm...........: DEFAULT
May 01 02:27:38 octopi webcamd[678]: Unable to set format: 1448695129 res: 640x480
May 01 02:27:38 octopi webcamd[678]: Init v4L2 failed !! exit fatal
May 01 02:27:38 octopi webcamd[678]: i: init_VideoIn failed
May 01 02:27:38 octopi mjpg_streamer[726]: MJPG-streamer [726]: Using V4L2 device.: /dev/video3
May 01 02:27:38 octopi mjpg_streamer[726]: MJPG-streamer [726]: Desired Resolution: 640 x 480
May 01 02:27:38 octopi mjpg_streamer[726]: MJPG-streamer [726]: Frames Per Second.: 30
May 01 02:27:38 octopi mjpg_streamer[726]: MJPG-streamer [726]: Format............: YUYV
May 01 02:27:38 octopi mjpg_streamer[726]: MJPG-streamer [726]: JPEG Quality......: 80
May 01 02:27:38 octopi mjpg_streamer[726]: MJPG-streamer [726]: TV-Norm...........: DEFAULT
May 01 02:27:38 octopi mjpg_streamer[726]: MJPG-streamer [726]: init_VideoIn failed
May 01 02:27:39 octopi webcamd[678]: Done bring up all configured video device
May 01 02:27:39 octopi webcamd[678]: Goodbye...
May 01 02:27:39 octopi systemd[1]: webcamd.service: Succeeded.
May 01 02:27:39 octopi systemd[1]: Started the OctoPi webcam daemon with the user specified config.
May 01 02:27:40 octopi systemd[1]: webcamd.service: Service RestartSec=100ms expired, scheduling restart.
May 01 02:27:40 octopi systemd[1]: webcamd.service: Scheduled restart job, restart counter is at 4.
May 01 02:27:40 octopi systemd[1]: Stopped the OctoPi webcam daemon with the user specified config.
May 01 02:27:40 octopi systemd[1]: Starting the OctoPi webcam daemon with the user specified config...
May 01 02:27:40 octopi webcamd[731]: Starting up webcamDaemon...
May 01 02:27:40 octopi webcamd[731]: --- Configuration: ----------------------------
May 01 02:27:40 octopi webcamd[731]: cfg_file: /boot/octopi.txt
May 01 02:27:40 octopi webcamd[731]: camera: usb
May 01 02:27:40 octopi webcamd[731]: usb options: -d /dev/endoscopecam -r 640x480 -f 30 -y
May 01 02:27:40 octopi webcamd[731]: raspi options: -fps 10
May 01 02:27:40 octopi webcamd[731]: http options: -w ./www-octopi -p 8080
May 01 02:27:40 octopi webcamd[731]: Explicitly USB device:
May 01 02:27:40 octopi webcamd[731]: -----------------------------------------------
May 01 02:27:40 octopi webcamd[731]: Found video devices:
May 01 02:27:40 octopi webcamd[731]: /dev/video0
May 01 02:27:40 octopi webcamd[731]: /dev/video1
May 01 02:27:40 octopi webcamd[731]: /dev/video10
May 01 02:27:40 octopi webcamd[731]: /dev/video11
May 01 02:27:40 octopi webcamd[731]: /dev/video12
May 01 02:27:40 octopi webcamd[731]: /dev/video2
May 01 02:27:40 octopi webcamd[731]: /dev/video3
May 01 02:27:40 octopi webcamd[731]: config file='/boot/octopi.txt':USB device was not set in options, start MJPG-streamer with the first found video device: /dev/video0
May 01 02:27:40 octopi root[780]: Starting USB webcam
May 01 02:27:40 octopi webcamd[731]: <13>May 1 02:27:40 root: Starting USB webcam
May 01 02:27:40 octopi webcamd[731]: Running ./mjpg_streamer -o output_http.so -w ./www-octopi -p 8080 -i input_uvc.so -d /dev/endoscopecam -r 640x480 -f 30 -y
May 01 02:27:40 octopi mjpg_streamer[781]: MJPG-streamer [781]: starting application
May 01 02:27:40 octopi mjpg_streamer[781]: MJPG-streamer [781]: MJPG Streamer Version: git rev: 501f6362c5afddcfb41055f97ae484252c85c912
May 01 02:27:40 octopi webcamd[731]: MJPG Streamer Version: git rev: 501f6362c5afddcfb41055f97ae484252c85c912
May 01 02:27:40 octopi webcamd[731]: i: Using V4L2 device.: /dev/video3
May 01 02:27:40 octopi webcamd[731]: i: Desired Resolution: 640 x 480
May 01 02:27:40 octopi webcamd[731]: i: Frames Per Second.: 30
May 01 02:27:40 octopi webcamd[731]: i: Format............: YUYV
May 01 02:27:40 octopi webcamd[731]: i: JPEG Quality......: 80
May 01 02:27:40 octopi webcamd[731]: i: TV-Norm...........: DEFAULT
May 01 02:27:40 octopi mjpg_streamer[781]: MJPG-streamer [781]: Using V4L2 device.: /dev/video3
May 01 02:27:40 octopi webcamd[731]: Unable to set format: 1448695129 res: 640x480
May 01 02:27:40 octopi webcamd[731]: Init v4L2 failed !! exit fatal
May 01 02:27:40 octopi webcamd[731]: i: init_VideoIn failed
May 01 02:27:40 octopi mjpg_streamer[781]: MJPG-streamer [781]: Desired Resolution: 640 x 480
May 01 02:27:40 octopi mjpg_streamer[781]: MJPG-streamer [781]: Frames Per Second.: 30
May 01 02:27:40 octopi mjpg_streamer[781]: MJPG-streamer [781]: Format............: YUYV
May 01 02:27:40 octopi mjpg_streamer[781]: MJPG-streamer [781]: JPEG Quality......: 80
May 01 02:27:40 octopi mjpg_streamer[781]: MJPG-streamer [781]: TV-Norm...........: DEFAULT
May 01 02:27:40 octopi mjpg_streamer[781]: MJPG-streamer [781]: init_VideoIn failed
May 01 02:27:41 octopi webcamd[731]: Done bring up all configured video device
May 01 02:27:41 octopi webcamd[731]: Goodbye...
May 01 02:27:41 octopi systemd[1]: webcamd.service: Succeeded.
May 01 02:27:41 octopi systemd[1]: Started the OctoPi webcam daemon with the user specified config.
May 01 02:27:41 octopi systemd[1]: webcamd.service: Service RestartSec=100ms expired, scheduling restart.
May 01 02:27:41 octopi systemd[1]: webcamd.service: Scheduled restart job, restart counter is at 5.
May 01 02:27:41 octopi systemd[1]: Stopped the OctoPi webcam daemon with the user specified config.
May 01 02:27:41 octopi systemd[1]: webcamd.service: Start request repeated too quickly.
May 01 02:27:41 octopi systemd[1]: webcamd.service: Failed with result 'start-limit-hit'.
May 01 02:27:41 octopi systemd[1]: Failed to start the OctoPi webcam daemon with the user specified config.

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

  • OctoPrint 1.6.0
  • Python 3.7.3
  • OctoPi 0.17.0

You could try this guide to setup your MJPG Streamer instances, the video you've linked to is from 2018 and likely quite out of date.

Thank you Charlie for the feedback!

I posted the wrong video. The one that I actually followed was this one which was from early 2020: https://www.youtube.com/watch?v=SdDq1wfTn0A&t=870s&ab_channel=ChrisRiley

I checked the guide you posted which creates multiple octopi.txt instances instead of editing the /root/bin/webcamd as the video suggested, but I don't see how it will be any different since at the end of the day, both ways are calling mjpg-streamer with the same attributes.

Nevertheless I will give it a try. So far I have edited octopi.txt properly and I've also created the /boot/octopi.conf.d. I am now looking on how to revert the changes made in /root/bin/.

I will post an update soon.

Ok I followed the guide. Things got more weird than before.

In my previous configuration, cameras always streamed to the same URL. Now it randomly assigns a webcam to a port (8080 and 8081).

Again, like before, each reboot has a random result.

Example 1:

After a reboot, I saw the following in var/log/messages:

May  2 20:40:07 octopi root: Starting USB webcam
May  2 20:40:07 octopi MJPG-streamer [498]: starting application
May  2 20:40:07 octopi MJPG-streamer [498]: MJPG Streamer Version: git rev: 501f6362c5afddcfb41055f97ae484252c85c912
May  2 20:40:07 octopi MJPG-streamer [498]: Using V4L2 device.: /dev/video3
May  2 20:40:07 octopi MJPG-streamer [498]: Desired Resolution: 640 x 480
May  2 20:40:07 octopi MJPG-streamer [498]: Frames Per Second.: 30
May  2 20:40:07 octopi MJPG-streamer [498]: Format............: YUYV
May  2 20:40:07 octopi MJPG-streamer [498]: JPEG Quality......: 80
May  2 20:40:07 octopi MJPG-streamer [498]: TV-Norm...........: DEFAULT
May  2 20:40:07 octopi kernel: [    8.630175] Adding 102396k swap on /var/swap.  Priority:-2 extents:1 across:102396k SSFS
May  2 20:40:07 octopi MJPG-streamer [498]: init_VideoIn failed
May  2 20:40:07 octopi kernel: [    8.784308] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
May  2 20:40:07 octopi kernel: [    8.784324] brcmfmac: power management disabled
May  2 20:40:07 octopi kernel: [    9.079783] bcmgenet: Skipping UMAC reset
May  2 20:40:07 octopi kernel: [    9.171763] bcmgenet fd580000.genet: configuring instance for external RGMII (no delay)
May  2 20:40:07 octopi kernel: [    9.172113] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
May  2 20:40:08 octopi root: Starting USB webcam
May  2 20:40:08 octopi MJPG-streamer [562]: starting application
May  2 20:40:08 octopi MJPG-streamer [562]: MJPG Streamer Version: git rev: 501f6362c5afddcfb41055f97ae484252c85c912
May  2 20:40:08 octopi MJPG-streamer [562]: Using V4L2 device.: /dev/video1
May  2 20:40:08 octopi MJPG-streamer [562]: Desired Resolution: 1280 x 720
May  2 20:40:08 octopi MJPG-streamer [562]: Frames Per Second.: 30
May  2 20:40:08 octopi MJPG-streamer [562]: Format............: JPEG
May  2 20:40:08 octopi MJPG-streamer [562]: TV-Norm...........: DEFAULT
May  2 20:40:08 octopi MJPG-streamer [562]: init_VideoIn failed
May  2 20:40:08 octopi kernel: [   10.231619] bcmgenet fd580000.genet eth0: Link is Down

Right after the above, there was an infinite loop of the below messages until I rebooted again:

May  2 20:40:09 octopi root: Starting USB webcam
May  2 20:40:09 octopi MJPG-streamer [594]: starting application
May  2 20:40:09 octopi MJPG-streamer [594]: MJPG Streamer Version: git rev: 501f6362c5afddcfb41055f97ae484252c85c912
May  2 20:40:09 octopi MJPG-streamer [594]: Using V4L2 device.: /dev/video3
May  2 20:40:09 octopi MJPG-streamer [594]: Desired Resolution: 640 x 480
May  2 20:40:09 octopi MJPG-streamer [594]: Frames Per Second.: 30
May  2 20:40:09 octopi MJPG-streamer [594]: Format............: YUYV
May  2 20:40:09 octopi MJPG-streamer [594]: JPEG Quality......: 80
May  2 20:40:09 octopi MJPG-streamer [594]: TV-Norm...........: DEFAULT
May  2 20:40:09 octopi MJPG-streamer [594]: init_VideoIn failed
May  2 20:40:10 octopi root: Starting USB webcam
May  2 20:40:10 octopi MJPG-streamer [611]: starting application
May  2 20:40:10 octopi MJPG-streamer [611]: MJPG Streamer Version: git rev: 501f6362c5afddcfb41055f97ae484252c85c912
May  2 20:40:10 octopi MJPG-streamer [611]: Using V4L2 device.: /dev/video1
May  2 20:40:10 octopi MJPG-streamer [611]: Desired Resolution: 1280 x 720
May  2 20:40:10 octopi MJPG-streamer [611]: Frames Per Second.: 30
May  2 20:40:10 octopi MJPG-streamer [611]: Format............: JPEG
May  2 20:40:10 octopi MJPG-streamer [611]: TV-Norm...........: DEFAULT
May  2 20:40:10 octopi MJPG-streamer [611]: init_VideoIn failed
May  2 20:40:12 octopi root: Starting USB webcam

Of course, no camera was working.

As I mentioned, I rebooted to end the infinite loop. The logs look like this:

May  2 20:46:51 octopi root: Starting USB webcam
May  2 20:46:51 octopi MJPG-streamer [496]: starting application
May  2 20:46:51 octopi MJPG-streamer [496]: MJPG Streamer Version: git rev: 501f6362c5afddcfb41055f97ae484252c85c912
May  2 20:46:51 octopi kernel: [    8.439314] Adding 102396k swap on /var/swap.  Priority:-2 extents:1 across:102396k SSFS
May  2 20:46:51 octopi MJPG-streamer [496]: Using V4L2 device.: /dev/video3
May  2 20:46:51 octopi MJPG-streamer [496]: Desired Resolution: 640 x 480
May  2 20:46:51 octopi MJPG-streamer [496]: Frames Per Second.: 30
May  2 20:46:51 octopi MJPG-streamer [496]: Format............: YUYV
May  2 20:46:51 octopi MJPG-streamer [496]: JPEG Quality......: 80
May  2 20:46:51 octopi MJPG-streamer [496]: TV-Norm...........: DEFAULT
May  2 20:46:51 octopi MJPG-streamer [496]: init_VideoIn failed
May  2 20:46:51 octopi kernel: [    8.663097] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
May  2 20:46:51 octopi kernel: [    8.663113] brcmfmac: power management disabled
May  2 20:46:51 octopi kernel: [    8.932252] bcmgenet: Skipping UMAC reset
May  2 20:46:51 octopi kernel: [    9.031749] bcmgenet fd580000.genet: configuring instance for external RGMII (no delay)
May  2 20:46:51 octopi kernel: [    9.032093] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
May  2 20:46:52 octopi root: Starting USB webcam
May  2 20:46:52 octopi MJPG-streamer [562]: starting application
May  2 20:46:52 octopi MJPG-streamer [562]: MJPG Streamer Version: git rev: 501f6362c5afddcfb41055f97ae484252c85c912
May  2 20:46:52 octopi MJPG-streamer [562]: Using V4L2 device.: /dev/video0
May  2 20:46:52 octopi MJPG-streamer [562]: Desired Resolution: 1280 x 720
May  2 20:46:52 octopi MJPG-streamer [562]: Frames Per Second.: 30
May  2 20:46:52 octopi MJPG-streamer [562]: Format............: JPEG
May  2 20:46:52 octopi MJPG-streamer [562]: TV-Norm...........: DEFAULT
May  2 20:46:52 octopi MJPG-streamer [562]: www-folder-path......: ./www-octopi/
May  2 20:46:52 octopi MJPG-streamer [562]: HTTP TCP port........: 8080
May  2 20:46:52 octopi MJPG-streamer [562]: HTTP Listen Address..: (null)
May  2 20:46:52 octopi MJPG-streamer [562]: username:password....: disabled
May  2 20:46:52 octopi MJPG-streamer [562]: commands.............: disabled
May  2 20:46:52 octopi MJPG-streamer [562]: starting input plugin input_uvc.so
May  2 20:46:52 octopi MJPG-streamer [562]: starting output plugin: output_http.so (ID: 00)

With the above, one of my cameras started working, but:

  1. I noticed that the resolutions are the ones I've set in octopi.txt, but the devices are using /dev/video* instead of the device name I provided in camera_usb_options:

/boot/octopi.txt
camera_usb_options="-d /dev/endoscopecam -r 640x480 -f 30 -y"

/boot/octopi.conf.d/overviewCam.txt
camera_usb_options="-d /dev/overviewcam -r 1280x720 -f 30"

I know the guide says to identify the devices by their IDs, but my device IDs have very weird names as you can see below so i just used their symbolic links in /dev

pi@octopi:~ $ ls /dev/v4l/by-id
usb-Generic_USB2.0_PC_CAMERA-video-index0  usb-Sonix_Technology_Co.__Ltd._USB_Live_camera_SN0001-video-index0
usb-Generic_USB2.0_PC_CAMERA-video-index1  usb-Sonix_Technology_Co.__Ltd._USB_Live_camera_SN0001-video-index1
pi@octopi:~ $
  1. My setup is like this:

octopi.txt is configured for the endoscope cam and should stream on port 8080
octopi.conf.d/overviewCam.txt is configured for a normal usb camera and should stream on port 8081

After the last reboot I showed above, the overview camera is streaming on port 8080, which shouldn't (maybe because the endoscope camera failed to start?).

  1. Executing "sudo service webcamd status" I can see the following:

pi@octopi:~ $ sudo service webcamd status
● 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 Sun 2021-05-02 21:09:19 EEST; 49s ago
Process: 404 ExecStart=/root/bin/webcamd (code=exited, status=0/SUCCESS)
Main PID: 504 (mjpg_streamer)
Tasks: 3 (limit: 4915)
Memory: 4.3M
CGroup: /system.slice/webcamd.service
└─504 ./mjpg_streamer -o output_http.so -w ./www-octopi -n -i input_uvc.so -d /dev/endoscopecam -r 640x480 -f 30 -y -d /dev/video0

May 02 21:09:18 octopi mjpg_streamer[565]: MJPG-streamer [565]: Format............: JPEG
May 02 21:09:18 octopi webcamd[404]: i: TV-Norm...........: DEFAULT
May 02 21:09:18 octopi mjpg_streamer[565]: MJPG-streamer [565]: TV-Norm...........: DEFAULT
May 02 21:09:18 octopi webcamd[404]: Unable to set format: 1196444237 res: 1280x720
May 02 21:09:18 octopi webcamd[404]: Init v4L2 failed !! exit fatal
May 02 21:09:18 octopi webcamd[404]: i: init_VideoIn failed
May 02 21:09:18 octopi mjpg_streamer[565]: MJPG-streamer [565]: init_VideoIn failed
May 02 21:09:19 octopi webcamd[404]: Done bring up all configured video device
May 02 21:09:19 octopi webcamd[404]: Goodbye...
May 02 21:09:19 octopi systemd[1]: Started the OctoPi webcam daemon with the user specified config.

Notice that mjpg_streamer has started with two devices: /dev/endoscopecam and /dev/video0 . Is this normal? I can disable that by editing the /root/bin/webcamd and I actually tried it but nothing changed. The second device disappeared of course but no improvement on whether the cameras work consistently or not.

Any help would be greatly appreciated.