A video streaming platform inspired by modern OTT services like Netflix and YouTube. This project demonstrates how adaptive video streaming works under the hood using HLS (HTTP Live Streaming), FFmpeg, Node.js, Express.js, TypeScript, Next.js, MongoDB, and Prisma.
Instead of serving a single video file, uploaded videos are automatically processed into multiple resolutions, segmented into chunks, and streamed dynamically using HLS playlists.
- Upload videos through REST APIs
- Multer-based file handling
- Unique video identification using timestamp-based IDs
- Background video processing
-
Automatic generation of:
- 1080p
- 720p
- 480p
- 360p
-
Creates:
- Master Playlist (
master.m3u8) - Variant Playlists (
playlist.m3u8) - Video Segments (
.ts)
- Master Playlist (
- HTTP Live Streaming (HLS)
- Chunk-based video delivery
- Dynamic quality switching based on network conditions
- Browser playback using HLS.js
- MongoDB + Prisma integration
- Tracks video lifecycle:
PENDING
↓
COMPLETED
- Prevents users from accessing videos before processing is complete
- Dynamic streaming routes
- Video playback through HLS.js
- Netflix-style video access using unique video IDs
┌──────────────────┐
│ User │
└────────┬─────────┘
│
▼
┌──────────────────┐
│ Next.js UI │
└────────┬─────────┘
│
▼
┌──────────────────┐
│ Express Backend │
└────────┬─────────┘
│
┌──────────────┼──────────────┐
│ │
▼ ▼
┌────────────────┐ ┌────────────────────┐
│ MongoDB Atlas │ │ FFmpeg Processing │
│ Prisma ORM │ │ Pipeline │
└────────────────┘ └─────────┬──────────┘
│
▼
┌────────────────────────────┐
│ Multi-Resolution Outputs │
│ │
│ master.m3u8 │
│ 1080p/playlist.m3u8 │
│ 720p/playlist.m3u8 │
│ 480p/playlist.m3u8 │
│ 360p/playlist.m3u8 │
└──────────┬─────────────────┘
│
▼
┌──────────────┐
│ HLS.js │
│ Video Player │
└──────────────┘
backend
│
├── src
│ ├── controllers
│ │ └── video.controller.ts
│ │
│ ├── routes
│ │ └── video.routes.ts
│ │
│ ├── service
│ │ └── video.service.ts
│ │
│ ├── repository
│ │ └── movie.repository.ts
│ │
│ ├── middlewares
│ │ └── multer.middleware.ts
│ │
│ └── index.ts
│
├── uploads
├── output
└── prisma
frontend
│
├── app
│ ├── upload
│ ├── stream
│ │ └── [videoId]
│ │
│ └── page.tsx
│
├── components
│
└── lib
User uploads a video:
Frontend
|
▼
POST /api/v1/video/upload
The backend receives the file through Multer and stores it temporarily.
A unique identifier is generated:
const videoId = Date.now();Example:
1780591338544
Output folder:
output/1780591338544
A movie entry is created in MongoDB.
Movie
├── movieId
├── processingStatus
├── createdAt
└── updatedAt
Initial status:
PENDING
The uploaded video is processed into multiple resolutions:
1080p
720p
480p
360p
Each resolution generates:
playlist.m3u8
segment001.ts
segment002.ts
segment003.ts
...
A master playlist is created:
master.m3u8
Example:
#EXTM3U
1080p/playlist.m3u8
720p/playlist.m3u8
480p/playlist.m3u8
360p/playlist.m3u8
The player uses this file to select the appropriate quality.
After processing completes:
PENDING
↓
COMPLETED
The status is updated inside MongoDB using Prisma.
Frontend route:
/stream/:videoId
Example:
/stream/1780591338544
Frontend checks processing status.
Still Processing Video...
Initialize HLS.js
Load master.m3u8
Start Streaming
output/
└── 1780591338544
│
├── master.m3u8
│
├── 1080p
│ ├── playlist.m3u8
│ ├── segment001.ts
│ ├── segment002.ts
│ └── ...
│
├── 720p
│ ├── playlist.m3u8
│ └── ...
│
├── 480p
│ ├── playlist.m3u8
│ └── ...
│
└── 360p
├── playlist.m3u8
└── ...
- Next.js
- React
- TypeScript
- Tailwind CSS
- HLS.js
- Node.js
- Express.js
- TypeScript
- Multer
- FFmpeg
- MongoDB Atlas
- Prisma ORM
- Adaptive Bitrate Streaming
- HTTP Live Streaming (HLS)
- Video Segmentation
- FFmpeg Transcoding
- Background Video Processing
- Repository Pattern
- REST API Design
- Dynamic Routing
- Media Processing Pipelines
- Playlist Generation
- Video Status Tracking
- Multi-Resolution Content Delivery
git clone <repository-url>cd backend
npm installCreate:
.envAdd:
DATABASE_URL=<your-mongodb-atlas-url>Run:
npm run devcd frontend
npm install
npm run dev- AWS S3
- Cloudinary
- BullMQ
- Redis Queue
- AWS CloudFront
- Thumbnail Generation
- Multi-Resolution Image Processing
- JWT Authentication
- User Profiles
- Upload Analytics
- Processing Dashboard
- Video Consumption Metrics