Files
TuonoMindCode-ComfyUI-Multi…/readme.md
T
2025-12-06 15:16:30 +01:00

7.6 KiB
Raw Blame History

ComfyUI Multi-Clip Text Script Nodes

Multi-Clip Text Script - Main overview

How to use it (visual)

Step 1 - Configure Main node Step 2 - Author script with clips
Step 3 - Select clip and format Step 4 - Connect to encoder and render

This ComfyUI node was created while I was making Wan 2.2 videos with 81 frames and crossfading them together. I found myself dragging and clicking through different parts of the workflow to change clip text prompts, so I wanted a faster, centralized place to edit all prompts.

This node was generated with ChatGPT 5.1, and this README was also written by ChatGPT.

Two simple nodes that help you author sequence-friendly prompts from a single script that contains multiple clips. You write one text block with (clip01), (clip02), … sections, then select one clip at a time to produce a clean prompt (with shared prefix/suffix and negative prompt).

Nodes

  • Multi-Clip Text Script: Main
  • Multi-Clip Text Script: Clip Selector

Category

  • Text / Multi-Clip

File

  • sequence_prompt_nodes.py

Why this exists

  • Keep consistent prompt parts across many shots (prefix/suffix/negative) while varying per-clip action text.
  • Author all clips once, then iterate and render per-clip without copy/paste.
  • Optional auto formatting to output a classic “prefix, clip, suffix.” prompt line.

Installation

  • Go to your ComfyUI/custom_nodes folder.

Clona the repo (exempel):

cd ComfyUI/custom_nodes git clone https://github.com/TuonoMindCode/ComfyUI-MultiClip-Text-Script.git

or

Copy sequence_prompt_nodes.py and __init__.py into your ComfyUI/custom_nodes/ComfyUI-MultiClip-Text-Script. Restart ComfyUI. Search for:

  • “Multi-Clip Text Script: Main”
  • “Multi-Clip Text Script: Clip Selector”

Script format

The Main node parses a single multiline script using labeled sections:

  • Label each section with (clipXX) where XX is a number (1-based).
  • Case-insensitive. Any number of digits is supported.
  • Text for a clip runs until the next (clipYY) or the end of the script.

Example script

(clip01) woman walks forward and waves to the camera

(clip02) woman walks forward and gets angry

(clip03) woman throws the phone

Clips are sorted numerically by their label: (clip1), (clip02), (clip10) → 1, 2, 10.

Node: Multi-Clip Text Script: Main

Purpose

  • Parse the multi-clip script, store prefix/suffix and per-clip texts in an internal string (MULTICLIP_PAIR_DATA).
  • Provide total clip count and a shared negative prompt for downstream nodes.

Inputs (required)

  • prefix_text (STRING, multiline): Common description always included (subject, style, tempo, etc.).
  • multi_clip_script (STRING, multiline): Your script with (clipXX) sections.
  • suffix_text (STRING, multiline): Appended after every clip (camera style, quality, etc.).

Inputs (optional)

  • negative_text (STRING, multiline): One negative prompt used for every clip.

Outputs

  • pair_data (MULTICLIP_PAIR_DATA): Internal encoded data with prefix, suffix, and all clips.
  • num_clips (INT): Number of parsed clips.
  • multi_clip_negative (MULTICLIP_NEGATIVE): The shared negative prompt.

Details

  • If no clips are found, pair_data still contains prefix and suffix. num_clips is 0.
  • Leading/trailing whitespace is trimmed from all pieces.

Node: Multi-Clip Text Script: Clip Selector

Purpose

  • Select one clip (1-based index) from pair_data and build the final prompt text.

Inputs (required)

  • pair_data (MULTICLIP_PAIR_DATA): Output from Main.
  • clip_number (INT): 1-based index of the clip to use.

Inputs (optional)

  • auto_format (BOOLEAN):
    • False: Join with blank lines: prefix + blank + clip + blank + suffix.
    • True: Produce “prefix, clip, suffix.” and clean trailing commas/semicolons/spaces.
  • log_to_console (BOOLEAN): Print the combined prompt for debugging.
  • negative (MULTICLIP_NEGATIVE): Connect from Main’s multi_clip_negative to pass the shared negative forward.

Outputs

  • clip_text (STRING): The final prompt for the selected clip.
  • negative_text (STRING): The negative prompt passthrough (if provided).

Behavior notes

  • Out-of-range clip_number is clamped to the valid range.
  • If pair_data had no clips, the output becomes a combination of prefix/suffix only.
  • Cleaning rules used by auto_format remove trailing commas, semicolons, and spaces on each piece before joining. The final text gets a period if it ends without punctuation.

Quick example

Inputs to Main

  • prefix_text: “cinematic, natural light, handheld”
  • multi_clip_script:
    (clip01)
    woman walks forward and waves to the camera
    
    (clip02)
    woman walks forward and gets angry
    
    (clip03)
    woman throws the phone
    
  • suffix_text: “soft bokeh, film grain”
  • negative_text: “low quality, blurry, artifacts”

Main outputs

  • pair_data → connect to Clip Selector
  • num_clips → e.g., 3
  • multi_clip_negative → connect to Clip Selector’s negative

Clip Selector

  • clip_number: 2
  • auto_format: False → Output:
    cinematic, natural light, handheld
    
    woman walks forward and gets angry
    
    soft bokeh, film grain
    
  • auto_format: True → Output:
    cinematic, natural light, handheld, woman walks forward and gets angry, soft bokeh, film grain.
    
  • negative_text: “low quality, blurry, artifacts”

Typical workflow

  • Multi-Clip Text Script: Main
    • pair_data → Multi-Clip Text Script: Clip Selector.pair_data
    • multi_clip_negative → Multi-Clip Text Script: Clip Selector.negative
  • Multi-Clip Text Script: Clip Selector
    • clip_text → your text encoder’s positive prompt input
    • negative_text → your text encoder’s negative prompt input
  • Render per-clip by changing clip_number or automating it in a loop.

Internal encoding (for reference)

  • pair_data is a single string combining:
    • prefix
    • suffix
    • all clip texts, in order
  • Separators (do not type these yourself; they are inserted by the node):
    • META_SEP = “\n<<<MULTICLIP_META_SEP>>>\n”
    • CLIP_SEP = “\n<<<MULTICLIP_CLIP_SEP>>>\n”
  • Layout:
    • prefix + META_SEP + suffix + META_SEP + (clip1 + CLIP_SEP + clip2 + CLIP_SEP + …)

Tips

  • Use auto_format = True for a compact, comma-separated prompt line.
  • Keep prefix/suffix relatively short to avoid overly long prompts when combined.
  • Enable log_to_console to debug the exact text sent to your text encoder.
  • If no (clipXX) sections are detected, num_clips = 0; you can still use prefix/suffix.

Troubleshooting

  • No clips detected
    • Ensure each section starts with (clip01), (clip02), … on its own line or followed by whitespace.
    • Labels are case-insensitive but must follow the (clip) pattern.
  • Wrong clip selected
    • clip_number is 1-based. 1 = first clip.
    • Values out of range are clamped to the nearest valid index.
  • Extra punctuation
    • Use auto_format = True to remove trailing commas/semicolons/spaces from each part before joining.

Development notes

  • Node classes:
    • MultiClipTextScriptMain
    • MultiClipTextScriptClipSelector
  • Display names:
    • “Multi-Clip Text Script: Main”
    • “Multi-Clip Text Script: Clip Selector”
  • Category: “Text / Multi-Clip”
  • Regex used to parse clips:
    • (clip(\d+)) followed by text until the next (clipN) or end of string.
    • DOTALL and IGNORECASE enabled.
  • Sorting:
    • Clips are sorted numerically by the parsed number part (e.g., clip02 → 2).