Nodes/IAMCCS-nodes/Wan Indexed Prompt Encode
ComfyUI Node

Wan Indexed Prompt Encode

One text box, a bank of prompts, and a loop counter picks which one wins

By IAMCCS·Created 11 months ago·Updated 8 days ago· 113
Wan Indexed Prompt Encode
  • clip
  • conditioning
  • selected_prompt
  • selected_index
  • prompt_count
  • report
  • total_generations
  • continuation_generations
  • total_frames
  • total_duration_s
text
segment_index0
index_offset0
selection_modedirect_index
phase1_last_segment0
phase2_last_segment1
separator_modeauto
fallback_moderepeat_last
first_visible_frames81
continuation_visible_frames81
fps16.00
bootstrap_outside_looptrue

Every long-video workflow eventually hits the same problem: you have a different prompt for every shot, and you need the right one to reach the text encoder at the right iteration. IAMCCS_WanIndexedPromptEncode ("Wan Indexed Prompt Encode") collapses that whole dance into one node. You type a bank of prompts in a multiline text box, feed a segment_index from your loop, and it picks the matching prompt, encodes it to conditioning, and hands back a stack of loop-metrics outputs for free.

How the selection works

The node splits text into a prompt bank (newline-separated by default; separator_mode also supports indexed, blank_line, and line formats). Then selection_mode decides how segment_index maps to a prompt:

  • direct_index - segment N uses prompt N. One-to-one, exactly what you expect.
  • three_phase - segments ≤ phase1_last_segment use prompt 0, through phase2_last_segment use prompt 1, and everything after uses prompt 2. Classic "establishing shot / action / payoff" structure without duplicating lines.
  • cyclic_3 - cycles through the first three prompts (seg % 3), useful for intercut scenes.
  • single - always prompt 0, for when you want a stable conditioning and no surprises.

When direct_index runs past the bank, fallback_mode decides: repeat_last (default), wrap, or empty. There's also index_offset to shift the whole mapping without touching the loop counter.

The free outputs

Beyond conditioning and selected_prompt/selected_index/prompt_count, the node computes your whole loop budget from first_visible_frames, continuation_visible_frames, and fps:

  • total_generations, continuation_generations - how many segments you'll render (with bootstrap_outside_loop on, the first segment counts as the bootstrap and every prompt after is a continuation).
  • total_frames, total_duration_s - the full runtime math. Wire these into a display and you know instantly whether a 10-shot sequence actually lands at your target duration.

The segment_index input is lazy, which is the quiet superpower: wired to a loop's iteration counter, it only re-evaluates when the index changes, breaking validation cycles instead of fighting them.

Install

Part of IAMCCS-nodes:

cd ComfyUI/custom_nodes
git clone https://github.com/IAMCCS/IAMCCS-nodes.git

or ComfyUI Manager → search "IAMCCS" → restart. No models, no pip extras. Compatibility floor: ComfyUI ≥ 0.3.0, Python ≥ 3.12, Torch ≥ 2.8.

Where people slip

The three_phase mode is the classic off-by-one trap - phase1_last_segment is inclusive, so a value of 2 means segments 0, 1, and 2 all use phase 1. Check selected_prompt in a preview node on your first few iterations and you'll catch it immediately. Also, fallback_mode = empty produces a blank conditioning rather than an error when you run out of prompts - if a chunk silently renders with no text, that's why.

CategoryIAMCCS/Wan

Inputs (13)

NameTypeDefaultDescription
clipCLIP
textSTRING
segment_indexINT00–100000
index_offsetINT0-100000–100000
selection_modeCOMBOdirect_index4 options: direct_index, three_phase, cyclic_3, single
phase1_last_segmentINT00–100000
phase2_last_segmentINT10–100000
separator_modeCOMBOauto4 options: auto, indexed, blank_line, line
fallback_modeCOMBOrepeat_last3 options: repeat_last, wrap, empty
first_visible_framesINT811–8192
continuation_visible_framesINT811–8192
fpsFLOAT16.000.001–240
bootstrap_outside_loopBOOLEANtrue

Outputs (9)

NameTypeDescription
conditioningCONDITIONING
selected_promptSTRING
selected_indexINT
prompt_countINT
reportSTRING
total_generationsINT
continuation_generationsINT
total_framesINT
total_duration_sFLOAT