Nodes/TKNodes/Trim Padding used for Smooth Transition
ComfyUI Node

Trim Padding used for Smooth Transition

Strip the crossfade padding back off your video chunks

By trashkollector·Created about a year ago·Updated a day ago· 1
Trim Padding used for Smooth Transition
  • image
  • image
idx0
total_segments1
start_frames12
end_frames13

Smooth transitions between generated video chunks require a dirty secret: you have to render more than you keep. To crossfade chunk A into chunk B you pad the tail of A and the head of B with overlapping frames, blend them, then cut the padding away. TKTrimImageOverlap is the "cut the padding away" step - and unlike a plain trim node, it knows that the first and last segments of your video are special cases.

The node's full description is "Trim Padding used for Smooth Transition," and it's designed to run inside the pack's chunking loop, right before you stitch segments together. If you've ever hand-coded this logic into a workflow with a couple of math nodes, you know how easy it is to get the first and last chunk wrong. This node exists so you don't have to.

How it works

The trick is that overlap padding is shared between neighbors. Segment 1's tail overlap is what blends into segment 2's head - so:

  • First segment (idx == 0): trim only the end
  • Middle segments: trim both start and end
  • Last segment (idx == total_segments - 1): trim only the start

The node figures all of that out from two numbers you already have in your loop - idx (the current chunk's index, 0-based) and total_segments - so you feed the same values to every iteration and it applies the right rule automatically. That's the whole reason this node exists instead of just slicing frames yourself: the boundary logic is baked in, and there's a safety clamp so you can't accidentally trim a chunk down to an empty batch.

The inputs that matter

Four, and they're all self-explanatory once you know the pattern. image is the chunk's frame batch, padded and all. idx is the current loop index ("Index for audio chunks" per the tooltip). total_segments is how many chunks the whole video has ("total audio chunks"). And the two you'll actually tune: start_frames (default 12) and end_frames (default 13) - how many frames of padding to remove from each side.

Those defaults aren't random. They roughly match the overlap the pack's own LTX chunker pads onto chunks, sized to the model's temporal compression. If you're using a different chunker, set these to whatever overlap it added - trimming the wrong number of frames leaves a visible jump or a duplicated half-second.

Outputs

One: the trimmed image batch, ready to be fused or stitched. There's no audio output here - this node is purely visual. If your audio carries the same overlap, cut it with TKTrimAudioWithBooleans or let the audio path of the pipeline handle it.

Install

Part of the TKNodes pack, so the usual drill: ComfyUI Manager, search "Handy Nodes", install, restart. Or clone it by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/trashkollector/TKNodes

Restart ComfyUI. No models, no downloads, no config - it's tensor slicing with a position-aware brain. One honest caveat: the node trusts that you know your own padding scheme. Feed it a chunk that wasn't padded and it'll happily slice real frames off the ends. Know what your chunker added before you wire this up.

CategoryTKNodes/video

Inputs (5)

NameTypeDefaultDescription
imageIMAGEsource image with padding
idxINT00–9999Index for audio chunks
total_segmentsINT11–9999total audio chunks
start_framesINT120–9999start frame to remove
end_framesINT130–9999end framess to remove

Outputs (1)

NameTypeDescription
imageIMAGE