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.
- π 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)
- 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)
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
- Node.js (v14+ recommended)
- MySQL database
- FFmpeg installed on your system
- Nginx (for production deployment)
npm install
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
Import the database structure from database/structure.sql
to your MySQL server.
npm run build:css
npm run dev
npm start
npm run start:pm2
# Install Nginx (Ubuntu/Debian)
sudo apt update && sudo apt install -y nginx
# Restart Nginx
npm run restart:nginx
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 |
- Express.js
- MySQL2
- FFmpeg
- Tailwind CSS
- Video.js
- JWT for authentication
- Bcrypt for password hashing
- Nodemon
- Express Status Monitor
ISC Β© Amrit
- FFmpeg team for powerful media processing
- Video.js for excellent player implementation
- Tailwind CSS for utility-first styling