← BACK

VideoTranslator

Auto translate video

TypeScript ⭐ 0

VideoTranslator 🚀

NPM Version
Package License
NPM Downloads

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.

Table of Contents 📜

Features ⭐

  • 🎬 Automatic Video Translation: Upload your video and get it translated into various languages.
  • 🎤 Accurate Speech-to-Text: Utilizes advanced models for precise transcription of video audio.
  • 🌐 Multilingual Support: Supports translation into multiple languages, with Vietnamese as the default.
  • 🚀 Efficient Processing: Leverages background job processing with BullMQ for efficient handling of video translations.
  • 💻 Dockerized Deployment: Easily deploy and manage the application using Docker and Docker Compose.
  • ⚡ Real-time Progress Updates: Track the translation progress with Server-Sent Events (SSE).
  • ⚙️ Configurable: Environment variables allow for easy customization of ports, API keys, and other settings.

Tech Stack 💻

  • Languages: TypeScript, Node.js, YAML, JSON
  • Frameworks: NestJS, Express.js, Next.js (implied by dependencies, though not explicitly used as a frontend framework in the provided code)
  • Databases/Caches: Redis (for BullMQ)
  • AI/ML: Groq SDK (for Whisper transcription and LLM translation)
  • Other: FFmpeg (for media processing), Multer (for file uploads), BullMQ (for job queues), Throttler (for rate limiting)

Installation 🛠️

Prerequisites 📋

  • Node.js (v20 or higher recommended)
  • npm or yarn
  • Docker and Docker Compose (for containerized deployment)
  • FFmpeg installed on your system (if not using Docker, or if Docker image needs it manually)

Local Setup 🏡

  1. Clone the repository:

    git clone https://github.com/phambaophuc/VideoTranslator.git
    cd VideoTranslator
    
  2. Install dependencies:

    npm install
    
  3. 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
    
  4. Run the application:

    npm run start:dev
    

Docker Setup 🐳

This project provides a docker-compose.yml file for easy setup with Docker.

  1. Build and run the containers:
    docker-compose up --build
    

This command will start the application and a Redis instance.

Usage ⏯️

This application allows you to upload a video and receive a translated version with subtitles burned in.

Uploading a Video ⬆️

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"
}

Checking Video Status ⏳

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..."
}

Retrieving Translated Video ⬇️

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.

Real-time Progress Updates 📡

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.