# 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/`](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.txt` snippet to force-enable the IMX219 overlay. ## Quick Start 1. **Install dependencies** ```bash pip install -r requirements.txt ``` 2. **Run the streamer** *Auto-detect (recommended):* ```bash python stream.py ``` *For the official Raspberry Pi Camera Module (CSI):* ```bash python stream_picamera2.py ``` *For a USB webcam:* ```bash python stream_usb.py ``` 3. **View the stream** Open a browser on any device on the same network and go to: ``` http://:5000 ``` Replace `` 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: ```bash python stream_picamera2.py --width 1280 --height 720 --port 8080 ``` Use a second USB camera: ```bash python stream_usb.py --device 1 ``` ## Files - `stream_picamera2.py` — Optimized streamer for Raspberry Pi Camera Module v2/v3 using `picamera2`. - `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.