Skip to content

Softbinator/vybe-camera-agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vybe-camera-agent

Captures RTSP camera streams, splits them into fixed-duration chunks, and uploads them to S3 (or any S3-compatible provider) using rclone.

  • Multiple cameras run concurrently, each in its own thread
  • Uses ffmpeg for RTSP capture and segmentation
  • Uses rclone for uploads — swap storage providers without changing code
  • Failed uploads are retried with exponential backoff; chunks are kept locally until confirmed uploaded
  • Configured via a YAML file (cameras) and a .env file (credentials)

Prerequisites

The following tools must be installed and available on your PATH:

Verify they are available:

python --version
ffmpeg -version
rclone --version

Setup

1. Clone the repository

git clone <repo-url>
cd vybe-camera-agent

2. Create and activate a virtual environment

Linux / macOS:

python3 -m venv .venv
source .venv/bin/activate

Windows (Command Prompt):

python -m venv .venv
.venv\Scripts\activate.bat

Windows (PowerShell):

python -m venv .venv
.venv\Scripts\Activate.ps1

3. Install dependencies

pip install -r requirements.txt

4. Configure credentials

cp .env.example .env

Edit .env and fill in your storage credentials. The variables follow rclone's environment variable convention — the remote name prefix must match rclone_remote in config.yaml (uppercased):

RCLONE_CONFIG_S3VYBE_TYPE=s3
RCLONE_CONFIG_S3VYBE_PROVIDER=AWS
RCLONE_CONFIG_S3VYBE_ACCESS_KEY_ID=YOUR_KEY
RCLONE_CONFIG_S3VYBE_SECRET_ACCESS_KEY=YOUR_SECRET
RCLONE_CONFIG_S3VYBE_REGION=eu-central-1

5. Configure cameras

Edit config.yaml:

chunk_duration_seconds: 60        # Length of each recorded segment
temp_dir: /tmp/vybe-camera-agent  # Local staging directory for chunks
rclone_remote: s3vybe             # Must match the prefix in your .env (lowercased)
s3_bucket_path: my-bucket/recordings

cameras:
  - label: entrance
    rtsp_url: rtsp://admin:password@192.168.1.10:554/stream1
  - label: parking
    rtsp_url: rtsp://admin:password@192.168.1.11:554/stream1

Uploaded files will be stored at:

<rclone_remote>:<s3_bucket_path>/<camera_label>/<timestamp>.mp4

Running

python main.py

Stop with Ctrl+C — the agent will finish the current upload queue before exiting.


Project structure

vybe-camera-agent/
├── main.py                    # Entry point
├── config.yaml                # Camera list and global settings
├── .env.example               # Credential template (copy to .env)
├── requirements.txt
├── src/
│   ├── config_loader.py       # Loads and validates config.yaml + .env
│   ├── camera_worker.py       # Per-camera ffmpeg thread with auto-reconnect
│   └── uploader.py            # rclone upload with exponential backoff retry
├── Dockerfile
├── docker-compose.yml
└── deploy/
    ├── systemd/               # Linux auto-start (systemd service)
    ├── windows/               # Windows auto-start (Task Scheduler XML)
    └── macos/                 # macOS auto-start (launchd plist)

Docker deployment

Build and start:

docker compose up --build

Run in the background:

docker compose up --build -d

The container uses restart: unless-stopped, so it will automatically restart after a system reboot as long as the Docker daemon is running.


Auto-start on boot

Linux (systemd)

sudo cp deploy/systemd/vybe-camera-agent.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable vybe-camera-agent
sudo systemctl start vybe-camera-agent

# View logs
sudo journalctl -u vybe-camera-agent -f

Windows (Task Scheduler)

Run as Administrator:

schtasks /create /xml deploy\windows\task-scheduler.xml /tn "Vybe Camera Agent"

Or open Task Scheduler → Action → Import Task → select the XML file.

Update the WorkingDirectory inside the XML to match your installation path before importing.

macOS (launchd)

cp deploy/macos/com.vybe.camera-agent.plist ~/Library/LaunchAgents/
launchctl load ~/Library/LaunchAgents/com.vybe.camera-agent.plist

# View logs
tail -f /tmp/vybe-camera-agent.stdout.log
tail -f /tmp/vybe-camera-agent.stderr.log

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors