MiniMax H3 Temporal Trim / 时长裁剪
Shorten a MiniMax H3 clip without desyncing the audio
- latent
- LATENT
- frames
You generated a MiniMax H3 clip and it's too long. Trimming it sounds trivial until you remember that H3's latent is a paired video+audio NestedTensor - cut the video and leave the audio, and you've silently desynced the sound. Cut the video to a length that isn't on the model's frame grid, and you've handed the sampler a latent it wasn't trained to handle. Temporal Trim does the whole job in one node: shortens video and audio together, and snaps the result to H3's 17k+5 frame grid so it can't produce a mismatched pair.
What it does
One input, latent, plus a single setting: keep_seconds (default 5.0, range 0.2–20). It keeps that much from the start of the clip and drops the rest.
The details that keep it honest:
- It snaps up, not down. It aligns the requested duration to the same
17k+5grid the generation nodes use, so "5 seconds" here means the same 124 frames it means everywhere else in the pack. You never get a surprise frame count. - It can only shorten. If
keep_secondsis longer than what the source actually holds, it raises a clear error ("cannot extend… Trim only shortens") rather than silently padding or hallucinating. - It trims both streams to their matching lengths. Video to the new
latent_t, audio to the newaudio_t, so the pair stays coherent by construction.
Outputs are the trimmed LATENT and a frames integer if you want the count for downstream logic or a text readout.
Why you'd use it
The realistic workflow: you generated at, say, 15 seconds but only need the first five for a loop, a transition, or an edit. You could re-run the sampler with a shorter duration - but that costs a full generation, and you might want the exact frames you already have. Trimming the latent is nearly free and keeps everything else in the graph intact.
It also pairs with the pack's other AV-latent tools in that "generation-prep" slot: plan with Canvas Planner, validate with Prompt Lint, and trim any over-long latent before it goes to decode.
Install
Part of the MiniMax-H3 Tools pack, which needs ComfyUI 0.30.0+. Install via ComfyUI Manager by searching "MiniMax H3 Tools," or:
cd ComfyUI/custom_nodes
git clone https://github.com/Rinne414/ComfyUI-MiniMaxH3-Tools.git
Restart ComfyUI and it's under MiniMax H3. No extra Python dependencies, no model files. And the pack-wide note applies: stock SaveLatent/LoadLatent can't round-trip an H3 AV latent, so keep the trimmed result in the graph and don't try to persist it between runs.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| latent | LATENT | — | |
| keep_seconds | FLOAT | 5.00.2–20 | Duration to keep from the start, aligned to the frame grid. / 从开头保留的时长,并对齐到帧网格。 |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| LATENT | LATENT | — |
| frames | INT | — |