Skip to content

andreypudov/video-translator

Repository files navigation

Video Translator

Install the package

pip install video-translator

Extract subtitles

extract_subtitles \
  --input-video input.mp4 \
  --output-subtitle input.srt \
  --input-language zh \
  --subtitle-area 90
  • the file name of the video to be processed
  • the file name of the output subtitles
  • the language of the subtitles in the video (ISO 639-1 language code)
  • the area of the subtitles on the frame (in percentage from the top left corner)

Translate subtitles

translate_subtitles \
  --input-subtitle input.srt \
  --output-subtitle output.srt \
  --input-language en \
  --output-language ru
  • the file name of the original subtitle file
  • the file name of the output subtitle file
  • the language of the original subtitle file (ISO 639-1 language code)
  • the language of the output subtitle file (ISO 639-1 language code)

Examples

Extracting subtitles from the Leviathan with the English subtitles on the video:

./samples/leviathan.png

extract_subtitles \
  --input-video samples/leviathan.mp4 \
  --output-subtitle samples/leviathan_extracted.en.srt \
  --input-language ru \
  --subtitle-area 80

Translating English subtitles to Russian and vice versa:

export OPENAI_API_KEY=<value>
translate_subtitles \
  --input-subtitle samples/leviathan.ru.srt \
  --output-subtitle samples/leviathan_translated.en.srt \
  --input-language ru \
  --output-language en