Nodes/IAMCCS-nodes/Latent Tail Slice ??
ComfyUI Node

Latent Tail Slice ??

Grab the last N latent frames for the next video segment

By IAMCCS·Created 11 months ago·Updated 8 days ago· 113
Latent Tail Slice ??
  • latent
  • latent
  • n_frames
n_frames2
from_endtrue

Every long video workflow eventually needs the same thing: the tail frames of the last segment, to feed as context for the next one. If you're working with WAN or LTX in native ComfyUI, those "last few frames" live inside a LATENT tensor, and getting them out is a slice you'd normally write in a custom node. IAMCCS LatentTailSlice is that slice, pre-built, with the author's docstring spelling out the two uses: "Extract prev_samples tail without saving to disk (in-workflow re-use)" and "trim a LATENT to a precise temporal window."

The key framing is "stateless utility." It doesn't save anything, it doesn't cache, it doesn't keep state between runs - it just cuts the tensor and hands it back. That's the right design for a node you'll drop into a video loop.

How it works

The latent is a [B, C, T, H, W] tensor, and the node slices along the T (time) axis. Two controls:

  • n_frames (1–64) - how many latent frames to extract.
  • from_end - the tooltip is the complete manual: True → slice the last N frames (the tail, for prev_samples); False → slice the first N frames (the head, for anchor context).

So for a WAN continuation graph you set from_end = True and pull, say, 2–4 latent frames off the end of your previous segment's prev_samples. That tail becomes the context that keeps the next segment consistent.

Outputs: latent (the sliced LATENT) and n_frames (the number you actually extracted, clamped to what the input contained - the node won't try to slice more frames than exist).

Why this beats the alternatives

Saving decoded frames to disk and re-encoding them is the heavy way to do continuation - it costs VAE time and introduces encode/decode drift. Slicing the latent in place is cheaper and lossless. The author added this to the WAN category precisely because the WANAnimate/prev_samples flow (which this whole pack exists to fix) keeps wanting exact latent windows.

Install

It's in IAMCCS-nodes:

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

or ComfyUI Manager → search IAMCCS, restart. No dependencies, no models.

The one thing to remember

Latent frames aren't pixel frames. The time dimension is downsampled by the VAE (commonly 8x for these models), so "2 latent frames" ≈ 16 pixels frames of video. Match n_frames to your VAE's time scale or your overlap math will be off by a factor of eight - which is also why several LTX-2 nodes in this pack take overlap in pixel frames and convert internally.

CategoryIAMCCS/Wan

Inputs (3)

NameTypeDefaultDescription
latentLATENT
n_framesINT21–64Number of latent frames to extract.
from_endBOOLEANtrueTrue → slice last N frames (tail, for prev_samples). False → slice first N frames (head, for anchor context).

Outputs (2)

NameTypeDescription
latentLATENT
n_framesINT