AI Subtitle Translation: Whole-Track Translation via LLM
Subtitling a foreign video used to be a pipeline — transcribe, time, translate, review — with translation the most tedious stage. LLMs drove its cost to nearly zero, but most players don’t make translation part of the viewing experience: you export, open a site, upload, download, re-import. ZWPlayer collapses the chain into the player: choose a target language, click start, and the translation mounts as the secondary track. This article covers integration, the server protocol, and typical uses.
Player Side: Config + Panel
new ZWPlayer({
playerElm: 'player',
url: 'https://example.com/lecture.mp4',
subtitles: [{ url: 'https://example.com/en.srt', title: 'English' }],
translateApi: 'https://your-server.com/subtitle-api/api',
});
With the base URL set, the settings panel gains a “Subtitle Translate” entry. Open it, choose the source track and target language, click start.
Figure 1: the translate panel — pick the source subtitle and target language, translate the whole track
When translation finishes, the result mounts as the secondary track automatically, forming a dual subtitle with the original — no export/import round trip, no interrupted viewing. Combined with HLS/DASH Subtitle Preload, embedded stream subtitles can be translated whole as well.
Server Side: Open Protocol, Free Engine
translateApi points at a minimal HTTP subtitle service with a fully public protocol anyone can implement:
| Endpoint | Method | Purpose |
|---|---|---|
/api/languages |
GET | Supported target languages (fills the panel dropdown) |
/api/translate |
POST | multipart/form-data with the SRT and target language; returns the translation synchronously |
Two pragmatic design decisions:
- The upstream LLM is not locked in. Quality lives in the model; the protocol fixes “SRT in, SRT out”. Wire DashScope (
qwen-mt-flash), DeepSeek, or a self-hosted model — swap engines without touching the player; - Synchronous interface. A feature film is a seconds-to-minutes job for an LLM; synchronous keeps deployment to a single process, no job queue.
Auth is API-key based (optionally IP allowlist) — right-sized for personal and team use; add quotas before offering it publicly.
Three Typical Uses
- Language learning: original + AI translation in dual display, unknown words resolved in place; full-text subtitle search makes revisiting a line trivial;
- Course localization: translate an English course whole, mount as the secondary track, distribute inside the team; when unsure about quality, let AI produce the draft and humans proofread;
- Multilingual sites: video, N subtitle tracks generated per language, viewers choose in the menu — two orders of magnitude cheaper than rendering video per language.
Quality and Cost Expectations
- Common LLM weaknesses: proper-noun consistency (names drifting mid-video), slang, cultural references. Pinning the model and prompt per service improves consistency markedly;
- Cost ballpark: a 90-minute film ≈ 1,500 cues, typically cents at mainstream LLM pricing — three orders of magnitude below human translation;
- Always keep the original track: the translation is an aid, not a replacement; viewers can turn it off anytime.
FAQ
Must I self-host the service? Yes — the protocol is open and the reference implementation is lightweight (a single process). That is what keeps your subtitle data between you and the LLM you chose, with no middleman.
Does translation overwrite the original? No. It mounts on the secondary track; the original stays untouched, and the dual switch toggles original-only / translation-only / both.
BCC/VTT too? The exchange format is SRT; other formats convert first — the player’s export covers that step.