Trim Video Latent
Cut frames off the front of a video latent — count in latent frames, not pixels
- samples
- LATENT
Video latents carry their own length, and a lot of workflows pad that length before sampling - a reference image becomes a few extra latent frames at the front, a shorter clip gets extended to a target frame count, an extension pass bakes its conditioning into the start. Trim Video Latent exists to take those extra frames back off. It drops the first trim_amount frames from the temporal axis of a latent and hands you the trimmed result. Nothing else changes: no re-encode, no interpolation, no fancy math. Just a slice.
Where it shows up
You'll meet it most often in Wan extension and video-to-video graphs, which is why it lives in the same source file as the Wan nodes. The pattern: generate or condition a clip, then trim the leading frames that were only there to anchor the generation before you decode to pixels. It also pairs naturally with WanVideoToVideo, which returns a trim_latent value telling you how many conditioning frames were prepended - that number is exactly what you feed into this node.
The gotcha that catches everyone
trim_amount counts latent frames, not pixel frames. Video VAEs compress time by a factor (Wan compresses ~4×), so a latent's temporal axis is roughly a quarter the length of the final clip. The node slices samples[:, :, trim_amount:] directly on the latent - it never sees pixels. If you think you're trimming 16 video frames but you're actually trimming 16 latent frames, you've cut about 4× more than you intended.
The arithmetic is worth remembering: for Wan, N pixel frames = ((N - 1) // 4) + 1 latent frames. Trim in latent units, or divide your pixel count by the VAE's temporal compression and round to match.
Inputs and outputs
- samples (LATENT) - the video latent to trim.
- trim_amount (INT, 0–99999, default 0) - how many latent frames to drop from the front. 0 is a no-op that returns the input untouched.
Output: one LATENT, same everything except a shorter temporal axis.
How you get it
Ships with ComfyUI core - no install. It's been around since the Wan support era (2024), so any current ComfyUI has it.
Common mistakes
Trimming from the wrong end: this node only removes the start of the clip. There's no mode for cutting the tail - if you want to shorten the end, you're looking at a different approach (regenerate at the right length, or crop in pixel space after decode).
Trimming too far: slice past the available frames and you get an empty or near-empty latent, which will fail or produce a blank clip downstream. Keep trim_amount well under the latent's total length.
And the classic self-inflicted wound: trimming a latent that has no conditioning frames at all, "just to be safe." You've now chopped real content off your video. Only trim when you know frames were added - the Wan trim_latent output is the honest source of that number, so use it rather than guessing.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| samples | LATENT | — | |
| trim_amount | INT | 00–99999 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| LATENT | LATENT | — |