A real-time RTMP streaming server with advanced AI threat detection, powered by NVIDIA's Florence-2 model. The system monitors video streams, analyzes captured frames for security threats, and provides intelligent notifications with threat severity assessment.
Real-time AI threat detection in action - Our system automatically identifies security threats and generates immediate safety alerts with detailed threat analysis, severity classification, and recommended actions.
- Real-time Security Monitoring: Continuously analyzes video frames from RTMP streams
- Dual-Layer AI Analysis: Combines pattern matching with advanced AI contextual analysis
- Multi-Level Threat Classification: CRITICAL, HIGH, MEDIUM, LOW threat severity levels
- Intelligent Notifications: Automated Telegram alerts with threat summaries
- Confidence Scoring: Provides threat confidence percentages and recommended actions
- Customizable Sensitivity: Configurable threat detection thresholds
The system employs a sophisticated two-stage analysis approach:
The threatDetector.js analyzes image classifications using predefined security patterns:
- CRITICAL Threats: Weapons, violence, break-ins, fires, explosions
- HIGH Threats: Unauthorized persons, suspicious behavior, masked individuals
- MEDIUM Threats: Unusual objects, after-hours activity, rapid movements
- LOW Threats: Minor anomalies, unexpected movement patterns
Advanced AI analysis using NVIDIA's Florence-2 model provides:
- Contextual understanding of the scene
- Behavioral pattern analysis
- Security-focused threat assessment
- Confidence scoring and reasoning
The system combines both analyses to provide accurate threat detection with minimal false positives.
├── src/ # Source code
│ ├── server.ts # Main RTMP server (TypeScript)
│ ├── server.js # Legacy JavaScript server
│ ├── threatDetector.js # 🛡️ AI threat detection engine
│ ├── imageClassifier.ts # AI classification service (NVIDIA Florence-2)
│ ├── telegramNotifier.ts# Security alert notification service
│ └── site.html # Web viewer interface
├── config/ # Configuration files
│ ├── config.js # Main configuration (JavaScript)
│ └── config.py # Python configuration (legacy)
├── data/ # Runtime data (ignored by git)
│ ├── captured_frames/ # Video frame captures
│ └── classification_results/ # AI classification results
├── docs/ # Documentation
│ └── README.md # Detailed documentation
├── package.json # Node.js dependencies and scripts
├── tsconfig.json # TypeScript configuration
└── .gitignore # Git ignore rules
-
Install dependencies:
npm install
-
Configure API keys in
config/config.js -
Start the server:
npm start # TypeScript version npm run start:js # JavaScript version
-
Stream to:
rtmp://localhost:1935/live/{stream_key}
Configure threat detection sensitivity in config/config.js:
threatDetection: {
notificationThreshold: 3, // MEDIUM and above (1-5 scale)
detailedAnalysis: true, // Enable AI contextual analysis
timeBasedAnalysis: true // Consider time-of-day factors
}- 5 - CRITICAL: Immediate danger (weapons, violence, break-ins)
- 4 - HIGH: Suspicious activity (unauthorized persons, climbing fences)
- 3 - MEDIUM: Potential concern (loitering, unusual objects)
- 2 - LOW: Minor anomaly (unexpected movement)
- 1 - NONE: Normal activity
Our system generates comprehensive safety alerts exactly like the one demonstrated in the image above:
🚨 SAFETY ALERT - CRITICAL PRIORITY 🚨
⏰ Time: 9/22/2025, 6:14:45 PM
🔍 DETECTED SITUATION:
In this image we can see a person standing on the floor and holding a
gun in his hands. We can also see some chairs, plants, grass, a group
of trees, a wall and some lights.
⚠️ THREAT INDICATORS:
• gun
📱 This is an automated safety monitoring alert.
🚨 IMMEDIATE ATTENTION REQUIRED 🚨
🤖 AI drone
📅 09/22/25
Real-world deployment ready - This exact alert format is delivered via Telegram, mobile push notifications, and web dashboard interfaces.
See docs/README.md for complete setup instructions, configuration options, and usage examples.
- Frame Capture: Automatically captures frames from RTMP streams at configurable intervals
- Instant Analysis: Each captured frame is immediately processed through the AI threat detection pipeline
- Continuous Surveillance: 24/7 monitoring with intelligent filtering to reduce noise
- Telegram Integration: Real-time security alerts sent to configured Telegram channels
- Threat Summaries: Rich notifications including threat level, confidence, reasoning, and recommended actions
- Threshold-based Filtering: Only sends notifications for threats above configured severity levels
- Multi-Modal Detection: Combines visual analysis with contextual understanding
- Pattern Recognition: Detects suspicious behaviors, weapons, unauthorized access, and security breaches
- Confidence Scoring: Provides reliability metrics for each threat assessment
- False Positive Reduction: Advanced algorithms minimize unnecessary alerts
npm run dev- Start with auto-reloadnpm run build- Compile TypeScriptnpm run classify- Test AI classificationnpm run notify- Test Telegram notificationsnpm run test-threat- Test threat detection systemnpm run simulate- Simulate security footage for testing
Key configuration files:
config/config.js- Main server and AI settingspackage.json- Dependencies and scriptstsconfig.json- TypeScript compiler options
Data directories are automatically created and managed by the application.
- NVIDIA Florence-2: Advanced vision-language model for image understanding
- Node Media Server: High-performance RTMP streaming server
- Telegram Bot API: Real-time security notifications
- TypeScript/Node.js: Modern, type-safe backend development
- Pattern Recognition: Advanced regex-based threat pattern matching
- AI Contextual Analysis: Intelligent scene understanding and threat assessment
- NVIDIA API Key: Required for Florence-2 image classification
- Telegram Bot Token: For security alert notifications
- Node.js 18+: Runtime environment
- RTMP Source: Video stream (security camera, OBS, etc.)
- Security Surveillance: Monitor restricted areas for unauthorized access
- Perimeter Protection: Detect fence climbing, break-ins, and intrusions
- Violence Detection: Identify fights, weapons, and dangerous situations
- Property Monitoring: Watch for vandalism, theft, and property damage
- After-Hours Security: Enhanced monitoring during off-business hours