Description:
VideoTranslator is a powerful application designed to automatically translate video content into multiple languages. Leveraging advanced AI models for transcription and translation, it provides a seamless way to make video content accessible globally.
Clone the repository:
git clone https://github.com/phambaophuc/VideoTranslator.git
cd VideoTranslator
Install dependencies:
npm install
Configure Environment Variables:
Create a .env file in the root directory and populate it with your configuration. Use .env.example as a template:
cp .env.example .env
Important: Ensure you set your GROQ_API_KEY.
PORT=3000
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=
GROQ_API_KEY=your_groq_api_key_here
THROTTLE_TTL=60000
THROTTLE_LIMIT=60
MAX_VIDEO_SIZE_MB=500
Run the application:
npm run start:dev
This project provides a docker-compose.yml file for easy setup with Docker.
docker-compose up --build
This command will start the application and a Redis instance.
This application allows you to upload a video and receive a translated version with subtitles burned in.
Send a POST request to the /api/videos endpoint with a multipart/form-data payload. The video file should be sent as the video field.
You can optionally specify the target language using the language field (e.g., en for English, vi for Vietnamese).
Example using cURL:
curl -X POST -F "video=@/path/to/your/video.mp4" -F "language=en" http://localhost:3000/api/videos
Upon successful upload, the API will return a JSON response containing the videoId, jobId, status, and targetLanguage.
{
"videoId": "your-generated-video-id",
"jobId": "bullmq-job-id",
"status": "queued",
"targetLanguage": "en"
}
You can check the processing status of a video using its videoId.
API Endpoint: GET /api/videos/:videoId/status
Example:
curl http://localhost:3000/api/videos/your-generated-video-id/status
This will return the current progress and status of the video processing job.
{
"videoId": "your-generated-video-id",
"jobId": "bullmq-job-id",
"status": "transcribing",
"progress": 30,
"step": "transcribing",
"message": "Transcribing audio..."
}
Once the processing is complete, you can retrieve the translated video.
API Endpoint: GET /api/videos/:videoId/video
Example:
curl -o translated_video.mp4 http://localhost:3000/api/videos/your-generated-video-id/video
This endpoint supports range requests for efficient streaming.
Monitor the translation progress in real-time using Server-Sent Events (SSE).
API Endpoint: GET /api/videos/:videoId/events
Example:
curl http://localhost:3000/api/videos/your-generated-video-id/events
This will stream progress updates as the video is processed.