A robust REST API service for video file management with features for uploading, trimming, merging, and sharing videos.
Features • Prerequisites • Quick Start • API Docs • Development
- 🔐 JWT Authentication
- 📤 Video Upload (with size/duration validation)
- ✂️ Video Trimming
- 🔄 Video Merging
- 🔗 Shareable Links (with TTL)
- 📚 Swagger Documentation
- 🗄️ SQLite Database
- 📦 Redis Caching
- Node.js (v14+)
- npm (v6+)
- Redis Server (v6+)
- FFmpeg
# Install FFmpeg
choco install ffmpeg
# Install Redis
choco install redis-64
# Start Redis Server
redis-server
git clone https://github.com/Jay-2019/video-service.git
cd video-service
npm install
Create .env file:
PORT=3000
JWT_SECRET=video_service_jwt_secret
JWT_ALGORITHM=HS256
USER_ID=SUPER_USER_ID
USER_ROLE=SUPER_ADMIN
MAX_VIDEO_FILE_SIZE=26214400 # 25MB in bytes
MIN_VIDEO_DURATION=5 # seconds
MAX_VIDEO_DURATION=60 # seconds
NODE_ENV=development
FFMPEG_PATH=C:\\ffmpeg\\bin\\ffmpeg.exe
FFPROBE_PATH=C:\\ffmpeg\\bin\\ffprobe.exe
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
SHAREABLE_LINK_TTL=86400 # 24 hours in seconds
mkdir assets/videos
node generateToken.js
# Copy the generated token for API requests
# Development mode
npm run dev
# Production mode
npm start
- API Server: http://localhost:3000
- Swagger UI: http://localhost:3000/api-docs
Method | Endpoint | Description |
---|---|---|
GET | /api/ping |
Health check |
POST | /api/videos/upload |
Upload video |
POST | /api/videos/trim |
Trim video |
POST | /api/videos/merge |
Merge videos |
POST | /api/videos/share/{videoId} |
Create share link |
GET | /api/videos/share/{linkId} |
Access shared video |
- Generate JWT token:
node generateToken.js
- Use the generated token in API requests:
Authorization: Bearer <your-generated-token>
video-service/
├── assets/
│ └── videos/ # Video storage
├── src/
│ ├── config/ # Configurations
│ ├── constants/ # Constants
│ ├── controllers/ # Controllers
│ ├── database/ # DB config
│ ├── middlewares/ # Middlewares
│ ├── models/ # Models
│ ├── redis/ # Redis config
│ ├── routes/ # Routes
│ ├── services/ # Services
│ └── utils/ # Utilities
├── .env # Environment vars
├── server.js # Entry point
└── swagger.json # API docs
npm test
-
Location: assets\videos
-
Supported format: MP4
-
Note: Manual cleanup required
- SQLite for metadata
- File: database.sqliteStorage Details
- Stores shareable links
- TTL management
- Requires running Redis server
- ✔️ File size validation
- ✔️ Video duration checks
- ✔️ Authentication errors
- ✔️ Video Processing errors
- ✔️ Database/Redis errors
This project is licensed under the MIT License - see the LICENSE file for details.
Jay Prakash Maurya