An open API service indexing awesome lists of open source software.

https://github.com/alh477/demod-camera-setup-script

I am building my own PoE IP cams and I wanted to show up the lame ass SWEs at brand name IP cam companies. Use my script to make your own cameras for cheaper, so you don't need to use Internet Explorer compatibility mode. WHY DO THEY EVEN DO THAT, IT IS DISGUSTING AND APISH.
https://github.com/alh477/demod-camera-setup-script

apt bash bash-script camera debian-packages ffmpeg gnu ip mediamtx python python-script security ufw

Last synced: 2 months ago
JSON representation

I am building my own PoE IP cams and I wanted to show up the lame ass SWEs at brand name IP cam companies. Use my script to make your own cameras for cheaper, so you don't need to use Internet Explorer compatibility mode. WHY DO THEY EVEN DO THAT, IT IS DISGUSTING AND APISH.

Awesome Lists containing this project

README

          

# DeMoD Camera Setup
**Secure RTSP Streaming for SBCs with MediaMTX & FFMPEG**

![DeMoD LLC](https://upload.wikimedia.org/wikipedia/commons/thumb/a/ad/Sierpinski-Trigon-7.svg/200px-Sierpinski-Trigon-7.svg.png)
*Developed by [DeMoD LLC](https://demod.ltd)*

---

Transform your **Single-Board Computer (SBC)** into a **professional-grade IP camera system**. Stream USB webcam feeds over **RTSP** using **FFMPEG** and **MediaMTX**, with support for **multi-camera setups**, **secure authentication**, and **broad SBC compatibility**.

---

## Features

| Feature | Description |
|-------|-------------|
| **Multi-Camera Support** | Configure unlimited cameras via JSONC with per-camera auth |
| **Secure Auth** | RTSP basic auth with `env:` variable support (no plaintext passwords) |
| **SBC-Optimized** | ARM 32/64-bit, RISC-V, x86-64 — auto-detected binaries |
| **Security-First** | SHA256 verification, firewall config, non-root execution |
| **Three Interfaces** | CLI (`start.sh`), TUI (`security_checker.py`), Web UI (`config.py`) |
| **Security Rating** | 0–100 score with automated + user checks |
| **GPL v3 Licensed** | Fully open source — all improvements stay free |

---

## Supported Platforms

| OS Family | Package Manager | Firewall |
|----------|------------------|----------|
| Debian-like | `apt` | `ufw` |
| Fedora-like | `dnf` | `firewalld` |

| Architecture | MediaMTX Binary |
|--------------|-----------------|
| ARM 64-bit (aarch64) | `arm64` |
| ARM 32-bit (armv7l) | `armv7` |
| RISC-V 64-bit | `riscv64` |
| x86-64 | `amd64` |

> Works on: Raspberry Pi, Orange Pi, VisionFive, Intel NUC, etc.
---
> **Recommended Operating Systems & SBCs**
> Choose your stack based on **architecture**, **power**, **latency**, and **processing needs**.
> All are **fully validated** with DeMoD Camera Setup.

| OS | Architecture | SBC Example | Power | Real-Time Kernel | Best For | Link |
|----|--------------|-------------|-------|------------------|----------|------|
| **ArchibaldOS** | `aarch64`, `x86_64` | **LattePanda Sigma** (i5-1340P) | Low (~5W ARM) / **High (~45–80W x86)** | **PREEMPT_RT** (cross-arch patched) | **Top Universal Choice**
ARM (edge) + x86 (max power) | [![ArchibaldOS](https://img.shields.io/badge/ArchibaldOS-ALH477/ArchibaldOS-2ea44f?style=flat&logo=linux)](https://github.com/ALH477/ArchibaldOS) |
| **Raspberry Pi OS (64-bit)** | `aarch64` | Raspberry Pi 5 | Low (~6W) | `PREEMPT` | Easy Pi setup, GUI | [![Raspberry Pi OS](https://img.shields.io/badge/Raspberry%20Pi%20OS-64bit-C51A4A?style=flat&logo=raspberry-pi)](https://www.raspberrypi.com/software/) |
| **Armbian** | `aarch64`, `armv7`, `riscv64` | Orange Pi 5 | Low (~4–8W) | `PREEMPT` or `PREEMPT_RT` | Broad SBC support | [![Armbian](https://img.shields.io/badge/Armbian-Minimal-2185D0?style=flat&logo=linux)](https://www.armbian.com) |
| **Fedora Minimal** | `x86_64` | Intel NUC 13 | High (~15–30W) | **PREEMPT_RT** (`kernel-rt`) | High-performance x86 | [![Fedora](https://img.shields.io/badge/Fedora-Minimal%20(x86_64)-294172?style=flat&logo=fedora)](https://fedoraproject.org/coreos/download?tab=metal_virtualized) |

---

### **Maximum Power: LattePanda Sigma + ArchibaldOS**

| Spec | Value |
|------|-------|
| **CPU** | Intel Core **i5-1340P** (12 cores, up to **4.6 GHz**) |
| **GPU** | Intel Iris Xe (96 EU) — **Quick Sync Video** |
| **RAM** | Up to **64 GB** LPDDR5 |
| **Encoding** | **8+ 4K@30fps streams** via `-c:v h264_qsv` |
| **Latency** | **<25ms** with PREEMPT_RT |
| **Power** | **~45–80W** under full load |

> **Pro Setup**:
> ```bash
> # 1. Flash ArchibaldOS x86_64 to LattePanda Sigma
> # 2. Run:
> ./setup.sh # Auto-detects x86_64 + Quick Sync
> ```
> Use `config.py` → enable **Quick Sync** in FFMPEG:
> ```json
> "runOnInit": "ffmpeg -hwaccel qsv -i {device} -c:v h264_qsv -b:v 12M ..."
> ```

---

### **Real-Time Kernel Nuances**

| Arch | PREEMPT_RT Status | Notes |
|------|-------------------|-------|
| `aarch64` | Custom patched | ArchibaldOS provides **SBC-tuned semi or full RT kernel when possible** |
| `x86_64` | Mainline + enhanced | ArchibaldOS adds **I/O scheduling**, beats Fedora on NUCs |
| `riscv64` | Experimental | Avoid for hard real-time |

---

> **Pro Tip**: On **LattePanda Sigma**, pair with **240W USB-C PD** for sustained max performance.

---

## Requirements

- Linux SBC with `v4l2` webcam support
- USB webcam(s)
- Internet access (for MediaMTX download)
- Python 3.6+

---

## Installation

```bash
# 1. Clone or download the repository
git clone https://github.com/demod-llc/camera-setup.git
cd camera-setup

# 2. Make scripts executable
chmod +x setup.sh start.sh

# 3. Run setup (use sudo if prompted)
./setup.sh
```

### Setup Flow:
1. Select OS type (Debian/Fedora)
2. Select architecture
3. Installs: `v4l-utils`, `wget`, `tar`, `python3`
4. Adds user to `video` group
5. Downloads **MediaMTX v1.13.1** with **SHA256 verification**
6. Opens **port 8554/TCP** in firewall
7. Optional: Run security checker

---

## Usage

### 1. **Quick Start (Single Camera)**

```bash
./start.sh
```

- Detects webcams
- Prompts for auth (recommended)
- Starts stream at: `rtsp://:8554/cam`

---

### 2. **Web Configuration (Recommended)**

```bash
python3 config.py
```

Open browser: [http://:8000](http://localhost:8000)

- Paste **multi-camera JSONC**
- Or configure **single camera** via form
- Live **security rating**
- Start/stop server with one click

> **Secure by default**: Web UI binds to `127.0.0.1`. Use reverse proxy for remote access.

---

### 3. **TUI Security & Config**

```bash
python3 security_checker.py
```

- Guided security audit
- Fix issues interactively
- Supports JSONC multi-cam
- Final security score

---

## Stream URLs

```text
rtsp://:8554/cam0
rtsp://user:pass@:8554/cam1
```

Test locally:
```bash
ffplay rtsp://localhost:8554/cam0
```

---

## Multi-Camera Configuration (`config.jsonc`)

```jsonc
{
// Multi-camera example
"cams": [
{
"device": "/dev/video0",
"framerate": 30,
"bitrate": "800k",
"auth": {
"user": "admin",
"pass": "env:RTSP_PASS_CAM0" // Set via: export RTSP_PASS_CAM0=secret
}
},
{
"device": "/dev/video1",
"framerate": 25,
"bitrate": "600k"
// No auth = public stream
}
]
}
```

> **Never commit plaintext passwords.** Always use `env:VAR_NAME`.

---

## Auto-Start on Boot

### Option 1: Simple (Single Camera)
```bash
crontab -e
```
```cron
@reboot /home/user/camera-setup/start.sh
```

### Option 2: Systemd Service (Multi-Camera / Web UI)

Create `/etc/systemd/system/demod-camera.service`:
```ini
[Unit]
Description=DeMoD Camera RTSP Server
After=network.target

[Service]
Type=simple
User=youruser
WorkingDirectory=/home/youruser/camera-setup
ExecStart=/usr/bin/python3 config.py
Restart=always
Environment=RTSP_PASS_CAM0=your-secret-here

[Install]
WantedBy=multi-user.target
```

Enable:
```bash
sudo systemctl enable --now demod-camera.service
```

---

## Security Best Practices

| Practice | Command |
|--------|---------|
| **Use env vars** | `export RTSP_PASS_CAM0=strongpass` |
| **Run as non-root** | Avoid `sudo` for `start.sh` |
| **Restrict web UI** | Keep `127.0.0.1:8000` or use VPN |
| **Enable firewall** | Only 8554/TCP open by default |
| **Use TLS (optional)** | Reverse proxy with Caddy/Nginx |

### Recommended: TLS + Auth (Caddy Example)

```caddy
camera.demod.ltd {
reverse_proxy localhost:8000
basicauth {
user JDJhJDEyJ...
}
}
```

---

## Troubleshooting

| Issue | Solution |
|------|----------|
| `No webcam detected` | `ls /dev/video*` or `v4l2-ctl --list-devices` |
| `Checksum failed` | Retry `./setup.sh` — network issue |
| `JSONC error` | Validate syntax; use sample |
| `Stream not playing` | Test with `ffplay` locally |
| `High CPU` | Lower `bitrate` or `framerate` |

---

## Project Structure

```
.
├── setup.sh → Installs deps + MediaMTX
├── start.sh → CLI single-cam setup
├── config.py → Web UI (http://:8000)
├── security_checker.py → TUI security audit
├── utils.py → Shared logic
├── config.jsonc.example → Multi-cam template
├── mediamtx → Binary (after setup)
└── mediamtx.yml → Generated config
```

---

## Contributing

We welcome contributions!
- Fork and submit a **Pull Request**
- All code must be **GPL v3**
- Include copyright header
- Test on real hardware

---

## License

```
GNU General Public License v3.0 (GPL-3.0)
Copyright (C) 2025 DeMoD LLC
```

See [`LICENSE`](LICENSE) for full text.

> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License.

---

## Support

For enterprise support, consulting, or custom integrations:

**Contact**: [DeMoD LLC](https://demod.ltd/contact)

---

**DeMoD Camera Setup — Secure. Simple. Scalable.**

Let me know if you'd like:
- A **GitHub Actions CI** workflow
- **Docker image**
- **NixOS module**
- **Home Assistant integration**
- **Hardware guide**