Nodes/ComfyUI-Koolook/Clean Latent Slice (Koolook)
ComfyUI Node

Clean Latent Slice (Koolook)

Trimming LTX Director's Ghost Mask tail

By malkuthro·Created 11 months ago·Updated a day ago· 8
Clean Latent Slice (Koolook)
  • latent
  • latent
start0
length1

Clean Latent Slice does one thing: cut a video latent down to a specific temporal window. You use it because LTX Director's Ghost Mask reference feature secretly makes your clip longer than you asked for.

If you've used LTX Director - the community timeline node that makes LTX video behave like an editor - you know its Ghost Mask mode appends reference image(s) as guide frames at the end of the latent, after the clean video region. The model uses them to anchor identity (face shape, mouth shape) without the references showing up in the output. They're training wheels for the generation, not footage. But they still occupy frames, and if you don't cut them off you get a clip that's your shot plus a frozen reference frame glued to the back.

That's the whole job here. Wire the Director's clean_latent_frames output into length, set start to 0, and this node slices the latent back down to just the video. start=0 works because the refs live at the end. Feed the result into the sampler or video saver and you get exactly the frame count you wanted.

How it works

Under the hood it's a torch.narrow on the temporal axis - dimension 2 for the usual 5D [B, C, F, H, W] video latent, dimension 0 for anything else. The slice bounds get clamped to the tensor's actual size, so asking for more frames than exist won't crash, it just gives you what's there. It also trims a per-frame noise_mask if one is present, and leaves a broadcasted size-1 mask alone so it doesn't mangle the rest of your workflow.

One detail worth knowing: the narrow trick exists because PyTorch's NestedTensor (what Director can produce) doesn't slice like a normal tensor, and the approach is adapted from CGlide's CleanLatentSliceCS in the WhatDreamsCost-CSGlide repo. It's GPL-3.0 code, properly attributed. If you hit a latent type torch.narrow can't handle, the node falls back to a plain Python slice instead of erroring.

The inputs that matter

Only three, and honestly only two of them need your attention:

  • latent - the video latent from LTX Director's sampler.
  • start - first latent frame to keep. 0 for Ghost Mask, since the refs are appended at the end.
  • length - number of frames to keep. This is where you wire the Director's clean_latent_frames value.

Output is a single latent, same type in, same type out. Wire it straight into whatever saves or continues your video.

Install

It ships in the ComfyUI-Koolook pack. Easiest is ComfyUI Manager → Install Custom Nodes → install by Git URL:

https://github.com/malkuthro/ComfyUI-Koolook.git

Or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/malkuthro/ComfyUI-Koolook.git

Restart ComfyUI either way, and the node appears under Koolook/LTX. No model downloads, no extra Python dependencies - it's a couple of tensor ops. One gotcha: this pack's README is adamant about picking a single install method. If you already installed it via Manager it lives at custom_nodes/koolook/, and a second git clone to custom_nodes/ComfyUI-Koolook/ makes ComfyUI load both and quietly corrupt the workflow store on every restart. Pick one folder and stick with it.

Common issues

  • Clip comes out the wrong length - length doesn't match clean_latent_frames. Wire the Director output directly instead of typing a guess; the two stay in sync automatically.
  • A frozen frame at the end - the slice isn't running. Check start isn't clipping into the clean region. If you're somehow getting refs at the front, set start to skip them.
  • Nothing to do - if you're not using Ghost Mask, you don't need this node. It's a cleanup step for a specific Director feature, not a general-purpose trimmer.
CategoryKoolook/LTX

Inputs (3)

NameTypeDefaultDescription
latentLATENT
startINT00–100000First latent frame to keep. 0 for Ghost Mask (refs are at the end).
lengthINT11–100000Number of latent frames to keep. Wire the Director's 'clean_latent_frames'.

Outputs (1)

NameTypeDescription
latentLATENT