Skip to content

LiveSystem: A modern and secure alternative to mjpg-streamer (Python/WebSockets/Docker) #422

@AprendendoLinux

Description

@AprendendoLinux

Hi everyone,

I’d like to share LiveSystem, a project I developed to address the limitations found in classic webcam streaming solutions for Linux, such as the venerable but dated mjpg-streamer.

The Problem

Many of us still rely on mjpg-streamer for monitoring or embedded projects. However, it presents well-known challenges: an outdated interface, lack of native user management, constant hardware resource consumption, and difficulties with secure exposure via Docker due to its HTTP-based polling/streaming method.

The Solution: LiveSystem

LiveSystem was designed to be a "Cloud Native" tool—elegant, secure, and resource-efficient.

Technical Stack:

  • Backend: Python 3.10 with aiohttp for high-performance asynchronous I/O.
  • Image Processing: OpenCV (Headless).
  • Streaming: Binary data (blobs) via WebSockets (TCP), which bypasses the NAT issues often encountered when using WebRTC in isolated container environments.
  • Frontend: A futuristic dark/neon responsive UI, rendered via Jinja2.
  • Database: Hybrid support for SQLite (for lightweight setups) or MySQL (for production).

Technical Highlights

1. Smart Hardware Management (Smart Capture)
Unlike legacy solutions that keep /dev/video0 locked 24/7, LiveSystem monitors connected WebSocket clients. Capture via OpenCV only begins when at least one viewer is active, and the hardware is automatically released as soon as the last user disconnects.

2. Native Security (Zero-Trust mindset)
LiveSystem moves away from the "open-by-default" access of older tools:

  • Persistent session control via UUID (tokens in cookies).
  • Password hashing using bcrypt.
  • A dedicated administrative panel for user and privilege management.

3. DevOps Ecosystem
The project is built for modern deployment workflows:

  • Containerization: Optimized Dockerfile and docker-compose.yml for rapid deployment.
  • CI/CD: A GitHub Actions pipeline for automated semantic versioning and publishing to the GitHub Container Registry (GHCR).
  • Real-time Versioning: The version calculated during the pipeline is injected into the application footer dynamically.

How to test?

Deployment is straightforward using Docker. With a webcam connected to the host:

docker run -d --name live-cam \
    --restart always -p 8080:8080 \
    --device /dev/video0:/dev/video0 \
    -v /srv/webcam/sqlite:/app/data \
    -e PYTHONUNBUFFERED=1 \
    -e DB_TYPE=sqlite \
    -e DB_NAME=/app/data/stream.db \
ghcr.io/aprendendolinux/livesystem:latest

The service runs on port 8080. Default credentials (admin/admin123) should be updated upon first login via the user management module.

I’m looking forward to hearing your thoughts on the architecture, improvement suggestions, or potential pull requests.

Developed by: Henrique Fagundes.
Website: henrique.tec.br

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions