Raspberry Pi 4b Camera issues - workaround tips

Hi all, new here, I figured I'd share my experience so that others could benefit, and hopefully save a bunch of time.

I grabbed an Octopi Image(2019-09-26-octopi-buster-lite-0.17.0.img), used Etcher to write it, configured the octopi.txt and octopi-wpa-supplicant.txt, and stuck it in a brand new Raspberry Pi4b.
Booted up, was able to access the unit over ssh and the web browser, all good.

Figured I'd just start with the camera...
Tried an old ArduCam 13MP camera and had no, luck.
Looked for the /var/log/webcamd.log - never present.
Checked the ~/.octoprint/logs/octoprint.log and there is no mention of webcam.
Installed the Arducam drivers, in case that was it, didn't work.

Spent hours and hours digging around here in the forums over the course of a few weeks, to no avail (I did find other reports of the missing webcam.log though).

So I assumed the Arducam wasn't supported, which is fine, and plugged in a cheap NexiGo webcam instead.
Reconfigured /boot/octopi.txt for a usb cam, and rebooted.
No luck.

Read lots more, tried manually starting mjpg_streamer, and it worked right away...
Yet setting the same settings in /boot/octopi.txt didn't work.
Went digging around a bunch more and eventually found that OctoPi installs a System Service, webcamd.
BTW, found the service in the usual place

/etc/default/webcamd

that uses

/etc/init.d/webcamd

Which is all just a roundabout way of running

/root/bin/webcamd

Checked the systemctl status, and found:

$ sudo systemctl status webcamd
● 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 Sat 2020-10-17 18:22:51 PDT; 54s ago
Cntrl PID: 1169 (webcamd)
    Tasks: 2 (limit: 4915)
   Memory: 1020.0K
   CGroup: /system.slice/webcamd.service
           ├─1169 /bin/bash /root/bin/webcamd
           └─1185 sleep 120

Oct 17 18:22:51 octopi webcamd[1169]: -----------------------------------------------
Oct 17 18:22:51 octopi webcamd[1169]: Found video devices:
Oct 17 18:22:51 octopi webcamd[1169]: /dev/video0
Oct 17 18:22:51 octopi webcamd[1169]: /dev/video1
Oct 17 18:22:51 octopi webcamd[1169]: /dev/video10
Oct 17 18:22:51 octopi webcamd[1169]: /dev/video11
Oct 17 18:22:51 octopi webcamd[1169]: /dev/video12
Oct 17 18:22:51 octopi webcamd[1169]: readlink: invalid option -- 'r'
Oct 17 18:22:51 octopi webcamd[1169]: Try 'readlink --help' for more information.
Oct 17 18:22:51 octopi webcamd[1169]: Scan again in two minutes

So its trying to check all the video devices and choking.

Found you can also see the whole log file (helps when systemctl status doesn't show enough lines) with

journalctl -u webcamd

Read around some more, and tried mjpg_streamer again adding a specific device (-d /dev/video0), and it kept working.
So added "-d /dev/video0" to my "camera_usb_options" in /boot/octopi.txt
Rebooted and it now works.

No clue how to fix the readlink issue, but onto setting up the printer..
Hopefully, it will go much more smoothly.

So the arducam is basically a raspicam v2 if I'm not mistaken, so it should have worked fine with the proper settings. Working with someone in Discord they were having similar issues and it turned out it was more than likely just needing an update.

sudo apt update
sudo apt upgrade

some users have reported having to use -softfps 10 instead of -f 10 for their custom raspicam they were using, maybe that might help.

The -r makes me think it's still trying to load the usb_camera_options for resolution?

I took the Arducam off before switching to the USB webcam.
The error is shown with the USB webcam attached, I may put the Arducam back and try again now that I know more how to find the info to debug.

I found another tool that seems to provide some more info on webcam devices

sudo apt-get install uvcdynctrl

It walks each of the /dev/video* entries and tries to provide info on them.

$ uvcdynctrl -l
[libwebcam] Invalid V4L2 control type encountered: ctrl_id = 0x00980001, name = 'User Controls', type = 6
[libwebcam] Invalid or unsupported V4L2 control encountered: ctrl_id = 0x00980001, name = 'User Controls'
[libwebcam] Unknown V4L2 user control ID encountered: 0x00980927 (V4L2_CID_USER_BASE + 39)
[libwebcam] Invalid V4L2 control type encountered: ctrl_id = 0x00980001, name = 'User Controls', type = 6
[libwebcam] Invalid or unsupported V4L2 control encountered: ctrl_id = 0x00980001, name = 'User Controls'
[libwebcam] Unknown V4L2 user control ID encountered: 0x0098090E (V4L2_CID_USER_BASE + 14)
[libwebcam] Unknown V4L2 user control ID encountered: 0x0098090F (V4L2_CID_USER_BASE + 15)
[libwebcam] Invalid V4L2 control type encountered: ctrl_id = 0x009F0001, name = 'Image Processing Controls', type = 6
[libwebcam] Invalid or unsupported V4L2 control encountered: ctrl_id = 0x009F0001, name = 'Image Processing Controls'
[libwebcam] Unknown V4L2 control ID encountered: 0x009F0905
[libwebcam] Invalid or unsupported V4L2 control encountered: ctrl_id = 0x009F0905, name = 'Digital Gain'
[libwebcam] Invalid V4L2 control type encountered: ctrl_id = 0x00990001, name = 'Codec Controls', type = 6
[libwebcam] Invalid or unsupported V4L2 control encountered: ctrl_id = 0x00990001, name = 'Codec Controls'
[libwebcam] Unknown V4L2 MPEG control ID encountered: 0x009909CE (V4L2_CID_MPEG_BASE + 206)
[libwebcam] Unknown V4L2 MPEG control ID encountered: 0x009909CF (V4L2_CID_MPEG_BASE + 207)
[libwebcam] Unknown V4L2 MPEG control ID encountered: 0x009909E2 (V4L2_CID_MPEG_BASE + 226)
[libwebcam] Unknown V4L2 MPEG control ID encountered: 0x009909E5 (V4L2_CID_MPEG_BASE + 229)
[libwebcam] Unknown V4L2 MPEG control ID encountered: 0x00990A66 (V4L2_CID_MPEG_BASE + 358)
[libwebcam] Unknown V4L2 MPEG control ID encountered: 0x00990A67 (V4L2_CID_MPEG_BASE + 359)
[libwebcam] Unknown V4L2 MPEG control ID encountered: 0x00990A6B (V4L2_CID_MPEG_BASE + 363)
Listing available devices:
  video16   bcm2835-isp
    Media controller device /dev/media16 doesn't exist
ERROR: Unable to list device entities: Invalid device or device cannot be opened. (Code: 5)
  video0   USB Webcam gadget: NexiGo N660 
    Media controller device: /dev/media0
    Entity 1: bcm2835-codec-decode-source. Type: 65537, Revision: 0, Flags: 0, Group-id: 0, Pads: 1, Links: 1
      Device node
      Entity: 1, Pad 0, Flags: 2
      Out link: Source pad { Entity: 1, Index: 0, Flags: 2 } => Sink pad { Entity: 3, Index: 0, Flags: 1 }
  video11   bcm2835-codec-encode
    Media controller device /dev/media11 doesn't exist
ERROR: Unable to list device entities: Invalid device or device cannot be opened. (Code: 5)
  video13   bcm2835-isp
    Media controller device /dev/media13 doesn't exist
ERROR: Unable to list device entities: Invalid device or device cannot be opened. (Code: 5)
  video15   bcm2835-isp
    Media controller device /dev/media15 doesn't exist
ERROR: Unable to list device entities: Invalid device or device cannot be opened. (Code: 5)
  video10   bcm2835-codec-decode
    Media controller device /dev/media10 doesn't exist
ERROR: Unable to list device entities: Invalid device or device cannot be opened. (Code: 5)
  video1   USB Webcam gadget: NexiGo N660 
    Media controller device: /dev/media1
    Entity 1: bcm2835_isp0. Type: 131071, Revision: 0, Flags: 0, Group-id: 0, Pads: 4, Links: 3
      Device node
      Entity: 1, Pad 0, Flags: 1
      Entity: 1, Pad 1, Flags: 2
      Entity: 1, Pad 2, Flags: 2
      Entity: 1, Pad 3, Flags: 2
      Out link: Source pad { Entity: 1, Index: 1, Flags: 2 } => Sink pad { Entity: 12, Index: 0, Flags: 1 }
      Out link: Source pad { Entity: 1, Index: 2, Flags: 2 } => Sink pad { Entity: 18, Index: 0, Flags: 1 }
      Out link: Source pad { Entity: 1, Index: 3, Flags: 2 } => Sink pad { Entity: 24, Index: 0, Flags: 1 }
  video12   bcm2835-codec-isp
    Media controller device /dev/media12 doesn't exist
ERROR: Unable to list device entities: Invalid device or device cannot be opened. (Code: 5)
  video14   bcm2835-isp
    Media controller device /dev/media14 doesn't exist
ERROR: Unable to list device entities: Invalid device or device cannot be opened. (Code: 5)

You can also ask about supported formats and controls, very handy(I sniped the output to just show the pertinent info).

$ uvcdynctrl -c -d video0
Listing available controls for device video0:
  Brightness
  Contrast
  Saturation
  Hue
  Power Line Frequency
  Sharpness
  Exposure, Auto

$ uvcdynctrl -f -d video0
Listing available frame formats for device video0:
Pixel format: MJPG (Motion-JPEG; MIME type: image/jpeg)
  Frame size: 640x480
    Frame rates: 30, 15, 10
  Frame size: 1280x720
    Frame rates: 30, 15, 10
  Frame size: 1920x1080
    Frame rates: 30, 15, 10
Pixel format: YUYV (YUYV 4:2:2; MIME type: video/x-raw-yuv)
  Frame size: 640x480
    Frame rates: 30, 15, 10
  Frame size: 1280x720
    Frame rates: 30, 15, 10
Pixel format: H264 (H.264)
  Frame size: 640x480
    Frame rates: 30, 15, 10
  Frame size: 1280x720
    Frame rates: 30, 15, 10
  Frame size: 1920x1080
    Frame rates: 30, 15, 10
Pixel format:  (35363248-0000-0010-8000-00aa003)
  Frame size: 640x480
    Frame rates: 30, 15, 10
  Frame size: 1280x720
    Frame rates: 30, 15, 10
  Frame size: 1920x1080
    Frame rates: 30, 15, 10

This tool makes it much easier to understand what options are available and settings that an be configured.

1 Like