๐ Translate Subtitle
Machine-Translate a Subtitle File Without Breaking the Timing
- ai_config
- translated_srt
Translating a subtitle file with a generic LLM prompt is how you get translations that don't line up with the original - the model merges two lines, skips one, and suddenly your subtitles are showing the wrong text at the wrong time. MF_TranslateSubtitle exists to keep the numbering honest. It takes SRT text in, sends it to an LLM in numbered batches, and either returns a translation with every line accounted for or refuses to run at all.
You reach for it right after MF_WhisperTranscribe, which is exactly how the pack's demo chain goes: transcribe โ translate โ burn. Feed srt_text in, get translated_srt out with the timestamps preserved, and wire that straight into MF_BurnSubtitle. That's a fully automated localization pipeline in three nodes - no video editor, no manual retiming.
How it works
The node parses the SRT, then sends lines to the LLM as numbered batches - [1] ..., [2] ... - through the standard /v1/chat/completions endpoint. It parses the response by the same numbering pattern. Here's the design decision worth appreciating: if the line count drifts (the model merged or dropped a line), the node raises an error rather than quietly emitting misaligned subtitles. A silent off-by-one in subtitle alignment is a broken video; a loud failure is a retry. That's the right trade.
The backend is always openai_compatible. That's not a limitation, it just means you can point base_url anywhere that speaks the OpenAI chat API - OpenAI, Groq, or a local Ollama / LM Studio / llama.cpp server for a fully local chain.
The inputs that matter
ai_config(required) - wire fromMF_AIConfig, and it must beprovider=openai_compatible. Thefaster_whisper_localprovider raises here; that's an STT-only mode.srt_text- the SRT as a string, wired fromMF_WhisperTranscribeor pasted by hand.target_lang- free-form, e.g.English,ๆฅๆฌ่ช,Espaรฑol. Default is็น้ซไธญๆ(the author's home turf).batch_size- lines per LLM call, default 20. Smaller is more reliable; larger is faster until small models drift.
Output: translated_srt (STRING) - SRT with original timestamps, ready for MF_BurnSubtitle.srt_text or MF_ConvertChinese if you want it normalized (say, simplified โ traditional with Taiwan vocabulary) before burning.
Install
Ships in the MediaForge pack. ComfyUI Manager โ search "MediaForge", or:
cd ComfyUI/custom_nodes
git clone https://github.com/leon80148/comfyui_MediaForge.git
Restart, and you'll find it under MediaForge/AI. The pack's requirements.txt already includes requests, which is all a hosted translation needs. For a local LLM you'll want Ollama or LM Studio running on your own box - see below.
Common issues
- Line count drifts on big batches. The README's own guidance:
gpt-4o-miniis fine up to batch ~30; for long-form or specialized vocabulary switch togpt-4oor Groq'sllama-3.3-70b-versatileand you can push batch 50+. Or just dropbatch_sizeand retry. - Fully offline pipeline? Ollama / LM Studio don't expose Whisper, so they work for translate only. Pair
openai_compatiblepointed athttp://localhost:11434/v1withfaster_whisper_localon the transcribe side, and nothing leaves your machine. - Empty
srt_textraises - you'll get a message telling you to wire the transcribe output or paste an actual SRT. It's a guard, not a bug.
One takeaway: treat this node as the translation layer of a bigger assembly, not a standalone toy. Its whole job is producing SRT that's structurally identical to what went in - and refusing loudly when the LLM gets sloppy. That stubbornness is what makes the chain downstream (burn, upload, publish) trustworthy.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| ai_config | AI_CONFIG | โ | |
| srt_text | STRING | โ | |
| target_lang | STRING | ็น้ซไธญๆ | โ |
| system_prompt | STRING | ไฝ ๆฏๅฐๆฅญๅญๅน็ฟป่ญฏใๅฐๆฏไธๆฎต็ฟปๆ {target_lang}๏ผไฟ็่ชๆฐฃใไธ่งฃ้ใไธๅ ่จป่งฃใๆฏๆฎตๅฐๆไธๅ่ผธๅบๆฎตใ | โ |
| batch_size | INT | 201โ200 | โ |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| translated_srt | STRING | โ |