High-performance video download API powered by NestJS, yt-dlp, and FFmpeg.
| Tính năng | Mô tả |
|---|---|
| HLS Priority | Ưu tiên định dạng HLS để bypass throttling, tải nhanh gấp 10-20x |
| Real-time Remux | Chuyển đổi HLS (MPEG-TS) → MP4 on-the-fly bằng FFmpeg |
| Audio Fix | Tự động sửa lỗi "Malformed AAC" và codec không tương thích |
| Tính năng | Mô tả |
|---|---|
| Dynamic Analysis | Phân tích từ yt-dlp, không dùng config cứng |
| Bitrate Sorting | Ưu tiên bitrate cao nhất trong cùng resolution |
| Codec Labels | Hiển thị AV1/VP9/HDR và tag "Nhanh" cho HLS |
| Tính năng | Mô tả |
|---|---|
| Multi-threading | Tải song song với --concurrent-fragments |
| Memory Streaming | Stream trực tiếp, không ghi file tạm |
| Auto Fallback | Tự động chọn format khác khi gặp lỗi |
GET /video/formats?url={video_url}Response:
{
"title": "Video Title",
"thumbnail": "https://...",
"duration": 123,
"options": [
{
"label": "1080p HD (HLS MP4 - Nhanh)",
"format_id": "616",
"ext": "mp4",
"resolution": "1920x1080",
"type": "audio+video",
"sizeLabel": "~150 MB"
}
]
}GET /video/download?url={video_url}&format={format_id}&title={title}&size={size}Headers trả về:
Content-Type: video/mp4, audio/mp4, ...Content-Disposition: attachment; filename="..."Content-Length: (nếu biết trước size)
- Framework: NestJS 10.x
- Downloader: yt-dlp (bundled via yt-dlp-exec)
- Transcoder: FFmpeg (via ffmpeg-static)
- Language: TypeScript 5.x (Strict mode)
npm installTạo file .env:
PORT=8081
YTDL_METADATA_TIMEOUT_MS=30000 # increase on Render if you see timeout errors# Development
npm run start:dev
# Production
npm run build && npm run start:prodsrc/
├── main.ts # Entry point
├── app.module.ts # Root module
├── common/
│ └── pipes/ # Validation pipes
├── constants/ # Format configs
├── modules/
│ └── video/
│ ├── video.controller.ts # API endpoints
│ ├── video.service.ts # Core logic (900+ lines)
│ └── entities/ # Type definitions
└── utils/ # Helper functions
- Cloudflare Turnstile: Frontend xác thực trước khi gọi API
- URL Validation: Kiểm tra và whitelist các domain được hỗ trợ
- Rate Limiting: Có thể cấu hình thêm ở Nginx/Cloudflare
MIT License - Xem file LICENSE để biết thêm chi tiết.