Skip to content

StreamVision - View and manage your RTSP CCTV camera feeds live in real time with powerful analytics and security

Notifications You must be signed in to change notification settings

CodeByAmrit/StreamVision

Repository files navigation

Stream Vision

πŸ“Ή StreamVision

StreamVision is a Node.js-based real-time DVR camera streaming platform that allows users to stream multiple RTSP camera feeds directly in the browser. It supports dynamic DVR configurations, lazy loading of streams, and a responsive public viewer page.


οΏ½ Features

  • πŸ”’ Dynamic DVR login with username/password/IP
  • οΏ½ Stream up to 16 RTSP camera channels per DVR
  • βš™οΈ FFmpeg-based RTSP to HLS conversion (one worker per DVR)
  • 🌐 Public view for each DVR's live streams
  • 🧠 Lazy loading of video players using Intersection Observer
  • πŸ–₯️ EJS templating with Tailwind CSS
  • πŸ“ Organized architecture (routes, controllers, workers, views)

πŸ›  Tech Stack

  • Backend: Node.js, Express
  • Frontend: EJS, Tailwind CSS, Video.js
  • Streaming Engine: FFmpeg (RTSP β†’ HLS)
  • Database: MySQL (for DVRs, Cameras, Locations)
  • Worker Management: worker_threads (Node.js)

πŸ“ Project Structure

StreamVision/
β”œβ”€β”€ app.js                         # Main Express server
β”œβ”€β”€ cluster.js                     # Cluster setup for multi-threaded server
β”œβ”€β”€ config.nginx                   # Nginx configuration for reverse proxy
β”œβ”€β”€ ecosystem.config.js            # PM2 process manager configuration
β”œβ”€β”€ package.json                   # Project metadata and dependencies
β”œβ”€β”€ README.md                      # Project documentation
β”œβ”€β”€ tailwind.config.js             # Tailwind CSS configuration
β”œβ”€β”€ .env                           # Environment variables
β”œβ”€β”€ .gitignore                     # Git ignore rules
β”œβ”€β”€ config/                        # Configuration files
β”‚   └── getConnection.js           # Database connection logic
β”œβ”€β”€ controllers/                   # Business logic
β”‚   β”œβ”€β”€ camerasController.js       # Handles camera-related operations
β”‚   β”œβ”€β”€ dvrController.js           # Handles DVR-related operations
β”‚   └── publicStreamController.js  # Handles public stream-related operations
β”œβ”€β”€ database/                      # Database-related files
β”‚   └── structure.sql              # SQL script for database structure
β”œβ”€β”€ models/                        # Data models
β”‚   β”œβ”€β”€ cameraModel.js             # Camera model
β”‚   └── user.js                    # User model
β”œβ”€β”€ public/                        # Static assets and stream outputs
β”‚   β”œβ”€β”€ site.webmanifest           # Web manifest for PWA
β”‚   β”œβ”€β”€ up.html                    # Uptime status page
β”‚   β”œβ”€β”€ css/                       # CSS files
β”‚   β”œβ”€β”€ images/                    # Image assets
β”‚   β”œβ”€β”€ js/                        # JavaScript files
β”‚   └── streams/                   # HLS video output directories
β”œβ”€β”€ routes/                        # Express route definitions
β”‚   β”œβ”€β”€ camera.js                  # Camera-related routes
β”‚   β”œβ”€β”€ cameraRoutes.js            # Additional camera routes
β”‚   β”œβ”€β”€ dvrs.js                    # DVR-related routes
β”‚   β”œβ”€β”€ publicRoutes.js            # Public-facing routes
β”‚   └── userRouters.js             # User-related routes
β”œβ”€β”€ services/                      # Service logic
β”‚   β”œβ”€β”€ aouth.js                   # OAuth-related logic
β”‚   β”œβ”€β”€ auth.js                    # Authentication logic
β”‚   └── checkauth.js               # Middleware to check authentication
β”œβ”€β”€ src/                           # Source files
β”‚   └── input.css                  # Tailwind CSS input file
β”œβ”€β”€ streams/                       # Stream-related files
β”‚   └── (dynamic HLS stream folders created at runtime)
β”œβ”€β”€ utils/                         # Utility functions
β”‚   └── streamManager.js           # Manages active HLS streams
β”œβ”€β”€ views/                         # EJS templates
β”‚   └── dvr_live_public.ejs        # Public DVR stream view

βš™οΈ Installation & Setup

Prerequisites

  • Node.js (v14+ recommended)
  • MySQL database
  • FFmpeg installed on your system
  • Nginx (for production deployment)

1. Install Dependencies

npm install

2. Configure Environment

Create a .env file in the root directory with the following variables:

# Server Configuration
PORT=3000
NODE_ENV=development

# Database Configuration
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=yourpassword
DB_DATABASE=streamvision
DB_PORT=3306

# JWT Configuration
jwt_token=your_jwt_secret

# Password Hashing
saltRounds=10

# SSL Configuration (Optional)
DB_CA=/path/to/your/server-cert.pem

3. Database Setup

Import the database structure from database/structure.sql to your MySQL server.

4. Build CSS

npm run build:css

πŸš€ Running the Application

Development Mode

npm run dev

Production Mode

npm start

Using PM2 (Production)

npm run start:pm2

Nginx Setup (Production)

# Install Nginx (Ubuntu/Debian)
sudo apt update && sudo apt install -y nginx

# Restart Nginx
npm run restart:nginx

πŸ›  Available Scripts

Command Description
npm start Starts the production server
npm run dev Starts the development server with nodemon
npm run build:css Builds Tailwind CSS
npm run start:pm2 Starts the app using PM2 process manager
npm run restart:nginx Restarts Nginx service
npm run setup:linux Installs all required Linux dependencies

πŸ“¦ Dependencies

Core Dependencies

  • Express.js
  • MySQL2
  • FFmpeg
  • Tailwind CSS
  • Video.js
  • JWT for authentication
  • Bcrypt for password hashing

Development Dependencies

  • Nodemon
  • Express Status Monitor

πŸ“„ License

ISC Β© Amrit


πŸ™ Acknowledgments

  • FFmpeg team for powerful media processing
  • Video.js for excellent player implementation
  • Tailwind CSS for utility-first styling

About

StreamVision - View and manage your RTSP CCTV camera feeds live in real time with powerful analytics and security

Topics

Resources

Stars

Watchers

Forks