Nodes/ComfyUI-MiniMaxH3-Contex-Loop/MiniMax H3 Contex Loop Trim
ComfyUI Node

MiniMax H3 Contex Loop Trim

Cut the pinned frames off H3 output, picture and sound together

By ethanfel·Created 17 days ago·Updated about 19 hours ago· 315
MiniMax H3 Contex Loop Trim
  • images
  • audio
  • state
  • images
  • audio
  • images_with_overlap
  • overlap_frames
trim_frames0
fps24.000
match_tailtrue
retain_overlap_frames0

Every H3 chain scene comes out with a pinned overlap at the head - repeated context frames that have to come off before you concatenate scenes. Trim only the images and you've just shoved the soundtrack ahead of the picture by the same span: at 5 frames that's 208ms, inaudible on ambience but squarely offbeat on anything with a pulse. This node removes the leading pinned frames from both picture and sound so the clip is actually usable, and in 0.5 chains it resolves the per-scene blend from state instead of making you wire a constant.

What it does

Feed it the decoded images from the current H3 sample and a trim_frames count - normally the trim_frames output of MiniMax H3 Contex Loop Context, which knows what the encoder actually produced. Connect audio if the clip has sound; it gets trimmed by the matching duration. The fps (default 24) converts the frame trim into an audio duration and must match what you feed Create Video.

Outputs:

  • images - the delivered frames with the repeated leading context removed.
  • audio - trimmed by the same duration. With match_tail on (the default), it also time-conforms small H3 audio-grid mismatches so duration equals frames/fps exactly - H3's rounded 40 Hz audio grid runs about 8ms off picture, and that error accumulates down a long chain.
  • images_with_overlap + overlap_frames - an optional blend-ready stream retaining only the final part of the repeated visual context, for external stitchers that need an overlap count.

In a 0.5 chain, the recommended wiring is to connect Current Shot's state output into state. Then the node reads the active scene's resolved blend directly from the Plan, so a per-scene value can never be overridden by a Plan default. When state is connected, the retain_overlap_frames integer is ignored (it's the legacy manual path for external stitchers).

Install and gotchas

cd ComfyUI/custom_nodes
git clone https://github.com/ethanfel/ComfyUI-MiniMaxH3-Contex-Loop.git

Restart, or install via ComfyUI Manager under "MiniMax H3 Contex Loop". No pip step; a current ComfyUI with native Add Guide (PR #15439) is expected, and ffmpeg on PATH is preferred. Models aren't bundled - mind the MiniMax H3 Community License territory restriction.

The classic mistake is trimming images only and letting the audio run long, which is exactly the desync this node prevents - so don't bypass it with a plain image slice. And if your audio drifts later in the chain, check match_tail; it's the fix for H3's ~8ms grid rounding, not a band-aid on your mux settings.

Categoryconditioning/minimax/contex_loop

Inputs (7)

NameTypeDefaultDescription
imagesIMAGEDecoded images from the CURRENT H3 sample. The leading pinned overlap is removed.
trim_framesINT00–4096Connect trim_frames from MiniMax H3 Contex Loop Context. In head mode this removes the repeated overlap; before mode supplies 0.
audiooptAUDIODecoded audio for the same clip. Trimmed by the matching duration so sound stays locked to picture. Leave unwired for silent clips.
fpsoptFLOAT24.0001–240Frame rate used to convert the trim into an audio duration. Must match what you feed Create Video.
match_tailoptBOOLEANtrueTime-conform small H3 audio-grid mismatches so duration equals frames/fps exactly without a silence tail. H3's rounded 40 Hz grid can differ from picture duration by about 8ms.
retain_overlap_framesoptINT00–4096Legacy/manual visual overlap for an external stitcher. In a 0.5 chain, connect Current Shot's state output below and this integer is ignored; Loop Trim then resolves the exact per-scene blend from the Plan automatically.
stateoptH3_CHAIN_STATERecommended 0.5 chain route: connect Current Shot's state output. Loop Trim reads the active scene's resolved blend directly, so a Plan default can never override a per-scene value.

Outputs (4)

NameTypeDescription
imagesIMAGEDelivered frames with the repeated leading context removed.
audioAUDIOAudio trimmed by the same duration and, when match_tail is enabled, fitted exactly to the delivered image duration. The same AUDIO value privately carries the full decoded overlap to Segment Save so AV audio feathers survive final assembly; no extra wire is needed.
images_with_overlapIMAGEOptional blend-ready image stream. When overlap_frames is positive, this retains only the final requested part of the repeated visual context before the delivered frames. Audio remains fully trimmed.
overlap_framesINTNumber of repeated leading frames retained in images_with_overlap. Use as an overlap count in a compatible video stitcher.