main
Initial commit of the MJPEG streaming server for Raspberry Pi. Supports Pi Camera Module (via picamera2), USB webcams (via OpenCV), and auto-detection of camera type. Includes: - `stream_picamera2.py` — optimized Pi CSI camera streamer - `stream_usb.py` — generic USB camera streamer - `stream.py` — auto-detects camera and launches correct streamer - `image-setup/` — SD card imaging scripts and Pi 5 headless setup guide for first-boot automation with systemd service - `requirements.txt` — Python dependencies
PiCam Network Streamer
A lightweight MJPEG streaming server for Raspberry Pi. It serves a webpage you can open on any device on your local network to view the live camera feed.
Pi 5 OS Image Setup
For a fully automated first-boot setup on a Raspberry Pi 5 with an IMX219 camera, see the image-setup/ directory. It includes:
SETUP_GUIDE.md— Step-by-step SD card imaging instructions.autosetup.sh— One-command setup script (installs drivers, dependencies, and auto-starts the streamer as a systemd service).config_camera.txt—config.txtsnippet to force-enable the IMX219 overlay.
Quick Start
-
Install dependencies
pip install -r requirements.txt -
Run the streamer
Auto-detect (recommended):
python stream.pyFor the official Raspberry Pi Camera Module (CSI):
python stream_picamera2.pyFor a USB webcam:
python stream_usb.py -
View the stream Open a browser on any device on the same network and go to:
http://<raspberry-pi-ip>:5000Replace
<raspberry-pi-ip>with your Pi's IP address.
Options
Both scripts accept the same command-line arguments:
| Argument | Description | Default |
|---|---|---|
--host |
Network interface to bind to | 0.0.0.0 |
--port |
Port to serve on | 5000 |
--width |
Video width in pixels | 640 |
--height |
Video height in pixels | 480 |
--fps |
Target framerate | 30 |
USB streamer only:
| --device | Video device index (e.g., 0 for /dev/video0) | 0 |
Examples
Run at 720p on port 8080:
python stream_picamera2.py --width 1280 --height 720 --port 8080
Use a second USB camera:
python stream_usb.py --device 1
Files
stream_picamera2.py— Optimized streamer for Raspberry Pi Camera Module v2/v3 usingpicamera2.stream_usb.py— Generic streamer for USB cameras using OpenCV.stream.py— Auto-detects camera type and launches the correct streamer.requirements.txt— Python dependencies.image-setup/— Scripts and guides for preparing a headless Pi 5 OS image with IMX219 support.SETUP_GUIDE.md— Full imaging and setup instructions.setup-pi.sh— Run this on a live Pi to install everything and auto-start the streamer.autosetup.sh— For embedding into a custom SD card image (runs on first boot).firstrun.sh— Raspberry Pi first-boot trigger script.config_camera.txt— Snippet to enable the IMX219 overlay.
Description
Languages
Python
60%
Shell
40%