ruby script that takes a video file with subtitles, extracts the subtitles, translates it to another language + saves the translated subtitles
- Clone this repo
- Create a Google Cloud account. Then make a new project, download API credentials, add a billing method, and activate the Cloud Translation API.
- Set a local environment variable
GOOGLE_APPLICATION_CREDENTIALS
with the path to your Google Cloud credentials. It's a JSON file you downloaded from Google Cloud. - Run the script:
./translate.rb --input input_video.mkv --output translated_subtitles.srt --language es --stream 0:s:0
--input
: Path to the .mkv video file.
--output
: Path to save the translated .srt file (containing the translated subtitles)
--stream
: which stream to use as source language (for example '0:s:0' for first subtitle track)
--language
: target language for the translation (for example 'es' for Spanish)