How roflcoopter/viseron works
Purpose and startup
Viseron is a self-hosted, local NVR and computer-vision system: it ingests camera streams, runs configurable detection/recognition pipelines, records media and events, and exposes browser and integration interfaces. Python application startup is viseron/__main__.py, with core orchestration in viseron/__init__.py. Container deployments run the application as a supervised service via rootfs/etc/services.d/viseron/run.
Core runtime and extensibility
The backend is a Python component/domain architecture. Configuration and component loading are centered on viseron/config.py, viseron/components/__init__.py, and viseron/domain_registry.py. Components provide concrete adapters (for example FFmpeg/GStreamer cameras, detector backends, storage, webserver, notifications); domains define shared semantic contracts such as camera, motion, object detection, recognition, and NVR. This separates vendor/runtime integrations from downstream event and entity behavior.
Video ingestion and camera lifecycle
Camera components acquire and decode streams through FFmpeg or GStreamer: viseron/components/ffmpeg/camera.py, viseron/components/ffmpeg/stream.py, and viseron/components/gstreamer/pipeline.py. They feed shared frames and camera-domain events through viseron/domains/camera/shared_frames.py and viseron/domains/camera/events.py. The camera boundary is where external RTSP/media pipelines become internal frames, stream outputs, recordings, and detector inputs.
Analytics and event pipeline
Motion and AI providers implement domain-specific processing over camera frames. Motion implementations include viseron/components/background_subtractor/motion_detector.py and viseron/components/mog2/motion_detector.py; object detection adapters include viseron/components/yolo/object_detector.py, viseron/components/edgetpu/object_detector.py, and viseron/components/codeprojectai/object_detector.py. Results are represented in domains such as viseron/domains/object_detector/detected_object.py and drive NVR/event behavior in viseron/components/nvr/nvr.py. The internal data-stream component (viseron/components/data_stream/__init__.py) is the likely fan-out boundary between producers and consumers.
Recording, persistence, and retention
Camera recording/fragment handling is split between viseron/domains/camera/recorder.py, viseron/domains/camera/fragmenter.py, and stream-provider recorders such as viseron/components/ffmpeg/recorder.py. The storage component owns database models, queries, migrations, and tiered media retention: viseron/components/storage/models.py, viseron/components/storage/queries.py, and viseron/components/storage/tier_handler.py. PostgreSQL is provisioned in the container runtime (rootfs/etc/services.d/postgres/run), while media is served through tier-aware handlers.
HTTP, realtime API, and frontend
The webserver component exposes authenticated REST endpoints, streaming/static media, and WebSocket commands: viseron/components/webserver/api/v1, viseron/components/webserver/websocket_api/commands.py, and viseron/components/webserver/tiered_file_handler.py. A Vite/React frontend starts at frontend/src/index.tsx and composes routes in frontend/src/App.tsx; it calls backend APIs under frontend/src/lib/api and uses frontend/src/lib/websockets.ts for realtime updates. Primary UI surfaces cover live cameras, events, recordings, configuration, tuning, users, and profiles.
Deployment and external boundaries
Docker is the primary delivery model (docker/Dockerfile), with platform/GPU-specific images under docker/amd64-cuda, docker/aarch64, and docker/jetson-nano. The runtime also supervises nginx and go2rtc (rootfs/etc/services.d/nginx/run, rootfs/etc/services.d/go2rtc/run) alongside PostgreSQL and Viseron. External integrations include MQTT/Home Assistant (viseron/components/mqtt/homeassistant), notification services such as Discord/Telegram/webhooks, and remote AI services including CodeProjectAI, DeepStack, and CompreFace.
Main entry points: run Service supervisor · __main__.py Viseron application · __init__.py Component loader · camera.py Camera ingest
Components 18
Container runtime
- Docker image · Primary delivery image with platform and GPU variants.
docker/Dockerfile - Service supervisor · Runs Viseron alongside supporting services.
rootfs/etc/services.d/viseron/run - PostgreSQL
rootfs/etc/services.d/postgres/run - go2rtc
rootfs/etc/services.d/go2rtc/run
Python core
- Viseron application · Starts orchestration and component lifecycle.
viseron/__main__.py - Configuration
viseron/config.py - Component loader · Loads concrete integration adapters.
viseron/components/__init__.py - Domain registry · Shared camera, motion, detection, recognition, and NVR behavior.
viseron/domain_registry.py
Media and analytics
- Camera ingest · Converts external streams into internal camera data.
viseron/components/ffmpeg/camera.py - Shared frames
viseron/domains/camera/shared_frames.py - Data stream · Distributes frame and analytics data to consumers.
viseron/components/data_stream/__init__.py - Motion and AI · Motion detectors and object-detection providers process camera frames.
viseron/components/yolo/object_detector.py - NVR event logic · Turns detection and camera events into NVR behavior.
viseron/components/nvr/nvr.py - Recording pipeline · Creates camera recordings and media fragments.
viseron/domains/camera/recorder.py - Storage and retention · Owns database data, queries, and tiered retention.
viseron/components/storage/tier_handler.py
Interfaces
- REST and WebSocket API · Serves APIs, media, and realtime commands.
viseron/components/webserver/websocket_api/commands.py - React frontend · Live camera, event, recording, and administration surfaces.
frontend/src/App.tsx - External integrations
viseron/components/mqtt/homeassistant
Connections 21
- Docker image → Service supervisor: packages
- Service supervisor → Viseron application: launches
- Service supervisor → PostgreSQL: runs
- Service supervisor → go2rtc: runs
- Viseron application → Configuration: loads
- Viseron application → Component loader: initializes
- Component loader → Domain registry: binds adapters to
- Component loader → Camera ingest: loads
- Component loader → Motion and AI: loads
- Camera ingest → go2rtc: uses stream service
- Camera ingest → Shared frames: publishes frames
- Shared frames → Data stream: fans out
- Data stream → Motion and AI: delivers frames
- Motion and AI → NVR event logic: detection results
- NVR event logic → Recording pipeline: triggers recording
- Recording pipeline → Storage and retention: persists media
- Storage and retention → PostgreSQL: stores metadata
- REST and WebSocket API → Storage and retention: serves tiered media
- React frontend → REST and WebSocket API: REST and WebSocket
- NVR event logic → REST and WebSocket API: events and streams
- Viseron application → External integrations: publishes and calls