Wan Indexed Prompt Encode
One text box, a bank of prompts, and a loop counter picks which one wins
- clip
- conditioning
- selected_prompt
- selected_index
- prompt_count
- report
- total_generations
- continuation_generations
- total_frames
- total_duration_s
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_segmentuse prompt 0, throughphase2_last_segmentuse 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 (withbootstrap_outside_loopon, 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.
Inputs (13)
| Name | Type | Default | Description |
|---|---|---|---|
| clip | CLIP | — | |
| text | STRING | — | |
| segment_index | INT | 00–100000 | — |
| index_offset | INT | 0-100000–100000 | — |
| selection_mode | COMBO | direct_index | 4 options: direct_index, three_phase, cyclic_3, single |
| phase1_last_segment | INT | 00–100000 | — |
| phase2_last_segment | INT | 10–100000 | — |
| separator_mode | COMBO | auto | 4 options: auto, indexed, blank_line, line |
| fallback_mode | COMBO | repeat_last | 3 options: repeat_last, wrap, empty |
| first_visible_frames | INT | 811–8192 | — |
| continuation_visible_frames | INT | 811–8192 | — |
| fps | FLOAT | 16.000.001–240 | — |
| bootstrap_outside_loop | BOOLEAN | true | — |
Outputs (9)
| Name | Type | Description |
|---|---|---|
| conditioning | CONDITIONING | — |
| selected_prompt | STRING | — |
| selected_index | INT | — |
| prompt_count | INT | — |
| report | STRING | — |
| total_generations | INT | — |
| continuation_generations | INT | — |
| total_frames | INT | — |
| total_duration_s | FLOAT | — |