To add a webcam to OctoPrint on a Raspberry Pi, plug in a compatible USB webcam and boot the stable OctoPi image. OctoPi starts the stream when it detects the camera and supplies the stream and snapshot URLs. For a Raspberry Pi Camera Module 3, connect the ribbon cable while the Pi is powered off and boot an OctoPi build with camera-streamer. OctoPi README, Raspberry Pi camera installation, OctoPi camera stack
Which OctoPi image do you need for your camera?
These image choices are for OctoPi 1.1.0 with OctoPrint 2.0.1. The stable image’s MJPG-Streamer lacks libcamera support. Camera-streamer supports USB webcams and libcamera cameras, including the Camera Module 3. OctoPi 1.1.0 release notes, camera stack announcement, OctoPi-UpToDate camera-streamer release
| Camera | Image to flash | Where to find it |
|---|---|---|
| Compatible USB webcam | OctoPi stable with MJPG-Streamer | In Raspberry Pi Imager, select Choose OS → Other Specific Purpose OS → 3D printing → OctoPi, then choose the stable image. OctoPrint setup guide |
| Raspberry Pi Camera Module 3 | OctoPi with camera-streamer | Download the image for the 2.0.1 build marked from branch camera-streamer and Pre-release. In Imager, select Use Custom to flash the downloaded image. OctoPi-UpToDate camera-streamer release, Raspberry Pi Imager instructions |
For a ribbon camera, match the cable to the board. The Raspberry Pi 5 and Pi Zero series use the smaller board-side connector. With power disconnected, open the connector latch, seat the cable straight with the contacts facing away from the latch, and close it. Raspberry Pi camera installation
Setting up a webcam on the stable (mjpg-streamer) image
Open http://octopi.local/webcam/?action=stream in a browser. You can also try the streamer directly at http://octopi.local:8080/?action=stream. If you chose another hostname, use it in place of octopi.local. OctoPi README
On OctoPi 1.1.0, edit /boot/firmware/octopi.txt to change the USB camera’s resolution or frame rate. The webcam service uses /boot/octopi.txt as a fallback if the first file is absent. OctoPi 1.1.0 webcamd
The USB default is 640 × 480 at 10 fps. Replace the commented camera_usb_options example with an active line like the one below. Set -r for resolution and -f for frame rate to values your camera supports. Save the file and restart the Pi. OctoPi USB camera options, OctoPi restart configuration
camera_usb_options="-r 640x480 -f 10"
Some USB webcams produce no image when given -f. If that’s the symptom, use lsusb to find the camera’s vendor and product ID, then add it in octopi.txt using this line. Replace aabb:ccdd with the ID you found. OctoPi USB camera options
additional_brokenfps_usb_devices=("aabb:ccdd")
Setting up a webcam on the new camera stack
Edit usb-default.conf for a USB webcam or libcamera.conf for a Pi camera. On the SD card, both are in the camera-streamer directory of the boot partition. On a running Pi, the installer links that directory to /etc/camera-streamer.conf.d/. OctoPi-UpToDate installation script
These are the values in the stack’s USB configuration and libcamera configuration.
| Setting | USB | libcamera |
|---|---|---|
Primary camera port (PORT) | 8080 | 8080 |
Capture size (WIDTH × HEIGHT) | 1280 × 720 | 1920 × 1080 |
Frame rate (FRAMERATE) | 15 fps | 15 fps |
USB pixel format (FORMAT) | YUYV | — |
Live view height (VIDEO_HEIGHT) | — | 720 |
Snapshot height (SNAPSHOT_HEIGHT) | — | 1080 |
Change the values in the file for your camera, save it, and restart the Pi. After it boots, check the feed in OctoPrint. OctoPi restart configuration
Camera Module 3 focus. The default OPTIONS line enables continuous autofocus when supported. To see the controls your running camera exposes, open http://<ip>:8080/option with your Pi’s IP address. libcamera configuration, camera-streamer configuration guide
OPTIONS='--camera-options="AfMode=2" --camera-options="AfRange=2"'
Add a second USB webcam. Plug it in and run the command below on the Pi. Select the new camera when prompted. The script picks the first port unused by the camera configs starting at 8080, writes /etc/camera-streamer.conf.d/usb-bedcam.conf, and starts or restarts that camera. OctoPrint add-usb-camera script
sudo add-usb-camera bedcam
Use WebRTC. Install Camera-Streamer Control through OctoPrint’s plugin manager, then select WebRTC in the plugin’s settings. The plugin can fall back to the MJPEG stream if WebRTC fails to connect. Camera-Streamer Control plugin guide
Configuring the webcam in OctoPrint’s settings
OctoPrint moved webcam settings to individual plugins in 1.9.0. Open Settings → Classic Webcam to check the bundled plugin’s live-view and snapshot URLs. OctoPrint 1.9.0 release notes, official OctoPrint Docker README
| Field | OctoPi 1.1.0 value | What to check |
|---|---|---|
| Stream URL | /webcam/?action=stream | Select Test to check the live feed. OctoPrint stream control |
| Snapshot URL | http://127.0.0.1:8080/?action=snapshot | Select Test to check that OctoPrint can fetch a still for timelapses. OctoPrint snapshot control |
The relative stream path and loopback snapshot address are the OctoPi 1.1.0 image defaults. For timelapses, OctoPrint also needs the FFmpeg executable set in webcam.ffmpeg. OctoPrint configuration reference
If the image is upside down or mirrored, use the Classic Webcam orientation controls. They can flip the feed horizontally or vertically, or rotate it 90 degrees counterclockwise. OctoPrint orientation controls
To switch between cameras in OctoPrint, register each feed through a webcam provider. When multiple views are registered, switch between them in the Control tab. OctoPrint 1.9.0 release notes
Why is my OctoPrint webcam stream black or not showing?
- The feed works outside OctoPrint. Check the configured URL using Test beside Stream URL in Classic Webcam. OctoPrint stream control
- The USB feed went blank after changing its settings. Restore the original resolution and frame rate. Check the
-fworkaround above if the stable image detects the webcam but shows no video. OctoPi USB camera options - The Camera Module 3 is on the stable image. Use a camera-streamer build for this camera. OctoPi release notes, camera stack announcement
- A camera-streamer feed is missing. Read the service logs with
journalctl -u camera-streamer\*. On the Bookworm build, runrpicam-hello --list-camerasto see whether libcamera detects the ribbon camera. OctoPi-UpToDate troubleshooting, camera detection utility, Raspberry Pi camera software
If prints stall after adding a camera, see the mid-print disconnect guide. For a feed that works locally, see the OctoPrint remote access guide for remote viewing or the OctoPrint plugin guide for camera integrations.
The setup is based on the OctoPi 1.1.0 and OctoPrint 2.0.1 sources, the camera-streamer stack configuration, and Raspberry Pi’s camera documentation. The steps were not run on hardware.
Related across the network
- Klipper Hardware Requirements: SBC, MCU, and Sensors — klipperlab.com