Can't get USB webcam to work

Camera model
Generic, this camera worked on a previous OctoPrint on a different Raspberry Pi

What is the problem?
I can't get the video to show up on OctoPrint, and I can't get any of the diagnostics I've seen to show me anything.
I've also tried a Logitech Brio with the same results.

What did you already try to solve it?
I've read topics here, and tried various options in the config files, octopi.txt
octoprint-systeminfo-20230409132338.zip (10.0 KB)

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

Additional information about your setup (OctoPrint version, OctoPi version, ...)
OctoPrint V 1.8.6
OctoPi Version 0.18.0, running on Raspberry Pi 4 Model B Rev 1.4

  • open a linux shell session using a tool like putty,and log in to the Pi
  • unplug the webcam
  • run sudo dmesg -w

you should see info on the webcam appear.

Copy and paste that as a reply.

I'm having a similar issue but octoprint is a unraid docker container. Everything works but the camera. I can see the usb device in unraid but can't get an image in octo.
I see this in the container logs. Running dmesg -w from the console dose not seem to work for me (get a can't access buffer error.
octoprint-systeminfo-20231015232514.zip (11.7 KB)

MJPG Streamer Version.: 2.0
i: Using V4L2 device.: (null)
i: Desired Resolution: 720 x 1280
i: Frames Per Second.: -1
i: Format............: YUYV
i: JPEG Quality......: 80
i: TV-Norm...........: DEFAULT
i: init_VideoIn failed

Hi Griffon,

the issue with running demsg is normally a permission problem with your current user, so in the console you would typically need elevated permissions that can be obtained running the command with sudo that elevated your permission levels to allow the command to be executed.

A camera not working in a container typically results from the lack of permissions for the container to access the hardware.

If you run 'lsusb' in the console, you should see a lust of us devices. In my case:

jattie@hp-linux:~$ lsusb
Bus 001 Device 005: ID 045e:0810 Microsoft Corp. LifeCam HD-3000

This shows my cameras and printers connected to the linux hardware instance.

These devices are mapped as dev under the dev folder and you can filter them using grep like this:

jattie@hp-linux:~$ ls -lR --color /dev/ |grep -iE "video"
crw-rw----  1 root video    81,     0 May 19 10:36 video0
crw-rw----  1 root video    81,     1 May 19 10:36 video1
crw-rw----  1 root video    81,     2 May 19 10:36 video2
crw-rw----  1 root video    81,     3 May 19 10:36 video3
crw-rw----  1 root video    81,     4 May 19 10:36 video4
crw-rw----  1 root video    81,     5 May 19 10:36 video5
lrwxrwxrwx 1 root root  9 May 19 10:36 81:0 -> ../video0
lrwxrwxrwx 1 root root  9 May 19 10:36 81:1 -> ../video1
lrwxrwxrwx 1 root root  9 May 19 10:36 81:2 -> ../video2
lrwxrwxrwx 1 root root  9 May 19 10:36 81:3 -> ../video3
lrwxrwxrwx 1 root root  9 May 19 10:36 81:4 -> ../video4
lrwxrwxrwx 1 root root  9 May 19 10:36 81:5 -> ../video5
lrwxrwxrwx 1 root root 12 May 19 10:36 usb-Intel_R__RealSense_TM__3D_Camera__Front_F200__Intel_R__RealSense_TM__3D_Camera__Front_F200__032150301106-video-index00
lrwxrwxrwx 1 root root 12 May 19 10:36 usb-Intel_R__RealSense_TM__3D_Camera__Front_F200__Intel_R__RealSense_TM__3D_Camera__Front_F200__032150301106-video-index11
lrwxrwxrwx 1 root root 12 May 19 10:36 usb-Microsoft_Microsoft®_LifeCam_HD-3000-video-index0 -> ../../video4
lrwxrwxrwx 1 root root 12 May 19 10:36 usb-Microsoft_Microsoft®_LifeCam_HD-3000-video-index1 -> ../../video5
lrwxrwxrwx 1 root root 12 May 19 10:36 pci-0000:00:14.0-usb-0:2:1.0-video-index0 -> ../../video4
lrwxrwxrwx 1 root root 12 May 19 10:36 pci-0000:00:14.0-usb-0:2:1.0-video-index1 -> ../../video5
lrwxrwxrwx 1 root root 12 May 19 10:36 pci-0000:00:14.0-usb-0:3:1.0-video-index0 -> ../../video0
lrwxrwxrwx 1 root root 12 May 19 10:36 pci-0000:00:14.0-usb-0:3:1.0-video-index1 -> ../../video1
lrwxrwxrwx 1 root root 12 May 19 10:36 pci-0000:00:14.0-usb-0:3:1.2-video-index0 -> ../../video2
lrwxrwxrwx 1 root root 12 May 19 10:36 pci-0000:00:14.0-usb-0:3:1.2-video-index1 -> ../../video3

Video mappings can be elusive and I figured out through trail and error which ones I can actually stream from and the two important ones in my case was:

lrwxrwxrwx 1 root root 12 May 19 10:36 usb-Microsoft_Microsoft®_LifeCam_HD-3000-video-index0 -> ../../video4
lrwxrwxrwx 1 root root 12 May 19 10:36 usb-Microsoft_Microsoft®_LifeCam_HD-3000-video-index1 -> ../../video5

video4 allows me to stream successfully.

jattie@hp-linux:~$ ls -lR --color /dev/video4
crw-rw---- 1 root video 81, 4 May 19 10:36 /dev/video4

This last step show an import user name, on my distribution of Linux it is video, so video4 show that the root user allows video access to the camera stream.

This is normally the part where the video fails in the container. The container does not have all the mappings and if it does it doesn't have the right permissions inside to container to access the video stream.

What you need inside the container is to find the mapped video feed passed through to your container:

Again, in mu case:

root@webcam:~# ls -l /dev/vid*
crw-rw---- 1 root video 81, 4 May 26 13:25 /dev/video0

So you can see I have the video user set up with access to video0 that is mapped from video4 in the host os.

I am not a docker user, but reading the documents, you can achieve this passthrough like this:

docker run --device=/dev/video0:/dev/video0 --group-add video <image_name>

The equivalent command to dmesg inside a Docker container is docker logs <container_name_or_id>.

Here's an example command:

docker logs <container_name_or_id>

Replace <container_name_or_id> with the name or ID of the Docker container you want to view the logs for.

This command will display the logs of the specified Docker container, including any kernel messages that would typically be shown by dmesg on the host machine.

The docker experts here can probably give you better guidance.

1 Like

Thank you.
Right so the container is pretty bare bones. Not al lunix commands I would expect to work do. Like lsusb.
I do pass /dev/video0. See config image. and I see it in the container. I also see the camera in serial by-id.

ls /dev/serial/by-id

usb-1a86_USB_Serial-if00-port0 usb-SHENZHEN_Fullhan_webcam_20200506-if04

I also have a ms lifecam laying around, I tried that and it shows up in unraid under /dev/v4l as two devices as well.

I setup a windows vm, and both cameras seem to work there through unraid.
Frustrating :stuck_out_tongue: still can't get any video into the container.

hi i had lots of issues with my usb webcam until i removed opctoprint and tried octoprint_deploy, it was so much easier for me.
martin

Hi Griffon,

I can not see anything obvious from what you shared. The problem with containers and virtual environments is all the many different ways that get permissions from the hosting OS. The different OS implementations rarely work the same and probably down to how windows share resources vs Linux sharing resources and setting the permissions for that.

First step to check is the permissions assigned for /dev/video0 in your container.

root@webcam:~# ls -l /dev/vid*
crw-rw---- 1 root video 81, 4 May 26 13:25 /dev/video0

You should see permissions set for this resource like this: crw-rw---- and then you should see the the user and group assignments like this: root video.

Can you check what your looks like.

1 Like

I am running octopi, I had configured a raspi camera (OV5647) with no problems. I recently added a USB camera (logi C920) and it replaced my original (raspi) camera feed. Anyone can help me setup both cameras on Multicam plugin?

I searched the net for help but haven't gotten any success.

Here is my octo.txt file:

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"

Heads-up: The "input_raspicam" input module of mjpg-streamer is no longer supported.

Raspicam support is now available on the "input_uvc" module.

Additional options to supply to MJPG Streamer for the USB camera

See Available mjpg-streamer configuration options - Guides - OctoPrint Community Forum for available options

Defaults to a resolution of 640x480 px and a framerate of 10 fps

camera_usb_options="-r 640x480 -f 10"

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: Issues · guysoft/OctoPi · GitHub

#additional_brokenfps_usb_devices=()

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"

Configuration of network monitoring

This enables network monitoring for wifi connections with a simple ping test.

If connection terminates by variable reasons system tries to restart the wifi connection to reestablish a connection.

The connection test is done every minute.

By default it is disabled (0 = off / 1 = on)

destination_host can be an ip address or a hostname (for hostname ensure dns resosultion is working correctly)

enable_network_monitor=0
destination_host=192.168.1.1

EXPERIMENTAL

Support for different streamer types.

Available options:

mjpeg [default] - stable MJPG-streamer

hls - experimental FFMPEG HLS streamer

Hello @Hussain_Al-Khalaf !

??

And Please: When you post code, either do it as file

Upload

or use the Preformatted Text feature in the forum editor.

Format