A modern Node.js backend service for processing and streaming video content using HTTP Live Streaming (HLS) protocol.
This project provides a robust solution for video processing and adaptive streaming. It takes uploaded videos, transcodes them into multiple quality levels (360p, 420p, 720p, 1080p), and generates HLS playlists for adaptive streaming. The processed content is then stored in cloud storage (using Vercel Blob Storage) for delivery to users.
- Upload video files via REST API
- Real-time progress monitoring with WebSocket (Socket.IO)
- Automatic video transcoding to multiple resolutions
- HLS playlist generation for adaptive bitrate streaming
- Cloud storage integration with Vercel Blob Storage
- RESTful API for video management
- Video-on-demand platforms
- Online courses with video content
- Live streaming applications
- Media sharing platforms
- Video content management systems
- User-generated content platforms
- Backend Server: Express.js application handling HTTP requests
- Socket Server: Socket.IO for real-time progress updates
- Transcoding Engine: FFmpeg for video processing
- Storage: Vercel Blob Storage for hosting processed content
- Client uploads a video file to the
/upload
endpoint - Server receives the file and saves it temporarily
- FFmpeg transcodes the video to multiple quality levels (360p, 420p, 720p, 1080p)
- During transcoding, progress updates are sent to the client via WebSockets
- HLS playlists (.m3u8) and segments (.ts) are generated for each quality level
- All files are uploaded to Vercel Blob Storage
- The server sends back URLs to access the processed content
- Local temporary files are cleaned up automatically
- Node.js (v14+)
- FFmpeg installed on the server
- Vercel Blob Storage account (or Cloudinary as alternative)
-
Clone the repository
-
Install dependencies:
npm install
or
pnpm install
-
Create a
.env
file with the following variables:PORT=3000 BLOB_READ_WRITE_TOKEN=your_vercel_blob_token
-
Start the development server:
npm run dev
or
pnpm dev
- URL:
/upload
- Method:
POST
- Content-Type:
multipart/form-data
- Request Body:
video
: The video filesocketId
(optional): Socket ID for real-time progress updates
{
"success": true,
"message": "Video processing complete",
"id": "unique-folder-id",
"duration": "00:01:30",
"durationDetails": {
"hours": 0,
"minutes": 1,
"seconds": 30,
"rawSeconds": 90.5
},
"urls": {
"master": "https://cdn-url/videos/folder-id/master.m3u8",
"360": "https://cdn-url/videos/folder-id/360p.m3u8",
"420": "https://cdn-url/videos/folder-id/420p.m3u8",
"720": "https://cdn-url/videos/folder-id/720p.m3u8",
"1080": "https://cdn-url/videos/folder-id/1080p.m3u8"
}
}
- join_room: Join a specific room to receive updates
- progress: Receive transcoding progress updates
- completed: Receive notification when processing is finished
- Express.js - Web server framework
- Socket.IO - Real-time bidirectional event-based communication
- FFmpeg - Video processing and transcoding
- Multer - File upload middleware
- Vercel Blob Storage - Content delivery and storage
- UUID - Unique identifier generation
This project includes a Dockerfile for containerized deployment:
docker build -t hls-video-uploader .
docker run -p 3000:3000 -e BLOB_READ_WRITE_TOKEN=your_token hls-video-uploader
npm i video-hls-converter
ISC