Troubleshooting Octoprint webcam streaming - Page 1
Forum section: electronics / general

author: Alex_Baker
author_rank: Frequent Contributor
timestamp: September 13, 2023, 12:46:29 pm
content: Hey folksFor a long time now my raspberry pi refuses to stream my webcam to the octoprint webpage, I figured I would try and get it working. The webcam is a cheap generic usb one from amazon, and the PI is a 3B+ I think.I have looked through several forum pages but they all ended up with "my mistake, the camera was broken or not plugged in all the way", not very useful to me. All the stream/snapshot urls are at their default values because I have never changed them. Going tohttp://octopi.local/webcam/?action=streamI get 502 bad gateway, the snapshot stream under time lapse gives me a refused to connect error also.Unfortunately I don't have time to screw around in the terminal right now, I know there are a few things to test. I will also try to get my hands on a different usb camera to see if that works. Anyway, there is some background, has anybody here had any experience with this kind of issue?

author: xrunner
author_rank: Super Contributor
timestamp: September 13, 2023, 12:58:19 pm
content: Quote from: Alex_Baker on September 13, 2023, 12:46:29 pmHi,What I can tell you is I've always had a camera on my Pi 3 B+ for Octoprint which uses a cable to the on-board CSI interaface slot on top of the Pi. It's always "just worked". Why don't you get that kind of camera?

author: MarkF
author_rank: Super Contributor
timestamp: September 13, 2023, 01:48:17 pm
content: Here's what I did for my Logitech webcam:Code:Tools needed:Win32 Disk Imager from https://sourceforge.net/projects/win32diskimager/PuTTY from https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.htmlImages needed:Download OctoPi from https://octoprint.org/download/Latest image used:octopi-0.18.0-1.7.3-20220323100241.zipProcedure:- Copy image to MicroSD card- Open MicroSD card- Edit "octopi-wpa-supplicant.txt"Uncomment WPA/WPA2 network section and enter WiFi SSID and PSKUncomment the country Pi is in- Edit "octopi.txt" - Uncomment and set camera options:camera_usb_options="-r 960x540 -f 10"camera_raspi_options="-fps 10"- Insert card into Raspberry Pi and power up- Open PuTTY and access Pi: "octopi.local"- Login: username="pi" password="raspberry"- Change configuration: sudo raspi-configExpand file systemChange user passwordAdvanced options >> HostnameChange PI hostname- RebootChange camera resolution:- Open PuTTY and access Pi: "octopi.local"- Login: username="pi" password="raspberry"- Change directory: cd /root/bin- Edit "webcamd" file: sudo nano webcamd- Change Init Config section:camera_usb_options="-r 960x540 -f 10"camera_raspi_options="-fps 10"CTRL-OCTRL-X- Reboot->960x540, 864x486 smaller resolutionGet processor temperature:- Open PuTTY and access Pi: "octopi.local"- Login: username="pi" password="raspberry""- watch cat /sys/class/thermal/thermal_zone0/tempAccess OctoPrint from web browser: http://octopi.local or http://hostname.local if hostname was changedALWAYS POWER DOWN RASPBERRY PI VIA OCTOPRINT (Top right system menu)There are also some nice videos out there:

author: Lindley
author_rank: Regular Contributor
timestamp: September 13, 2023, 08:06:57 pm
content: Agree with @xrunner the Pi camera works fine for us and just as cheap or cheaper than a usb camera.

author: Alex_Baker
author_rank: Frequent Contributor
timestamp: September 13, 2023, 10:16:59 pm
content: Quote from: Lindley on September 13, 2023, 08:06:57 pmI do like those cameras, however they will not work for my setup. I have a heated enclosure where the printer electronics are in a separate case outside, so the cable required is around 600mm, and the USB cam plugs into a panel mount USB on top of the electronics case. A delicate ribbon cable would not be very good in this scenario I don't think.When I get a chance I will go into the terminal and try some things.

author: xrunner
author_rank: Super Contributor
timestamp: September 13, 2023, 10:53:01 pm
content: Quote from: Alex_Baker on September 13, 2023, 10:16:59 pmExtended cables available on Ebay, just saw one for that length.Extended camera cable

author: Alex_Baker
author_rank: Frequent Contributor
timestamp: September 14, 2023, 03:28:03 pm
content: Quote from: xrunner on September 13, 2023, 10:53:01 pmUnless they make a panel mount connector that takes those ribbon cables this method won't work for my setup.Also I may have solved my problem, we will see. While testing a few things in the terminal via ssh I was running into several issues that may have been caused by an out of date octoprint/linux install. I decided to go ahead and reinstall octoprint, it only took me about 40 minutes to get everything up and running again and so far the usb webcam is working fine. I was hoping to actually find a problem, but I guess this route is probably better in the long run.ThanksAlex