Cant resolve multi cam setup. need help!

logitech c920
logitech c922

What is the problem?
i cant get either camera to show up following @Charlie_Powell guide after doing a fresh install of octo print and octo dash on a new micro sd.

What did you already try to solve it?
ensured i had them both inserted correctly. ensured I followed everything in the guide.

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

systemctl status webcamd.service
● webcamd.service - the OctoPi webcam daemon with the user specified config
Loaded: loaded (/etc/systemd/system/webcamd.service; enabled; vendor preset: enabled)
Active: activating (start) since Mon 2021-08-02 21:41:43 EDT; 46s ago
Cntrl PID: 1492 (webcamd)
Tasks: 2 (limit: 4915)
CGroup: /system.slice/webcamd.service
β”œβ”€1492 /bin/bash /root/bin/webcamd
└─1532 sleep 120

Aug 02 21:41:43 octopi systemd[1]: Starting the OctoPi webcam daemon with the user specified config...
Aug 02 21:41:43 octopi root[1528]: Starting USB webcam
Aug 02 21:41:43 octopi mjpg_streamer[1529]: MJPG-streamer [1529]: starting application
Aug 02 21:41:43 octopi mjpg_streamer[1529]: MJPG-streamer [1529]: MJPG Streamer Version: git rev: 5554f42c352ecfa7edaec6fc51e507afce605a34
Aug 02 21:41:43 octopi mjpg_streamer[1529]: MJPG-streamer [1529]: Using V4L2 device.: /dev/video1
Aug 02 21:41:43 octopi mjpg_streamer[1529]: MJPG-streamer [1529]: Desired Resolution: 1920 x 1080
Aug 02 21:41:43 octopi mjpg_streamer[1529]: MJPG-streamer [1529]: Frames Per Second.: 15
Aug 02 21:41:43 octopi mjpg_streamer[1529]: MJPG-streamer [1529]: Format............: JPEG
Aug 02 21:41:43 octopi mjpg_streamer[1529]: MJPG-streamer [1529]: TV-Norm...........: DEFAULT
Aug 02 21:41:43 octopi mjpg_streamer[1529]: MJPG-streamer [1529]: init_VideoIn failed

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

journalctl -xe

-- A start job for unit webcamd.service has finished with a failure.

-- The job identifier is 1214 and the job result is failed.
Aug 02 21:41:43 octopi systemd[1]: webcamd.service: Service RestartSec=1s expired, scheduling restart.
Aug 02 21:41:43 octopi systemd[1]: webcamd.service: Scheduled restart job, restart counter is at 4.
-- Subject: Automatic restarting of a unit has been scheduled
-- Defined-By: systemd
-- Support: Debian -- Support

-- Automatic restarting of the unit webcamd.service has been scheduled, as the result for
-- the configured Restart= setting for the unit.
Aug 02 21:41:43 octopi systemd[1]: Stopped the OctoPi webcam daemon with the user specified config.
-- Subject: A stop job for unit webcamd.service has finished
-- Defined-By: systemd
-- Support: Debian -- Support

-- A stop job for unit webcamd.service has finished.

-- The job identifier is 1271 and the job result is done.
Aug 02 21:41:43 octopi systemd[1]: Starting the OctoPi webcam daemon with the user specified config...
-- Subject: A start job for unit webcamd.service has begun execution
-- Defined-By: systemd
-- Support: Debian -- Support

-- A start job for unit webcamd.service has begun execution.

-- The job identifier is 1271.
Aug 02 21:41:43 octopi root[1528]: Starting USB webcam
Aug 02 21:41:43 octopi mjpg_streamer[1529]: MJPG-streamer [1529]: starting application
Aug 02 21:41:43 octopi mjpg_streamer[1529]: MJPG-streamer [1529]: MJPG Streamer Version: git rev: 5554f42c352ecfa7edaec6fc51e507afce605a34
Aug 02 21:41:43 octopi mjpg_streamer[1529]: MJPG-streamer [1529]: Using V4L2 device.: /dev/video1
Aug 02 21:41:43 octopi mjpg_streamer[1529]: MJPG-streamer [1529]: Desired Resolution: 1920 x 1080
Aug 02 21:41:43 octopi mjpg_streamer[1529]: MJPG-streamer [1529]: Frames Per Second.: 15
Aug 02 21:41:43 octopi mjpg_streamer[1529]: MJPG-streamer [1529]: Format............: JPEG
Aug 02 21:41:43 octopi mjpg_streamer[1529]: MJPG-streamer [1529]: TV-Norm...........: DEFAULT
Aug 02 21:41:43 octopi mjpg_streamer[1529]: MJPG-streamer [1529]: init_VideoIn failed
Aug 02 21:43:13 octopi systemd[1]: webcamd.service: Start operation timed out. Terminating.
Aug 02 21:43:13 octopi systemd[1]: webcamd.service: Failed with result 'timeout'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: Debian -- Support

-- The unit webcamd.service has entered the 'failed' state with result 'timeout'.
Aug 02 21:43:13 octopi systemd[1]: Failed to start the OctoPi webcam daemon with the user specified config.
-- Subject: A start job for unit webcamd.service has failed
-- Defined-By: systemd
-- Support: Debian -- Support

-- A start job for unit webcamd.service has finished with a failure.

-- The job identifier is 1271 and the job result is failed.
Aug 02 21:43:15 octopi systemd[1]: webcamd.service: Service RestartSec=1s expired, scheduling restart.
Aug 02 21:43:15 octopi systemd[1]: webcamd.service: Scheduled restart job, restart counter is at 5.
-- Subject: Automatic restarting of a unit has been scheduled
-- Defined-By: systemd
-- Support: Debian -- Support

-- Automatic restarting of the unit webcamd.service has been scheduled, as the result for
-- the configured Restart= setting for the unit.
Aug 02 21:43:15 octopi systemd[1]: Stopped the OctoPi webcam daemon with the user specified config.
-- Subject: A stop job for unit webcamd.service has finished
-- Defined-By: systemd
-- Support: Debian -- Support

-- A stop job for unit webcamd.service has finished.

-- The job identifier is 1328 and the job result is done.
Aug 02 21:43:15 octopi systemd[1]: Starting the OctoPi webcam daemon with the user specified config...
-- Subject: A start job for unit webcamd.service has begun execution
-- Defined-By: systemd
-- Support: Debian -- Support

-- A start job for unit webcamd.service has begun execution.

-- The job identifier is 1328.
Aug 02 21:43:15 octopi root[1579]: Starting USB webcam
Aug 02 21:43:15 octopi mjpg_streamer[1580]: MJPG-streamer [1580]: starting application
Aug 02 21:43:15 octopi mjpg_streamer[1580]: MJPG-streamer [1580]: MJPG Streamer Version: git rev: 5554f42c352ecfa7edaec6fc51e507afce605a34
Aug 02 21:43:15 octopi mjpg_streamer[1580]: MJPG-streamer [1580]: Using V4L2 device.: /dev/video1
Aug 02 21:43:15 octopi mjpg_streamer[1580]: MJPG-streamer [1580]: Desired Resolution: 1920 x 1080
Aug 02 21:43:15 octopi mjpg_streamer[1580]: MJPG-streamer [1580]: Frames Per Second.: 15
Aug 02 21:43:15 octopi mjpg_streamer[1580]: MJPG-streamer [1580]: Format............: JPEG
Aug 02 21:43:15 octopi mjpg_streamer[1580]: MJPG-streamer [1580]: TV-Norm...........: DEFAULT
Aug 02 21:43:15 octopi mjpg_streamer[1580]: MJPG-streamer [1580]: init_VideoIn failed

could anyone help me please ?

edit: reinstalled everything again and never changed resolution etc... still nothing

Hi,

In order to be able to help you, could you please include both the octoprint.txt and webcam2.txt file contents, only the parts about the webcams would be enough ?

Also, the output of ls /dev/v4l/by-id would help for now, as some webcams offer multiple devices, and you might be trying to use one that is not suitable for streaming.

If you can manage, the output of journalctl -e -u webcamd.service, starting from the last --- Configuration: ---------------------------- line would be helpful, even if some of the information from the above would be duplicated

Thanks

1 Like

here is the text for octoprint.txt

### Windows users: To edit this file use Notepad++, VSCode, Atom or SublimeText.
### Do not use Notepad or WordPad.

### MacOSX users: If you use Textedit to edit this file make sure to use
### "plain text format" and "disable smart quotes" in "Textedit > Preferences"

### Configure which camera to use
#
# Available options are:
# - auto: tries first usb webcam, if that's not available tries raspi cam
# - usb: only tries usb webcam
# - raspi: only tries raspi cam
#
# Defaults to auto
#
camera="usb"

### Additional options to supply to MJPG Streamer for the USB camera
#
# See https://faq.octoprint.org/mjpg-streamer-config for available options
#
# Defaults to a resolution of 640x480 px and a framerate of 10 fps
#
camera_usb_options="-r 640x480 -f 10 -d /dev/v4l/by-id/usb-046d_C922_Pro_Stream_Webcam_BDFE0F4F-video-index0"

### Additional webcam devices known to cause problems with -f
#
# Apparently there a some devices out there that with the current
# mjpg_streamer release do not support the -f parameter (for specifying
# the capturing framerate) and will just refuse to output an image if it
# is supplied.
#
# The webcam daemon will detect those devices by their USB Vendor and Product
# ID and remove the -f parameter from the options provided to mjpg_streamer.
#
# By default, this is done for the following devices:
#   Logitech C170 (046d:082b)
#   GEMBIRD (1908:2310)
#   Genius F100 (0458:708c)
#   Cubeternet GL-UPC822 UVC WebCam (1e4e:0102)
#
# Using the following option it is possible to add additional devices. If
# your webcam happens to show above symptoms, try determining your cam's
# vendor and product id via lsusb, activating the line below by removing # and
# adding it, e.g. for two broken cameras "aabb:ccdd" and "aabb:eeff"
#
#   additional_brokenfps_usb_devices=("aabb:ccdd" "aabb:eeff")
#
# If this fixes your problem, please report it back so we can include the device
# out of the box: https://github.com/guysoft/OctoPi/issues
#
#additional_brokenfps_usb_devices=()

### Additional options to supply to MJPG Streamer for the RasPi Cam
#
# See https://faq.octoprint.org/mjpg-streamer-config for available options.
#
# NOTE: Newer raspi cam modules are reporting as usb devices causing these
#       options to be ignored. Set `camera="raspi"` to avoid these issues.
#
# Defaults to 10fps
#
#camera_raspi_options="-fps 10"

### Configuration of camera HTTP output
#
# Usually you should NOT need to change this at all! Only touch if you
# know what you are doing and what the parameters mean.
#
# Below settings are used in the mjpg-streamer call like this:
#
#   -o "output_http.so -w $camera_http_webroot $camera_http_options"
#
# Current working directory is the mjpg-streamer base directory.
#
#camera_http_webroot="./www-octopi"
#camera_http_options="-n"

### EXPERIMENTAL
# Support for different streamer types.
#

and webcam2.txt

### Windows users: To edit this file use Notepad++, VSCode, Atom or SublimeText.
### Do not use Notepad or WordPad.

### MacOSX users: If you use Textedit to edit this file make sure to use
### "plain text format" and "disable smart quotes" in "Textedit > Preferences"

### Configure which camera to use
#
# Available options are:
# - auto: tries first usb webcam, if that's not available tries raspi cam
# - usb: only tries usb webcam
# - raspi: only tries raspi cam
#
# Defaults to auto
#
camera="usb"

### Additional options to supply to MJPG Streamer for the USB camera
#
# See https://faq.octoprint.org/mjpg-streamer-config for available options
#
# Defaults to a resolution of 640x480 px and a framerate of 10 fps
#
camera_usb_options="-r 640x480 -f 10 -d /dev/v4l/by-id/usb-046d_HD_Pro_Webcam_C920_A69AE6FF-video-index1"

### Additional webcam devices known to cause problems with -f
#
# Apparently there a some devices out there that with the current
# mjpg_streamer release do not support the -f parameter (for specifying
# the capturing framerate) and will just refuse to output an image if it
# is supplied.
#
# The webcam daemon will detect those devices by their USB Vendor and Product
# ID and remove the -f parameter from the options provided to mjpg_streamer.
#
# By default, this is done for the following devices:
#   Logitech C170 (046d:082b)
#   GEMBIRD (1908:2310)
#   Genius F100 (0458:708c)
#   Cubeternet GL-UPC822 UVC WebCam (1e4e:0102)
#
# Using the following option it is possible to add additional devices. If
# your webcam happens to show above symptoms, try determining your cam's
# vendor and product id via lsusb, activating the line below by removing # and
# adding it, e.g. for two broken cameras "aabb:ccdd" and "aabb:eeff"
#
#   additional_brokenfps_usb_devices=("aabb:ccdd" "aabb:eeff")
#
# If this fixes your problem, please report it back so we can include the device
# out of the box: https://github.com/guysoft/OctoPi/issues
#
#additional_brokenfps_usb_devices=()

### Additional options to supply to MJPG Streamer for the RasPi Cam
#
# See https://faq.octoprint.org/mjpg-streamer-config for available options.
#
# NOTE: Newer raspi cam modules are reporting as usb devices causing these
#       options to be ignored. Set `camera="raspi"` to avoid these issues.
#
# Defaults to 10fps
#
#camera_raspi_options="-fps 10"

### Configuration of camera HTTP output
#
# Usually you should NOT need to change this at all! Only touch if you
# know what you are doing and what the parameters mean.
#
# Below settings are used in the mjpg-streamer call like this:
#
#   -o "output_http.so -w $camera_http_webroot $camera_http_options"
#
# Current working directory is the mjpg-streamer base directory.
#
#camera_http_webroot="./www-octopi"
camera_http_options="-n -p 8081"

### EXPERIMENTAL
# Support for different streamer types.
#

pi@octopi:~ $ ls /dev/v4l/by-id
usb-046d_C922_Pro_Stream_Webcam_BDFE0F4F-video-index0  usb-046d_C922_Pro_Stream_Webcam_BDFE0F4F-video-index1  usb-046d_HD_Pro_Webcam_C920_A69AE6FF-video-index0  usb-046d_HD_Pro_Webcam_C920_A69AE6FF-video-index1

and lastly

-- Logs begin at Wed 2021-08-04 16:43:22 EDT, end at Wed 2021-08-04 18:41:38 EDT. --
Aug 04 16:43:27 octopi systemd[1]: Starting the OctoPi webcam daemon with the user specified config...
Aug 04 16:43:27 octopi root[584]: Starting USB webcam
Aug 04 16:43:27 octopi mjpg_streamer[585]: MJPG-streamer [585]: starting application
Aug 04 16:43:27 octopi mjpg_streamer[585]: MJPG-streamer [585]: MJPG Streamer Version: git rev: 5554f42c352ecfa7edaec6fc51e507afce605a34
Aug 04 16:43:27 octopi mjpg_streamer[585]: MJPG-streamer [585]: Using V4L2 device.: /dev/video2
Aug 04 16:43:27 octopi mjpg_streamer[585]: MJPG-streamer [585]: Desired Resolution: 640 x 480
Aug 04 16:43:27 octopi mjpg_streamer[585]: MJPG-streamer [585]: Frames Per Second.: 10
Aug 04 16:43:27 octopi mjpg_streamer[585]: MJPG-streamer [585]: Format............: JPEG
Aug 04 16:43:27 octopi mjpg_streamer[585]: MJPG-streamer [585]: TV-Norm...........: DEFAULT
Aug 04 16:43:27 octopi mjpg_streamer[585]: MJPG-streamer [585]: www-folder-path......: ./www-octopi/
Aug 04 16:43:27 octopi mjpg_streamer[585]: MJPG-streamer [585]: HTTP TCP port........: 8080
Aug 04 16:43:27 octopi mjpg_streamer[585]: MJPG-streamer [585]: HTTP Listen Address..: 127.0.0.1
Aug 04 16:43:27 octopi mjpg_streamer[585]: MJPG-streamer [585]: username:password....: disabled
Aug 04 16:43:27 octopi mjpg_streamer[585]: MJPG-streamer [585]: commands.............: disabled
Aug 04 16:43:27 octopi mjpg_streamer[585]: MJPG-streamer [585]: starting input plugin input_uvc.so
Aug 04 16:43:27 octopi mjpg_streamer[585]: MJPG-streamer [585]: starting output plugin: output_http.so (ID: 00)
Aug 04 16:43:28 octopi root[603]: Starting USB webcam
Aug 04 16:43:28 octopi mjpg_streamer[604]: MJPG-streamer [604]: starting application
Aug 04 16:43:28 octopi mjpg_streamer[604]: MJPG-streamer [604]: MJPG Streamer Version: git rev: 5554f42c352ecfa7edaec6fc51e507afce605a34
Aug 04 16:43:28 octopi mjpg_streamer[604]: MJPG-streamer [604]: Using V4L2 device.: /dev/video1
Aug 04 16:43:28 octopi mjpg_streamer[604]: MJPG-streamer [604]: Desired Resolution: 640 x 480
Aug 04 16:43:28 octopi mjpg_streamer[604]: MJPG-streamer [604]: Frames Per Second.: 10
Aug 04 16:43:28 octopi mjpg_streamer[604]: MJPG-streamer [604]: Format............: JPEG
Aug 04 16:43:28 octopi mjpg_streamer[604]: MJPG-streamer [604]: TV-Norm...........: DEFAULT
Aug 04 16:43:28 octopi mjpg_streamer[604]: MJPG-streamer [604]: init_VideoIn failed
Aug 04 16:43:29 octopi systemd[1]: Started the OctoPi webcam daemon with the user specified config.

There seems to be the problem you're encountering. Try replacing the index1 at the end by index0, in the webcam2.txt file.

As stated earlier, some webcams, such as the one you're using offer multiple devices (as you can see in the output of the ls command -- both cams offer the index0 and index1 devices). In this case, the index0 seems to offer video streaming capabilities, while the index1 doesn't.

You could check by inspecting the output of v4l2-ctl --all -d /dev/v4l/by-id/usb-046d_C922_Pro_Stream_Webcam_BDFE0F4F-video-index1 and comparing it to the output of v4l2-ctl --all -d /dev/v4l/by-id/usb-046d_C922_Pro_Stream_Webcam_BDFE0F4F-video-index0. The index0 should show Video capture under Device Caps, while the other may show Metadata Capture for instance.

Hope this helps you.

2 Likes

This is a good point, that I may add to the guide. Is it always that index0 version that would support video control, or is it more random and can't be depended on?

1 Like

wow that worked... i swear i thought i tried that already guess not... Thank you so much! and for future referance how do i access

@Charlie_Powell
For the models I've encountered (Microsoft Lifecam HD 5000 and a generic HD 1080p webcam, and the Logitechs in this case) it seems to be consistent that the index0 would support video control.

Although inspection of v4l2-ctl output will definitely answer that question though. You would have to search for the device with video capture capability. I'll try to read the docs to see if I can manage a one liner that could answer the question...

@justin1311
Sorry, I've made a typo, the command is v4l2-ctl. As I'm running OctoPrint on a Fedora system, this command is available through the v4l-utils package of the distro's package manager. The package name seems to be the same on Debian, and would be the same on raspbian which I presume is the distro used on a Rpi.

You could try apt-get install v4l-utils on the command prompt, and then you would get access to the command.

I'll edit previous posts to correct the typo

PS @Charlie_Powell
The shortest output that seems to answer the question is : v4l2-ctl --list-formats -d /dev/v4l/by-id/...-index0 which could output something like that :

$ v4l2-ctl --list-formats -d /dev/v4l/by-id/webcamid-index0
ioctl: VIDIOC_ENUM_FMT
	Type: Video Capture

	[0]: 'YUYV' (YUYV 4:2:2)
	[1]: 'MJPG' (Motion-JPEG, compressed)

while for the index1, it is :

$ v4l2-ctl --list-formats -k -d /dev/v4l/by-id/webcam-index1
ioctl: VIDIOC_ENUM_FMT
	Type: Video Capture

So piping the input to wc -l and checking whether the number of lines is strictly greater than 3 would work :

$ if [[ $(v4l2-ctl --list-formats -d /dev/v4l/by-id/webcamid-index0|wc -l) > 3 ]]; then echo "Video streaming supported"; else echo "Video streaming NOT supported"; fi;
Video streaming supported


$ if [[ $(v4l2-ctl --list-formats -d /dev/v4l/by-id/webcamid-index1|wc -l) > 3 ]]; then echo "Video streaming supported"; else echo "Video streaming NOT supported"; fi;
Video streaming NOT supported

You could then try

$ for i in $(ls /dev/v4l/by-id/); do if [[ $(v4l2-ctl --list-formats -d /dev/v4l/by-id/$i|wc -l) > 3 ]]; then echo "Device /dev/v4l/by-id/$i supports video streaming"; else echo "Device /dev/v4l/by-id/$i DOES NOT support video streaming"; fi; done;
Device /dev/v4l/by-id/webcamid0-index0 supports video streaming
Device /dev/v4l/by-id/webcamid0-index1 DOES NOT support video streaming
Device /dev/v4l/by-id/webcamid1-index0 supports video streaming
Device /dev/v4l/by-id/webcamid1-index1 DOES NOT support video streaming

Also, I'm considering sending a PR for the OctoPi project, in order to simplify multicam streaming handling. As MJPG Streamer is able to handle multiple input streams, and outputing them on the same port, I think it would simplify things. For instance, on my Fedora system, I only have a mjpg-streamer service that look like this :

[Unit]
Description=MJPG-streamer instance for octoprint webcam control
Wants=network-online.target
After=network-online.target systemd-udev-trigger.service dev-3dprinters-webcams-generic_1080p_front_webcam_stream0.device dev-3dprinters-webcams-microsoft_hd5000_zaxis_webcam_stream0.device
Requires=systemd-udev-trigger.service dev-3dprinters-webcams-microsoft_hd5000_zaxis_webcam_stream0.device dev-3dprinters-webcams-generic_1080p_front_webcam_stream0.device

[Service]
User=octoprint
Group=octoprint
Type=exec
ExecStart=/usr/local/bin/mjpg_streamer -i 'input_uvc.so -d /dev/3dprinters/webcams/microsoft_hd5000_zaxis_webcam_stream0 -r 1280x720' -i 'input_uvc.so -d /dev/3dprinters/webcams/generic_1080p_front_webcam_stream0 -r 1920x1080' -o 'output_http.so -p 8080 -l 127.0.0.1'

[Install]
WantedBy=multi-user.targer

It's a bit sophisticated as I added some udev rules to make symlinks in the /dev tree, and added the systemd tag to be able to wait on those devices to start the service, but it also exposes each stream on the http://127.0.0.1:8080/?action=stream_0 and http://127.0.0.1:8080/?action=stream_1 URLs, then mapped to the http://octoprint/webcams/?action=stream_(0|1) by Apache acting as a reverse proxy.

I find it better to start only one instance of mjpg-streamer instead on one per webcam.

1 Like