A high-performance video processing service built with Hono.js and BullMQ for handling video transformations. This API allows users to upload videos and process them with various options like quality adjustment, format conversion, and resolution changes.
- Video upload with automatic file handling
- Asynchronous video processing using queue system
- Support for multiple video processing options:
- Quality adjustment
- Format conversion
- Resolution modification
- Job status tracking
- Error handling
- File upload security with unique filename generation
- Hono.js - Lightweight web framework
- BullMQ - Queue system for handling video processing jobs
- FFmpeg - Video processing engine
- Redis - Queue storage and job management
- Bun - JavaScript runtime & package manager
- TypeScript - Type safety and better developer experience
- Node.js 16+
- Redis server
- FFmpeg installed on your system
- Bun runtime
- Clone the repository
- Install dependencies:
bun install
- Create a
.env
file:
env
PORT=3001
REDIS_HOST=localhost
REDIS_PORT=6379
- Start the server:
bun run dev
http://localhost:3001/api/video/upload
Query Parameters:
quality
(optional) - Video bitrate qualityformat
(optional) - Output format (e.g., mp4, webm)resolution
(optional) - Video resolution (e.g., 1280x720)
Request Body:
- Form data with video file (key:
video
)
Response:
{
"jobId": "string",
"status": "processing"
}
GET /api/video/status/:jobId
Response:
{
"jobId": "string",
"status": "completed|failed|processing|waiting"
}
Query Parameters:
quality
(optional) - Video bitrate qualityformat
(optional) - Output format (e.g., mp4, webm)resolution
(optional) - Video resolution (e.g., 1280x720)
Request Body:
- Form data with video file (key:
video
)
curl -X POST \
'http://localhost:3001/api/video/upload?quality=1000k&format=mp4&resolution=1280x720' \
-F 'video=@/path/to/video.mp4'
Response:
{
"jobId": "string",
"status": "completed|failed|processing|waiting"
}
├── src/
│ ├── config/ # Configuration files (Redis, etc.)
│ ├── middlewares/ # Custom middlewares
│ ├── routes/ # API routes
│ ├── services/ # Business logic
│ ├── types/ # TypeScript type definitions
│ └── index.ts # Application entry point
The application can be configured using environment variables:
PORT
- Server port (default: 3001)REDIS_HOST
- Redis server hostREDIS_PORT
- Redis server port
- Unique filename generation for uploaded files
- File type validation
- Error handling middleware
- Secure file storage management
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a new Pull Request
This project is licensed under the MIT License.