Automatic Subtitle Translation Implementation
Subtitle translation is a task with hard constraints that distinguish it from standard machine translation: line length, timing, synchronization with speech, style preservation.
Technical Subtitle Constraints
SRT/VTT format imposes translation requirements:
- Maximum line length: 42 characters (Netflix standard) or 84 characters (2 lines)
- Display duration: 1–7 seconds per subtitle block
- Reading speed: ≤ 17 characters/second for film, ≤ 20 for documentary
LLM must not just translate, but fit these constraints.
Translation Pipeline
[SRT/VTT file]
→ [Parsing: subtitles with timing]
→ [Batching: groups of 20–30 subtitles for context]
→ [LLM translation with length constraints]
→ [Post-check: line length, reading speed]
→ [Auto-truncation if limit exceeded]
→ [Assembly back to SRT/VTT]
Batching by groups is important: model sees neighbor subtitle context and translates coherently, without meaning breaks between blocks.
Prompt for Constrained Translation
Translate subtitles from English to Russian.
Constraints:
- Maximum 84 characters per block (2 lines of 42)
- Preserve meaning, adaptation allowed
- Don't use quotes unless in original
- Keep proper names unchanged
Supported Languages and Models
For Russian, Ukrainian, European languages—GPT-4o-mini (optimal quality-speed ratio). For rare languages (Swahili, Vietnamese, Hindi)—NLLB-200 (Meta) as fallback, or GPT-4o for critical content.
Processing a 90-minute film (≈1200 subtitles): 30–60 seconds, cost < $0.05 per language with gpt-4o-mini.







