Subtitle Text Replace (文本替换)
Fix every typo in your subtitles without touching the source file
- subtitle_data
- subtitle_data
- preview
There's a specific kind of pain this node exists to fix: your Whisper transcription nailed the timing but butchered the text, or you transcribed in English and want to burn Chinese, or you just noticed a name is spelled wrong in thirty subtitles. Re-editing the SRT and re-parsing is annoying. SubtitleTextReplace is the search-and-replace node for the ComfyUI-Subtitle-Effects pipeline, and it's the closest thing the pack has to a free pass for sloppy transcripts.
It sits between your subtitle source and any effect node. Wire SUBTITLE_DATA in, get edited SUBTITLE_DATA out - nothing is touched in place, the node deep-copies the entries before it rewrites them, so your source stays pristine.
How it works
Think of it as a per-entry text filter. Every subtitle entry gets passed through your replace rule, then repacked into a fresh SUBTITLE_DATA with the same fps and source. That's the whole mechanism - no rendering, no frames touched, runs in milliseconds.
The two knobs that make it more than a dumb str.replace:
use_regex- when on, yourfindstring is treated as a regular expression and handed tore.sub. This is the one that saves you:\bComfyUI\binstead of hoping you caught every case, or^\s+to strip leading whitespace. If yourfindis plain text, leave it off - regex special characters like.will match too much if you don't expect them.remove_punctuation- strips every Unicode punctuation character (anything in the UnicodePcategory, so it catches full-width Chinese punctuation too). Great for the "clean up for a big bold title" pass, where you don't want,。!cluttering the frame.
One behavior worth knowing: after replacement, entries that end up with empty text get dropped and the rest are renumbered, so your subtitle indexes stay sequential instead of leaving holes. The preview output shows the edited entries in bracket format so you can check your work in a text node before committing pixels to it.
The inputs that matter
Required: subtitle_data (in), find, and replace_with. That's it. find empty means no replacement happens - so a node with nothing in find and remove_punctuation off is just a passthrough. The two booleans are optional and both default off.
Outputs: subtitle_data (the edited entries, ready for any effect node) and preview (a string you can display).
Install
Part of the ComfyUI-Subtitle-Effects pack:
cd ComfyUI/custom_nodes
git clone https://github.com/liaowu-boos/ComfyUI-Subtitle-Effects.git
cd ComfyUI-Subtitle-Effects
pip install "Pillow>=9.0.0" "jieba>=0.42"
Or install through ComfyUI Manager by searching liaowu-boos/ComfyUI-Subtitle-Effects, then restart ComfyUI. All nodes land under Subtitle Effects. No models to download, CPU-only, effectively free to run.
Common issues
remove_punctuationstrips more than you wanted. It's aggressive on purpose - it removes all punctuation, including apostrophes and periods inside English. Don't use it on subtitles wheredon'tneeds to staydon't.- Regex not matching. Remember it's
re.subsemantics:findis the pattern,replace_withis the replacement. If you're replacing literal dots or brackets, escape them or keepuse_regexoff. - Nothing changed. Check that the
SUBTITLE_DATAactually has entries - wire aSubtitleSource'spreviewinto a display node to confirm you're feeding it real data, because an empty source silently passes through.
It's a small utility, but it's the one you'll reach for every time a transcription comes back wrong - which, if you've used Whisper on real audio, is every time.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| subtitle_data | SUBTITLE_DATA | — | |
| find | STRING | — | |
| replace_with | STRING | — | |
| use_regexopt | BOOLEAN | false | — |
| remove_punctuationopt | BOOLEAN | false | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| subtitle_data | SUBTITLE_DATA | — |
| preview | STRING | — |