πŸ‡ΊπŸ‡¦ We stand with Ukraine! πŸ‡ΊπŸ‡¦

Raspberry Pi Camera V2 stopped working

My hardware

Raspberry Pi Camera V2
Raspberry Pi 4 w/ 4GB RAM

What is the problem?

"Webcam stream not loaded"

I have had Octoprint installed and everything working fine for several weeks. Yesterday the camera stopped working. Not sure what I did, but I think it coincided with updates to various plugins and perhaps Octoprint itself.

What did you already try to solve it?

[Note: in the course of doing these things I determined that the hardware seems to be fine, but in the interest of showing that I tried to solve this myself first, here are all of the steps (that I can remember).]

  1. Made sure ribbon cable was properly connected.
  2. Tried different ribbon cables.
  3. Ordered a new Pi Camera V2, installed it, in case I zapped the old one.
  4. Searched this forum and the web in general.
  5. Futzed around with various diagnostic steps from forums and other websites.
sudo systemctl restart webcamd
sudo apt update
sudo apt-get update --fix-missing
sudo apt-get upgrade
sudo apt full-upgrade
sudo raspi-config, Interfaces, etc.
sudo service webcamd start

...in various sequences, and in every instance rebooting and re-testing. (Side question: does it matter if I reboot via SSH or from within the Octoprint web interface?)

  1. Tried vcgencmd get_camera which returned: supported=1 detected=1

  2. Finally figured out how to get a test image with raspistill -v -o test.jpg and that worked - I can see an image - so the camera(s), cables, and Pi all work ok, which tell me it's something with Octoprint itself. (Wish I had found the test image thing before ordering the second Camera module, but hey, now I have two!)

  3. Tried restoring Octoprint backups.

  4. Tried restarting Octoprint in Safe Mode.

Logs

I don't seem to have a webcamd.log, but I found this journalctl -u webcamd which returned 4000+ lines of results, which are apparently too long to paste in this forum, so...I put them here, hope that's ok:

http://www.nomadicfrog.com/downloads/webcam_log_2021_02_28_v01.txt

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

I think everything is up to date:

OctoPrint 1.5.3
Python 2.7.16
OctoPi 0.17.0
Ender 3 V2 printer
macOS 11.2
Safari 14.0.3 and Firefox 86.0

I have done updates via SSH (as noted above) and from within Octoprint and it says everything is up to date (which is suspicious to me because I'm pretty sure the last Backup that I restored (see above steps) was before I updated the plugins yesterday, so I'm not sure how everything could still be "up to date"...)

I'm sure this is a dumb and oft-repeated question, but I've been trying for a day and a half, so any other pointers would be welcome. Thanks!

It seems to me like you configured your raspicam like a usbcam.
You have to use other parameters in the octopi.txt

Raspicam ( input_raspi.so )

input_raspi.so is included in this MJPG Streamer fork by Jackson Liam which also supports the Raspberry Pi Camera . This is the fork that is shipped on the OctoPi SD card image for the Raspberry Pi.

See also the documentation for more information about these options.

  • -fps or --framerate : set video framerate, default 1 frame/sec
  • -x or --width : width of frame capture, default 640
  • -y or --height : height of frame capture, default 480
  • -quality : set JPEG quality (0 to 100), default 85
  • -usestills : uses stills mode instead of video mode
  • -sh : Set image sharpness (-100 to 100)
  • -co : Set image contrast (-100 to 100)
  • -br : Set image brightness (0 to 100)
  • -sa : Set image saturation (-100 to 100)
  • -ISO : Set capture ISO
  • -vs : Turn on video stablisation
  • -ev : Set EV compensation
  • -ex : Set exposure mode, valid values (according to the RaspiCam documentation):
    • off
    • auto : Use automatic exposure
    • night : Select setting for night shooting
    • nightpreview
    • backlight : Select setting for back-lit subject
    • spotlight
    • sports : Select setting for sports (fast shutter etc.)
    • snow : Select setting optimized for snowy scenery
    • beach : Select setting optimized for beach
    • verylong : Select setting for long exposures
    • fixedfps : Constrain fps to a fixed value
    • antishake : Antishake mode
    • fireworks : Select setting optimized for fireworks
  • -awb : Set AWB mode, valid values (according to the RaspiCam documentation):
    • off : Turn off white balance calculation
    • auto : Automatic mode (default)
    • sun : Sunny mode
    • cloudshade : Cloudy mode
    • tungsten : Tungsten lighting mode
    • fluorescent : Fluorescent lighting mode
    • incandescent : Incandescent lighting mode
    • flash : Flash mode
    • horizon : Horizon mode
  • -ifx : Set image effect (according to the RaspiCam documentation):
    • none : No effect
    • negative : Produces a negative image
    • solarise : Solarise the image
    • whiteboard : Whiteboard effect
    • blackboard : Blackboard effect
    • sketch : Sketch-style effect
    • denoise : Denoise the image
    • emboss : Embossed effect
    • oilpaint : Oil paint-style effect
    • hatch : Cross-hatch sketch style
    • gpen : Graphite sketch style
    • pastel : Pastel effect
    • watercolour : Watercolour effect
    • film : Grainy film effect
    • blur : Blur the image
    • saturation : Colour-saturate the image
    • colourswap : Not fully implemented
    • washedout : Not fully implemented
    • posterise : Not fully implemented
    • colourpoint : Not fully implemented
    • colourbalance : Not fully implemented
    • cartoon : Not fully implemented
  • -cfx : Set colour effect (U:V), the supplied U and V parameters (range 0 to 255) are applied to the U and Y channels of the image. For example, --colfx 128:128 should result in a monochrome image (according to the RaspiCam documentation).
  • -mm : Set metering mode (see raspistill notes), valid values (according to the RaspiCam documentation):
    • average : Average the whole frame for metering
    • spot : Spot metering
    • backlit : Assume a backlit image
    • matrix : Matrix metering
  • -rot : Set image rotation (0-359, at the present only 0, 90, 180 and 270 are supported though)
  • -hf : Set horizontal flip
  • -vf : Set vertical flip

Thank you for your suggestion. I am skeptical that this is the issue, though, for three reasons:

  1. When I first set up the camera a month ago I changed the relevant file to comment out "auto" and "usb" and leave only raspicam, and (tried) to configure other options there like resolution, frame rate, AWB, and EV. (I say "tried" because those settings didn't seem to make any difference – the white balance and EV were still off – but otherwise the system was working and I put those aesthetic issues further down in my priorities.

  2. The main reason I am skeptical of this being the problem is that, as I mentioned above, the system was working, for weeks, since I first configured the camera, and while I'm not certain what action I did to cause the recent problem, I am quite certain that I did not mess with these settings by manually editing the text file in the past couple of days.

  3. I will re-check octopi.txt to see if an update reverted it to a previous state, but even then, my understanding is that it defaults to "auto" selection, which should detect and use the raspicam if it is present.

Perhaps if you could tell me what you see that indicates "I configured my raspicam like a usbcam" that might point me where to look?

Here is my current octopi.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"

### 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="auto"
camera="raspi"
	
### 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"

### 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
#
# Defaults to 10fps
#
#camera_raspi_options="-fps 10"
#camera_raspi_options="-fps 25"
camera_raspi_options="-r 1920x1080 -f 10 -ev -1" 


### 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"
camera_http_webroot="./www"
camera_http_options=""

those are usbcam parameters (well except the -ev)

you have to use those parameters

  • -fps or --framerate : set video framerate, default 1 frame/sec
  • -x or --width : width of frame capture, default 640
  • -y or --height : height of frame capture, default 480

your log also indicates that mjpeg-streamer didn't start because of that config

Feb 28 20:41:14 octopi webcamd[1515]: Starting up webcamDaemon...
Feb 28 20:41:14 octopi webcamd[1515]: --- Configuration: ----------------------------
Feb 28 20:41:14 octopi webcamd[1515]: cfg_file:      /boot/octopi.txt
Feb 28 20:41:14 octopi webcamd[1515]: camera:        raspi
Feb 28 20:41:14 octopi webcamd[1515]: usb options:   -r 640x480 -f 10
Feb 28 20:41:14 octopi webcamd[1515]: raspi options: -r 1920x1080 -f 10 -ev -1
Feb 28 20:41:14 octopi webcamd[1515]: http options:  -w ./www
Feb 28 20:41:14 octopi webcamd[1515]: Explicitly USB device:
Feb 28 20:41:14 octopi webcamd[1515]: -----------------------------------------------
Feb 28 20:41:14 octopi webcamd[1515]: Found video devices:
Feb 28 20:41:14 octopi webcamd[1515]: /dev/video0
Feb 28 20:41:14 octopi webcamd[1515]: /dev/video10
Feb 28 20:41:14 octopi webcamd[1515]: /dev/video11
Feb 28 20:41:14 octopi webcamd[1515]: /dev/video12
Feb 28 20:41:14 octopi webcamd[1515]: /dev/video13
Feb 28 20:41:14 octopi webcamd[1515]: /dev/video14
Feb 28 20:41:14 octopi webcamd[1515]: /dev/video15
Feb 28 20:41:14 octopi webcamd[1515]: /dev/video16
Feb 28 20:41:14 octopi webcamd[1515]: raspi
Feb 28 20:41:14 octopi webcamd[1515]: config file='/boot/octopi.txt':Start MJPG-streamer with video device: raspi
Feb 28 20:41:14 octopi root[1526]: Starting Raspberry Pi camera
Feb 28 20:41:14 octopi webcamd[1515]: <13>Feb 28 20:41:14 root: Starting Raspberry Pi camera
Feb 28 20:41:14 octopi webcamd[1515]: Running ./mjpg_streamer -o output_http.so -w ./www  -i input_raspicam.so -r 1920x1
Feb 28 20:41:14 octopi mjpg_streamer[1527]: MJPG-streamer [1527]: starting application
Feb 28 20:41:14 octopi mjpg_streamer[1527]: MJPG-streamer [1527]: MJPG Streamer Version: git rev: 501f6362c5afddcfb41055
Feb 28 20:41:14 octopi webcamd[1515]: MJPG Streamer Version: git rev: 501f6362c5afddcfb41055f97ae484252c85c912
Feb 28 20:41:14 octopi webcamd[1515]: raspicam input plugin: option '-r' is ambiguous; possibilities: '-rot' '-roi'
Feb 28 20:41:14 octopi webcamd[1515]:  ---------------------------------------------------------------
Feb 28 20:41:14 octopi webcamd[1515]:  Help for input plugin..: raspicam input plugin
Feb 28 20:41:14 octopi webcamd[1515]:  ---------------------------------------------------------------
Feb 28 20:41:14 octopi webcamd[1515]:  The following parameters can be passed to this plugin:
Feb 28 20:41:14 octopi webcamd[1515]:  [-fps | --framerate]...: set video framerate, default 5 frame/sec
Feb 28 20:41:14 octopi webcamd[1515]:  [-x | --width ]........: width of frame capture, default 640
Feb 28 20:41:14 octopi webcamd[1515]:  [-y | --height]........: height of frame capture, default 480
Feb 28 20:41:14 octopi webcamd[1515]:  [-quality].............: set JPEG quality 0-100, default 85
Feb 28 20:41:14 octopi webcamd[1515]:  [-usestills]...........: uses stills mode instead of video mode
Feb 28 20:41:14 octopi webcamd[1515]:  [-preview].............: Enable full screen preview
Feb 28 20:41:14 octopi webcamd[1515]:  [-timestamp]...........: Get timestamp for each frame
Feb 28 20:41:14 octopi webcamd[1515]:  
Feb 28 20:41:14 octopi webcamd[1515]:  -sh  : Set image sharpness (-100 to 100)
Feb 28 20:41:14 octopi webcamd[1515]:  -co  : Set image contrast (-100 to 100)
Feb 28 20:41:14 octopi webcamd[1515]:  -br  : Set image brightness (0 to 100)
Feb 28 20:41:14 octopi webcamd[1515]:  -sa  : Set image saturation (-100 to 100)
Feb 28 20:41:14 octopi webcamd[1515]:  -ISO : Set capture ISO
Feb 28 20:41:14 octopi webcamd[1515]:  -vs  : Turn on video stablisation
Feb 28 20:41:14 octopi webcamd[1515]:  -ev  : Set EV compensation
Feb 28 20:41:14 octopi webcamd[1515]:  -ex  : Set exposure mode (see raspistill notes)
Feb 28 20:41:14 octopi webcamd[1515]:  -awb : Set AWB mode (see raspistill notes)
Feb 28 20:41:14 octopi webcamd[1515]:  -ifx : Set image effect (see raspistill notes)
Feb 28 20:41:14 octopi webcamd[1515]:  -cfx : Set colour effect (U:V)
Feb 28 20:41:14 octopi webcamd[1515]:  -mm  : Set metering mode (see raspistill notes)
Feb 28 20:41:14 octopi webcamd[1515]:  -rot : Set image rotation (0-359)
Feb 28 20:41:14 octopi webcamd[1515]:  -stats : Compute image stats for each picture (reduces noise for -usestills)
Feb 28 20:41:14 octopi webcamd[1515]:  -drc : Dynamic range compensation level (see raspistill notes)
Feb 28 20:41:14 octopi webcamd[1515]:  -hf  : Set horizontal flip
Feb 28 20:41:14 octopi webcamd[1515]:  -vf  : Set vertical flip

it says
Feb 28 20:41:14 octopi webcamd[1515]: raspicam input plugin: option '-r' is ambiguous; possibilities: '-rot' '-roi'
and lists all possible parameters and then the script stops because mjpeg-streamer exits

Feb 28 20:41:14 octopi webcamd[1515]:  ---------------------------------------------------------------
Feb 28 20:41:14 octopi webcamd[1515]: input_init() return value signals to exit
Feb 28 20:41:14 octopi mjpg_streamer[1527]: MJPG-streamer [1527]: input_init() return value signals to exit
Feb 28 20:41:45 octopi webcamd[1515]: Done bring up all configured video device
Feb 28 20:41:45 octopi webcamd[1515]: Goodbye...
Feb 28 20:41:45 octopi systemd[1]: webcamd.service: Succeeded.
Feb 28 20:41:45 octopi systemd[1]: Started the OctoPi webcam daemon with the user specified config.
Feb 28 20:41:45 octopi systemd[1]: webcamd.service: Service RestartSec=100ms expired, scheduling restart.
Feb 28 20:41:45 octopi systemd[1]: webcamd.service: Scheduled restart job, restart counter is at 11.
1 Like

Cool, thank you, I'll look into that.

After I replied above I did look more at the documentation you posted, and I noticed myself that the parameters I used seemed to be wrong. Everything was new to me when I was first setting up – Pi, 3D printing, Octoprint – and I must have misread the documentation and conflated the USB and raspicam parameters (as you just explained).

(Rhetorical question I don't really need an answer to: why can't they be the same parameters for all cameras, then just use the camera="raspi" switch to select which is being used?)

I'm still confused as to why it worked at all, then, for the first month I had the printer / pi / camera, but I'll work on fixing it and see if it helps now...

Yep, correcting those parameters fixed the immediate* problem!

Thank you!!

*I'm still struggling with white balance and other parameters:

camera_raspi_options="-x 1920 -y 1080 -ev -1 -awb fluorescent"

...but that's something I can work on for a while now that I'm on the right path. Thanks again!

1 Like