Author: Aidan A. Bradley
GitHub: github.com/aab18011
Website: https://aab18011.github.io/
Date: August 24, 2025
Company/League: Outback Paintball Series (OPS) - Matt's Outback Paintball (League Owner)
Sponsor: Tom Brierton
Location: Riley Mountain Rd., Coventry, CT
ROC (Remote OBS Controller) is an open-source, Python-based suite for automated scene switching in OBS Studio, designed for livestreaming multi-camera setups. Initially developed for the Outback Paintball Series to broadcast paintball tournaments, ROC integrates scene switching, a custom v4l2loopback installer, and FFmpeg-based camera streaming into a unified system.
Key principles:
- Unified Architecture: Combines previously separate repositories (scene switcher, v4l2loopback installer, FFmpeg connector) into one cohesive codebase.
- PEP 8 Compliance: Ensures readable, maintainable code.
- Semantic Versioning: Follows MAJOR.MINOR.PATCH (e.g., v3.0.0b for beta, v3.0.1a for alpha).
ROC operates in two phases:
- Bootstrap (Phase 1): Initializes system, checks dependencies, discovers cameras, and configures settings.
- Main Application (Phase 2): Manages runtime operations, camera streaming, and scene switching via a rule-based engine.
- Automated Scene Switching: JSON-defined rules trigger scene changes based on real-time data (e.g., game state, timers).
- Camera Management: Auto-discovers cameras (ARP/brute-force), streams via FFmpeg to v4l2loopback devices.
- Resilience: Exponential backoff for network retries, health monitoring for OBS, cameras, and scoreboards.
- Extensible Actions: Supports delays, sequences, parallel actions, and custom scripts.
- Metrics & Logging: Tracks rule executions, scene history, and system health.
- Hot-Reload: Dynamically updates rules without restarting.
- Versatile: Adaptable for any multi-camera livestream with event-driven switching.
- OS: Ubuntu 20.04+, Debian 11+, CentOS 8+, or Arch Linux
- Hardware: 2GB RAM (4GB recommended), 2-core CPU, 10GB free disk space
- Network: Stable LAN for cameras/scoreboards; internet for dependency installation
- Software: Python 3.8+, OBS Studio with WebSocket plugin v5.0+
Requires Python 3.8+ and Linux (tested on Ubuntu/Debian). Installs FFmpeg, v4l2loopback, and Python dependencies.
git clone https://github.com/aab18011/roc.git
cd roc
sudo bash install_roc.sh
roc startSee Installation for detailed setup and Usage for commands.
- Clone Repository:
git clone https://github.com/aab18011/roc.git cd roc - Run Installer:
sudo bash install_roc.sh
- Creates
rocuser, directories, virtual environment, installs dependencies, compiles v4l2loopback, sets up systemd service, and runs interactive config. - Prompts for OBS details, field number, scoreboard URL, and camera discovery method.
- Creates
- Post-Install:
- Edit
/etc/roc/config.jsonand/etc/roc/cameras.json. - Start service:
roc start
- Edit
Runs as a systemd service under the roc user. Manage via /usr/local/bin/roc.
roc start: Start service.roc stop: Stop service.roc restart: Restart service.roc status: Check status.roc logs [-f]: View logs (live with-f).roc health: Show system resources, service status.roc metrics: Display runtime metrics (JSON).roc cameras: List camera status (JSON).roc rules: Show scene rules status (JSON).roc config: Run configuration manager (if implemented).
-
Main Config (
/etc/roc/config.json): Defines system, network, OBS, camera, scoreboard, and scene settings. -
Cameras (
/etc/roc/cameras.json): Lists camera IPs, credentials, streams. -
Scene Rules (
/etc/roc/scene_rules.json): Specifies conditions and actions.Cameras (
/etc/roc/cameras.json):{ "cameras": [ { "id": "cam1", "ip": "192.168.1.100", "port": 554, "protocol": "rtsp", "path": "/main", "username": "admin", "password": "pass123", "stream_type": "main" } ] }Complex Scene Rule (
/etc/roc/scene_rules.json):{ "name": "game_with_timeout", "priority": 80, "conditions": [ {"field": "game_time", "operator": ">", "value": 0}, {"field": "timeout_active", "operator": "=", "value": true} ], "actions": [ {"type": "switch_scene", "scene": "timeout"}, {"type": "delay", "value": 5}, {"type": "switch_scene", "scene": "game"} ] } -
Hot-reload rules by editing
scene_rules.json.
- Runtime: Monitors scoreboards, evaluates rules, controls OBS scenes asynchronously.
- Customization: Add custom actions in rules (e.g., Python snippets).
- Debugging: Set
"debug_mode": truein config for verbose logs.
Adheres to PEP 8, structured modularly:
- roc_bootstrap_enhanced.py: Initializes system, checks dependencies, discovers cameras. Uses
NetworkRetryManager,EnhancedCameraDiscovery,ROCBootstrap. - roc_main_enhanced.py: Manages runtime, cameras, scene engine. Includes
ConnectionManager,CameraManager,SceneEngine. - roc_scene_engine.py: Rule-based engine for scene switching. Uses
SceneEngineAdvancedfor JSON rule evaluation.
Uses asyncio for concurrency, dataclasses for structures, logging for traceability.
ROC aims to enhance flexibility and control for livestreaming. Planned features include:
- RTSP/RTMP Support: Add
"protocol": "rtsp"or"rtmp"incameras.jsonto support varied camera types. Challenge: Ensuring compatibility with diverse camera firmware. - Headless OBS: Enable OBS control without a GUI via WebSocket, ideal for lightweight servers. Challenge: Testing on minimal Linux distros.
- Remote Control: Develop a mobile app or Raspberry Pi interface for on-the-field scene toggling, with override priority. Challenge: Secure key-based authentication for remote commands.
- Automated Ads: Import video ads from a folder, resize via FFmpeg, and schedule in OBS. Challenge: Optimizing resize performance for real-time playback.
- Stop service:
roc stop - Disable service:
systemctl disable roc.service - Remove files:
sudo rm -rf /opt/roc /etc/roc /var/log/roc /tmp/roc sudo rm -f /usr/local/bin/roc /etc/systemd/system/roc.service sudo rm -f /etc/modprobe.d/roc-v4l2loopback.conf /etc/modules-load.d/roc-v4l2loopback.conf
- Remove user:
sudo userdel -r roc - Remove dependencies (optional):
sudo apt remove ffmpeg v4l-utils - Reload systemd:
systemctl daemon-reload - Remove v4l2loopback:
sudo rmmod v4l2loopback
| Issue | Possible Cause | Solution |
|---|---|---|
| FFmpeg stream fails | Incorrect RTSP URL | Verify URL with ffprobe rtsp://<ip>:554/main |
| OBS WebSocket error | Wrong port/password | Check /etc/roc/config.json for correct obs settings |
| High CPU usage | Too many cameras | Reduce cameras or set FFmpeg -threads 2 in cameras.json |
| Rules not triggering | Invalid JSON syntax | Validate scene_rules.json; enable "debug_mode": true |
| Service fails to start | v4l2loopback not loaded | Check `lsmod |
Open a GitHub Issue with logs and system details.
We welcome contributions to ROC! To contribute:
- Fork the repository and create a feature branch (
git checkout -b feature/xyz). - Follow PEP 8.
- Update the Changelog with your changes.
- Submit a pull request with a clear description.
- For bugs or features, open an issue with logs and steps to reproduce.
See CONTRIBUTING.md for details.
ROC is provided "as is" without warranty of any kind. Use at your own risk, and ensure proper configuration for production environments.
ROC is licensed under the MIT License. See LICENSE or the MIT License text.
Follows Keep a Changelog and Semantic Versioning.
- Planned: RTSP/RTMP protocol selection in config.
- Planned: Headless OBS control.
- Planned: Remote control via smartphone/Raspberry Pi.
- Planned: Automated advertisement playback.
- Hot-reload for scene rules.
- Network retry backoff bugs.
- Unified codebase, merging scene switcher, custom v4l2loopback installer, and FFmpeg-v4l2loopback connector from separate v2.x repositories into a single, modular system.
- Phase-based architecture (bootstrap, main runtime, scene engine).
- Enhanced installer with rollback, progress tracking, and interactive config.
- Systemd service for robust deployment.
- Camera auto-discovery (ARP/brute-force).
- Advanced scene engine with JSON rules, supporting complex conditions and actions.
- Replaced v2.x series’ fragmented codebase with a cohesive, Python-driven system, improving maintainability and performance.
- Optimized asynchronous processing and polling for lower latency.
- SQLite database (unused, added complexity).
- Separate bash orchestrator (now integrated into Python).
- Dynamic polling (0.1s for critical moments).
- Pause detection via three consecutive identical timer values.
- Scene switch caching to avoid redundant switches.
- Optimized breakout sequence (7s Breakout, 30s Default, Game Scene).
- Robust OBS WebSocket keep-alive.
- Suppressed verbose third-party logs.
- Refactored into
ROCControllerclass. - Enhanced config handling with fallbacks.
- Optimized game start detection and scoreboard parsing.
- Improved mid-match startup robustness.
- Mid-match startup issues.
- Excessive Selenium log output.
- SQLite database for logs (removed in v2.2.8).
setup.pyfor dependency automation.- Systemd service (
roc-controller.service). - Network checks for WAN/LAN.
- Persistent browser session for polling.
- Updated scoreboard IPs.
- Removed stability check for faster data acceptance.
- Optional
bracket.odshandling. - Refined camera switching logic.
FileNotFoundErrorforbracket.ods.- Placeholder team name parsing.
- Persistent
Interview Sceneissues.
- SQLite database and related functionality.
- Streamlined logging to file-based output.
- Improved virtual environment checks.
- Robust virtual environment checks with
.roc-venvmarker.
- Dependency installation issues.
- Detailed logging with timestamps and state changes.
- Modernized systemd service configuration.
- Standardized log format.
- OBS WebSocket stability with better reconnection logic.
- Improved OBS WebSocket session persistence.
- Excessive WebSocket traffic.
- Single-file structure (
main.py).
- Consolidated functionality into one script.
- Multiple Python files and bash orchestrator.
- Initial release with scoreboard monitoring, OBS control, bracket parsing, network checks, pause functionality, camera switching, virtual environment, systemd integration, and bash orchestration.
- Issues with bracket file, team names, stability checks, logging verbosity, scene persistence, and dependency management.