Nodes/ComfyUI-Audio-Srt-Aligner/Video SRT Overlay (字幕合成)
ComfyUI Node

Video SRT Overlay (字幕合成)

Burn your SRT onto video frames without touching ffmpeg

By ahkimkoo·Created 4 months ago·Updated 4 months ago· 1
Video SRT Overlay (字幕合成)
  • images
  • images_with_subtitle
srt_string
font_family
font_size80
font_color#FFFFFF
border_color#000000
border_size2
shadow_color#000000
shadow_size2
shadow_offset_x2
shadow_offset_y2
effectfade
fade_in_duration300
fade_out_duration300
subtitle_y_position0.70
subtitle_x_margin0.20
fps24.0

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's srt_string output.
  • font_family - a dropdown scanned from the plugin's fonts/ dir plus ComfyUI/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) and subtitle_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_color as 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 at 127.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/.ttc into ComfyUI/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 fps is correct, check the SRT's own timestamps before hunting in the node - the overlay faithfully renders what it's given.
Categoryvideo/srt

Inputs (17)

NameTypeDefaultDescription
imagesIMAGE
srt_stringSTRING
font_familyCOMBO1 options:
font_sizeINT8012–200
font_colorSTRING#FFFFFF
border_colorSTRING#000000
border_sizeINT20–20
shadow_colorSTRING#000000
shadow_sizeINT20–20
shadow_offset_xINT2-20–20
shadow_offset_yINT2-20–20
effectCOMBOfade2 options: fade, none
fade_in_durationINT3000–2000
fade_out_durationINT3000–2000
subtitle_y_positionoptFLOAT0.700–1
subtitle_x_marginoptFLOAT0.200–0.5
fpsoptFLOAT24.01–120

Outputs (1)

NameTypeDescription
images_with_subtitleIMAGE