Skip to content

A backend-focused system for monitoring live streams and detecting anomalies in real time.

Notifications You must be signed in to change notification settings

ardamoustafa1/StreamGuard

Repository files navigation

📡 StreamGuard Enterprise

Next-Generation AI Broadcast Monitoring System

Python FastAPI OpenCV FFmpeg License

StreamGuard is an industrial-grade monitoring solution designed for TV channels, OTT platforms, and 24/7 livestreams. Unlike traditional tools that only ping a server, StreamGuard uses Computer Vision (OpenCV) and Audio Analysis (FFmpeg) to "watch" and "listen" to the stream like a human operator.

If the screen freezes or audio drops, it doesn't just alert you—it records video evidence, sends it to your phone, and logs the incident on a real-time Mission Control Dashboard.


🚀 Key Features

🧠 1. AI-Powered Visual Analysis

  • Frozen Frame Detection: Uses pixel-difference algorithms to detect if the broadcast is stuck, even if the player is still "buffering" correctly.
  • Black Screen Detection: Automatically flags complete signal loss.

🔊 2. Deep Audio Forensics

  • Silence Detection: Monitors decibel levels in real-time.
  • Instant Alerts: Triggers an alarm if audio drops below -50dB (configurable) for more than 5 seconds.

📼 3. Automated DVR & Evidence

  • Automatic Recording: When an error is detected, the system automatically acts as a DVR.
  • Telegram Upload: Records the last 15 seconds of the incident and uploads the video file to your Engineering Telegram Group immediately.

💻 4. Modern Command Center

  • Real-time Dashboard: A beautiful, dark-mode web interface (Linear-style design).
  • Live Metrics: Watch Motion Score and Volume Levels update every second.
  • Remote Control: Start/Stop the AI engine directly from your browser.

🛠️ Tech Stack

  • Core Engine: Python 3.9+
  • Vision: OpenCV (cv2), NumPy
  • Audio: FFmpeg, Subprocess
  • API / Backend: FastAPI, Uvicorn
  • Frontend: HTML5, CSS3 (Glassmorphism), Chart.js
  • Notifications: Telegram Bot API
  • Hardware: Optimized for CPU-only environments (No GPU required).

📸 Screenshots

Command Center (Web) Mobile Alert (Telegram)
Dashboard Telegram
Real-time analytics and control Instant video evidence on your phone

⚡ Quick Start

1. Installation

Clone the repo and install dependencies:

git clone https://github.com/yourusername/streamguard.git
cd streamguard
pip install -r requirements.txt

2. Configuration

Rename config.example.json to config.json and edit your settings:

{
    "telegram": {
        "bot_token": "YOUR_BOT_TOKEN",
        "chat_id": "YOUR_CHAT_ID"
    },
    "streams": [
        { "url": "http://your-hls-stream.m3u8" }
    ]
}

3. Launch

Run the dashboard server. The AI Engine will be managed automatically.

python dashboard_api.py

Access the dashboard at: http://localhost:8000


🛡️ Architecture

graph TD
    A[Live Stream HLS/RTMP] -->|Input| B(StreamGuard AI Engine)
    
    subgraph "Core Processing"
        B -->|CV2| C{Motion Analysis}
        B -->|FFmpeg| D{Audio Analysis}
    end
    
    C -->|Frozen?| E[Trigger Alarm]
    D -->|Silence?| E
    
    E -->|Action 1| F[Record Evidence .mp4]
    E -->|Action 2| G[Send Telegram Alert]
    F --> G
    
    B -->|Metrics| H[Status.json]
    H -->|API Read| I[FastAPI Backend]
    I -->|WebSocket/Poll| J[Web Dashboard]
Loading

🤝 Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

📄 License

MIT

About

A backend-focused system for monitoring live streams and detecting anomalies in real time.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published