Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ALH477/DeMoD-Camera-Setup-Script

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DeMoD Camera Setup

Secure RTSP Streaming for SBCs with MediaMTX & FFMPEG

DeMoD LLC
Developed by DeMoD LLC


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
Raspberry Pi OS (64-bit) aarch64 Raspberry Pi 5 Low (~6W) PREEMPT Easy Pi setup, GUI Raspberry Pi OS
Armbian aarch64, armv7, riscv64 Orange Pi 5 Low (~4–8W) PREEMPT or PREEMPT_RT Broad SBC support Armbian
Fedora Minimal x86_64 Intel NUC 13 High (~15–30W) PREEMPT_RT (kernel-rt) High-performance x86 Fedora

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:

# 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:

"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

# 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)

./start.sh
  • Detects webcams
  • Prompts for auth (recommended)
  • Starts stream at: rtsp://<ip>:8554/cam

2. Web Configuration (Recommended)

python3 config.py

Open browser: http://: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

python3 security_checker.py
  • Guided security audit
  • Fix issues interactively
  • Supports JSONC multi-cam
  • Final security score

Stream URLs

rtsp://<ip>:8554/cam0
rtsp://user:pass@<ip>:8554/cam1

Test locally:

ffplay rtsp://localhost:8554/cam0

Multi-Camera Configuration (config.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)

crontab -e
@reboot /home/user/camera-setup/start.sh

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

Create /etc/systemd/system/demod-camera.service:

[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:

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)

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 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


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

About

Turn your Single-Board Computer (SBC) into a powerful IP camera system with this open-source toolkit. Using FFMPEG and MediaMTX, stream USB webcam feeds over RTSP. Perfect for home security, monitoring, or IoT projects.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors