Overview
Architected a high-concurrency CCTV monitoring system for the Haryana Government. Features low-latency RTSP-to-HLS transcoding and real-time motion forensics.
The Problem
Legacy analog cameras stream RTSP feeds incompatible with modern HTML5 video elements, creating security access latency bottlenecks for remote field audits.
Research Method
Evaluated HLS fragment segment durations. Discovered that 2-second segments minimize stream buffer lag without causing client network segment overload.
Architecture
Ingress RTSP feed → FFmpeg Alpine Transcoder (Segmented HLS) → Local Storage node → NGINX Static segment publisher with client caching headers.
Security & Auth
Hardware UUID address verified via dynamic token handshakes before authorizing stream access.
Performance Stats
Live stream lag delay: Reduced from 12s to 1.8s. Concurrent active viewers limit: 500+ streams.
Database Design
TABLE Feeds (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(50), rtsp_url TEXT, active BOOLEAN, logs_count INT);
API Routing Map
- →GET /api/feeds - Lists all CCTV nodes register arrays
- →GET /live/:feedId/index.m3u8 - Renders live HLS playlist chunks
Code Pipeline
// Spawn transcoder process
const { spawn } = require('child_process');
const ffmpeg = spawn('ffmpeg', [
'-rtsp_transport', 'tcp',
'-i', rtspUrl,
'-c:v', 'copy',
'-hls_time', '2',
'-hls_playlist_type', 'event',
filePath
]);Infrastructure & Deploy
Containerized deployment routed behind a Traefik reverse proxy node on dedicated Linux servers.
Future Roadmap
- ✔Add WebRTC peer-to-peer data channels to bypass proxy bandwidth consumption limits
- ✔Integrate motion detection logs indexing via WebSockets broadcasts