Extracting Subtitles from Video file using FFmpeg & Translating using Python Script
Step 1: Check available subtitle streams
Wiki topics:
LNG · Linguistics & Language
Extracting Subtitles from Video file using FFmpeg & Translating using Python Script
Step 1: Check available subtitle streams
ffmpeg -i your_movie.mkv

Step 2: Extract the subtitle
ffmpeg -i your_movie.mkv -map 0:2 subtitles_ita.srt

Now we have the .srt file extracted in the chosen directory
Translating .srt file to English by Using Python Script
Step 1: Install deep-translator
py -3 -m pip install deep-translator

Python Script:
from deep_translator import GoogleTranslator
input_file = r"D:\Test\subtitles_ita.srt"
output_file = r"D:\Test\subtitles_en.srt"
translator = GoogleTranslator(source='it', target='en')
with open(input_file, "r", encoding="utf-8") as f:
content = f.read()
blocks = content.strip().split("\n\n")
translated_blocks = []
for block in blocks:
lines = block.split("\n")
if len(lines) < 3:
translated_blocks.append(block)
continue
number = lines[0]
timestamp = lines[1]
dialogue = " ".join(lines[2:])
try:
translated_dialogue = translator.translate(dialogue)
if not translated_dialogue:
translated_dialogue = dialogue # fallback if empty
except Exception:
translated_dialogue = dialogue # fallback if error
new_block = f"{number}\n{timestamp}\n{translated_dialogue}"
translated_blocks.append(new_block)
translated_content = "\n\n".join(translated_blocks)
with open(output_file, "w", encoding="utf-8") as f:
f.write(translated_content)
print("✅ Translation complete (with fallback protection)!")

Successfully translated the .srt file and saved a new copy!
Easy Method : Use Subtitle Edit
Open subtitles_ita.srt in Subtitle Edit
Go to: Auto-translate → Google Translate
Choose:
→ From: Italian
→ To: English
Click Translate → Save as subtitles_en.srt

메타데이터
- post_id
- 554a44990e35
- slug
- extracting-subtitles-from-video-file-using-ffmpeg-translating-using-python-script-554a44990e35
- url
- https://medium.com/@haq.prg/extracting-subtitles-from-video-file-using-ffmpeg-translating-using-python-script-554a44990e35
- canonical_url
- https://medium.com/@haq.prg/extracting-subtitles-from-video-file-using-ffmpeg-translating-using-python-script-554a44990e35
- author_url
- https://medium.com/@haq.prg
- status
- ok
- fetched_at
- 2026-07-14 10:49:49