ComfyUI Node

text_Splitter

Cut a script into shots and index into it for prompt scheduling

By cardenluo·Created 2 years ago·Updated 21 days ago· 309
text_Splitter
    • 调度输出
    • 拆分列表
    • 列表
    text_input
    split_rule按行分割
    custom_separator
    current_frame0

    If you're driving a video workflow where the prompt needs to change shot by shot or frame-by-frame - the kind of thing Apt_Preset's own README describes under its "prompt scheduling" features for AnimateDiff-style Controller Stacks - you first need a way to break one big block of text into the individual pieces a scheduler can step through. text_Splitter is that tool: split a multi-shot script by whichever rule fits how you wrote it, then either pull out one piece at a time or hand the whole set downstream as a list.

    Twelve split rules, covering the practical ways people actually structure this kind of text: no splitting at all, a custom regex you supply yourself, by line, by blank line (the natural choice if you wrote one shot per paragraph, separated by a blank line between them), by space, by comma, by period, by semicolon, by tab, by the | pipe character, by ordinal numbering (recognizing patterns like 1., A., or (1) at the start of each entry), and by markdown-style headings or chapter markers. custom_separator is only used when split_rule is set to the custom-regex option, letting you define your own boundary pattern for text that doesn't fit any of the built-in rules.

    current_frame is where this becomes a scheduling tool rather than a plain splitter - it's an integer index (with an enormous max, effectively unbounded) that selects which split segment gets returned as the "current" one. Wire a frame counter or a loop index into this from elsewhere in your workflow, and the node hands back the shot or paragraph that corresponds to that position, letting your prompt actually change as your video progresses instead of staying static for the whole generation.

    Three outputs, covering both use cases. The first output ("scheduling output," a STRING) is the single segment selected by current_frame - the piece you'd feed into a per-frame or per-shot conditioning node. The second ("split list," a LIST) is the full set of split pieces as ComfyUI's native list type, if you want to hand the whole thing to a downstream node rather than stepping through it one at a time. The third ("list," a wildcard * output marked is_list: true) is effectively the same split content again, exposed in the form ComfyUI's execution engine will auto-loop over - useful if you want a node further down the chain to run once per segment automatically rather than you managing the indexing yourself via current_frame.

    Installing it. Standard for the whole pack - search "ComfyUI-Apt_Preset" in ComfyUI Manager, or clone directly:

    cd ComfyUI/custom_nodes
    git clone https://github.com/cardenluo/ComfyUI-Apt_Preset.git
    

    Run install.bat on Windows for dependencies, then restart ComfyUI. Pure text processing - no models, no GPU dependency - so it should work as soon as the pack loads cleanly.

    Troubleshooting. If your text isn't splitting where you expect, the most common cause is picking a rule that doesn't actually match how you formatted the source - "by blank line" needs an actual empty line between segments, not just a line break, so single-newline-separated shots will come through as one block under that rule; switch to "by line" instead if that's your format. If you're using the custom-regex option and getting unexpected splits, remember custom_separator is treated as a regex pattern, so characters with special regex meaning (., (, ), |) need escaping if you actually want them matched literally. And if text_Splitter isn't present in your install at all, that's most likely the documented pack-wide IMPORT FAILED issue tied to a missing dependency elsewhere in Apt_Preset - check your ComfyUI console log at startup and reinstall via Manager's "install missing custom nodes" rather than assuming this specific node is the problem.

    CategoryApt_Preset/prompt

    Inputs (4)

    NameTypeDefaultDescription
    text_inputSTRING
    split_ruleCOMBO按行分割12 options: 不分割, 自定义正则, 按行分割, 按空行分割, 按空格分割, 按逗号分割, +6
    custom_separatorSTRING
    current_frameINT00–18446744073709550000

    Outputs (3)

    NameTypeDescription
    调度输出STRING
    拆分列表LIST
    列表*