A Python tool that extracts and translates subtitles from MKV files using AI.
- Extracts subtitle tracks from MKV files using ffmpeg
- Translates subtitles using AI model (only Google's Gemini currently implemented. You need to create a free key https://aistudio.google.com/apikey)
- Supports batch processing to handle rate limits
- Shows estimated completion time during translation
- Saves translated subtitles as SRT files
- Python 3.x
- Clone this repository
- Install required packages:
pip install -r requirements.txt
- Create a
.env
file with your configuration:
PROVIDER=gemini
API_KEY=your_gemini_api_key
LANGUAGE=target_language
Run the script with an MKV file as argument:
python subtranslator.py video.mkv
The script will:
- List all available subtitle tracks in the MKV file
- Let you select which subtitle track to translate
- Extract and translate the subtitles
- Save the translated subtitles as
video_language.srt
Configure the translator by editing the .env
file:
PROVIDER
: Translation provider (currently only supportsgemini
)API_KEY
: Your Gemini API keyLANGUAGE
: Target language for translation
- ffmpeg-python
- python-dotenv
- google-genai
MIT License