Local pipeline for translating both:
- On-screen text in video frames using OCR + redraw
- Spoken audio tracks using ASR + translation + TTS dubbing
av_translate.py— root entrypoint for the end-to-end AV pipelinecli.py— root CLI wiringrunner.py— root orchestration for the AV flowpresets.py— root preset configurationaudio/— audio-specific modules (asr,tts,media,translation,types)video/— video-specific modules (ocr, frame rendering, video pipeline)
Run:
python av_translate.py \
--input input.mp4 \
--output translated_output.mp4 \
--source-lang fr \
--target-lang hi \
--device auto \
--preset balancedpython av_translate.py \
--input input.mp4 \
--output translated_turbo.mp4 \
--source-lang fr \
--target-lang hi \
--device auto \
--preset turbopython av_translate.py \
--input input.mp4 \
--output translated_balanced.mp4 \
--source-lang fr \
--target-lang hi \
--device auto \
--preset balancedpython av_translate.py \
--input input.mp4 \
--output translated_quality.mp4 \
--source-lang fr \
--target-lang hi \
--device auto \
--preset qualityYou can override preset parameters manually. Example:
python av_translate.py \
--input input.mp4 \
--output translated_custom.mp4 \
--source-lang fr \
--target-lang hi \
--preset turbo \
--asr-model large-v3 \
--difference-threshold 0.06- Translates on-screen text with the multithreaded video pipeline.
- Extracts source audio from the input video.
- Runs ASR with
faster-whisper. - Translates transcript text with NLLB (
facebook/nllb-200-distilled-600M). - Synthesizes dubbed speech with MMS-TTS (
facebook/mms-tts-*). - Muxes the translated video and dubbed audio into the final MP4.
--input— input video path--output— final translated output path--source-lang— source language ISO-639-1 code--target-lang— target language ISO-639-1 code--preset— one ofturbo,balanced, orquality--device—auto,cuda, orcpu
Advanced frame-processing controls:
--difference-threshold--max-consecutive-skips--max-workers--gpu-concurrency-limit--queue-size--frame-timeout
- Use GPU for best speed with
--device cuda, or--device autoif CUDA is available. turbofavors speed.balancedis the default tradeoff.qualityuses denser frame processing and more conservative settings.
ffmpegandffprobeinstalled and available inPATH- Python dependencies from
requirements.txt - Internet access on first run to download model weights
pip install -r requirements.txtpython av_translate.py \
--input demo/input.mp4 \
--output demo/output_hi.mp4 \
--source-lang fr \
--target-lang hi \
--device auto \
--preset balanced