Nodes/IAMCCS-nodes/IAMCCS WAN Prev Samples Loop Select
ComfyUI Node

IAMCCS WAN Prev Samples Loop Select

Start fresh, or keep rolling from the last chunk?

By IAMCCS·Created 11 months ago·Updated 8 days ago· 113
IAMCCS WAN Prev Samples Loop Select
  • anchor_samples
  • previous_samples
  • prev_samples
  • using_loop_state
  • report
loop_index0

Multi-chunk Wan video has one recurring decision: for this chunk, do we start from the reference image again, or do we continue from where the previous chunk's generation left off? IAMCCS WAN Prev Samples Loop Select is a one-line answer to that question, and it's the difference between a video that flows and a video that visibly jumps back to the anchor on every cut.

What it does

Inputs:

  • anchor_samples - a LATENT, your start/reference image (or image stack) encoded to latent.
  • loop_index - the current iteration number.
  • previous_samples (optional) - the latents from the previous chunk's sampler output.

The logic is deliberately simple: on iteration 0 it routes anchor_samples through as prev_samples, because there's no previous generation yet. From iteration 1 on, if previous_samples is actually connected and valid, it routes that through instead. If you're on iteration 5 but nothing is wired into previous_samples, it falls back to the anchor rather than erroring.

Outputs:

  • prev_samples - the LATENT to feed into your motion/continuity node.
  • using_loop_state - a BOOLEAN saying which branch it took (true = using previous generation, false = using anchor). Wire this to a switch or just read it from the report.
  • report - a small JSON with the loop index, which branch, and the latent shape it passed along.

How it works

That's the whole mechanism - a conditional router. The cleverness is in the fallback: a lot of ComfyUI switch nodes die with a validation error when an input is missing, and this one silently degrades to the anchor. For first chunk of a board, that's exactly the behavior you want.

Where it fits

In the shotboard loop, it sits right after Chunk Select and before your motion node. The prev_samples output feeds WanImageMotionPro's prev_samples input, and the anchor it hands through on iteration 0 lines up with lock_start_slots on the motion node so the first chunk is properly start-anchored. Using it means you don't have to hand-wire "which latent is the predecessor" logic yourself on every loop you build.

Installing it

Part of IAMCCS-nodes. ComfyUI Manager (search "IAMCCS"), or:

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

Restart after. No model files, no extra dependencies.

Common issues

The usual mistake is feeding it the previous chunk's decoded images instead of its latents. This node wants the raw LATENT - decoded pixels won't round-trip through VAE encode without quality loss and shape surprises. And if your continuation keeps snapping to the anchor on later iterations, check that previous_samples is actually connected; the fallback to anchor is silent by design, so the report is the place to look.

CategoryIAMCCS/Wan/PURE/Loop

Inputs (3)

NameTypeDefaultDescription
anchor_samplesLATENT
loop_indexINT00–100000
previous_samplesoptLATENT

Outputs (3)

NameTypeDescription
prev_samplesLATENT
using_loop_stateBOOLEAN
reportSTRING