Video SRT Overlay (字幕合成)
Burn your SRT onto video frames without touching ffmpeg
- images
- images_with_subtitle
VideoSrtOverlay is the render half of the ComfyUI-Audio-Srt-Aligner pack: you give it a batch of video frames and an SRT string, it paints the subtitles onto the frames, and hands you back images_with_subtitle ready for SaveImage or VideoCombine. No ffmpeg CLI, no temp files, no external subtitle tool. If you've already got timed subtitles, this is the whole "put them on the video" step in one node.
Its natural partner is the pack's own AudioSrtAligner, which produces the srt_string from audio. But it happily accepts any standard SRT text - paste one in, or pull it from whatever transcription tool you used. The node renders strictly per the SRT: it parses each entry's time range and text, and it doesn't merge or split anything, so what your SRT says is what lands on screen.
How it works
Each frame gets the active subtitle composited over it with Pillow. Before the loop it pre-renders each unique subtitle as an RGBA layer - with the chosen font, border stroke, and shadow - then blits it at the right frame for the right duration. fps converts the frame index into a time (frame / fps) that's matched against each SRT entry. The fade effect animates opacity over the fade-in/fade-out windows; none skips that for a hard cut (and is noticeably faster on long renders).
The inputs that matter
images(IMAGE, required) - your video frames as a(B, H, W, C)tensor, straight out of a VAE decode or a video-loading node.srt_string(STRING, required) - the subtitle content. Paste SRT text or wire in AudioSrtAligner'ssrt_stringoutput.font_family- a dropdown scanned from the plugin'sfonts/dir plusComfyUI/models/fonts/(.ttf/.otf/.ttc). For Chinese subtitles this matters: pick a CJK-capable font or you get tofu boxes.fps- must match your video's actual frame rate, or every subtitle drifts off its audio. This is the one input beginners skip and then blame the node for.subtitle_y_position(default 0.70) andsubtitle_x_margin(default 0.20) - vertical placement and the side margin that determines the wrapping width. 0.20 means ~10% blank each side.- The styling block -
font_size(default 80),font_color/border_color/shadow_coloras hex,border_size(0–20), shadow size and offset. Keep a dark border + shadow on; white-on-white video becomes unreadable fast.
Output
A single output, images_with_subtitle, same shape as the input. Feed it to SaveImage for stills or VideoCombine to mux into a video file.
Installing
Same pack, same install as its sibling - one install gets you both nodes:
cd ComfyUI/custom_nodes
git clone https://github.com/ahkimkoo/ComfyUI-Audio-Srt-Aligner
cd ComfyUI-Audio-Srt-Aligner
pip install -r requirements.txt
# restart ComfyUI
Or use ComfyUI Manager and search "ComfyUI-Audio-Srt-Aligner". Expect a heavier-than-it-looks dependency install (audio-separator, stable-ts, qwen-asr, modelscope are all in requirements.txt regardless of whether you use the overlay's sibling features).
Where people get burned
- Empty font dropdown. The plugin auto-downloads the Alibaba PuHuiTi Medium font on first load (~6.3MB into
fonts/) - but that download routes through a local proxy at127.0.0.1:8118, so it can silently fail if you don't have one. The fix is boring and reliable: drop any.ttf/.otf/.ttcintoComfyUI/models/fonts/, restart, and it appears in the dropdown. - Wrong
fps. The subtitles won't be in the wrong place, they'll be in the wrong time. Match it to the video or every line drifts. - No CJK font on Chinese text → boxes instead of characters. The auto-downloaded PuHuiTi is exactly for this; if it's missing, add any Chinese-capable font.
- If subtitles look like they're appearing one frame early or late and your
fpsis correct, check the SRT's own timestamps before hunting in the node - the overlay faithfully renders what it's given.
Inputs (17)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| srt_string | STRING | — | |
| font_family | COMBO | 1 options: | |
| font_size | INT | 8012–200 | — |
| font_color | STRING | #FFFFFF | — |
| border_color | STRING | #000000 | — |
| border_size | INT | 20–20 | — |
| shadow_color | STRING | #000000 | — |
| shadow_size | INT | 20–20 | — |
| shadow_offset_x | INT | 2-20–20 | — |
| shadow_offset_y | INT | 2-20–20 | — |
| effect | COMBO | fade | 2 options: fade, none |
| fade_in_duration | INT | 3000–2000 | — |
| fade_out_duration | INT | 3000–2000 | — |
| subtitle_y_positionopt | FLOAT | 0.700–1 | — |
| subtitle_x_marginopt | FLOAT | 0.200–0.5 | — |
| fpsopt | FLOAT | 24.01–120 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| images_with_subtitle | IMAGE | — |