Nodes/H3 Relay/H3RelayInternalLoopTrim
ComfyUI Node

H3RelayInternalLoopTrim

The node that keeps your audio on the beat after H3 continuation

By akatz-ai·Created 28 days ago·Updated 8 days ago· 15
H3RelayInternalLoopTrim
  • images
  • audio
  • images
  • audio
  • images_with_overlap
  • overlap_frames
trim_frames0
fps24.000
match_tailtrue
retain_overlap_frames0

Every H3 continuation shot carries a pinned prefix of frames repeated from the previous shot - that's how the model keeps continuity. Those frames have to come off before you concatenate shots, or you get a choppy, overlapping timeline. Trim only the images, though, and you've created a subtler bug: the audio is now a full trim_frames/24 seconds ahead of the picture. At five frames that's about 208ms - silent on ambience, squarely offbeat on anything with a pulse.

Loop Trim is the node that removes the same span from both streams. The description says it flatly: Remove the leading pinned frames from a decoded H3 clip, trimming picture and sound by the same duration. It's the continuation-loop counterpart to Chain Context - which is why both live in the same conditioning/minimax/contex_loop category, and why the tooltip on trim_frames tells you to wire it from the context node.

The inputs

  • images - decoded images from the current H3 sample; the leading pinned overlap is removed.
  • trim_frames - connect from Chain Context's trim_frames output. In head mode that's the repeated overlap; before mode supplies 0.
  • audio (optional) - decoded audio for the same clip, trimmed by the matching duration. Leave unwired for silent clips.
  • fps (default 24) - used to convert the trim into an audio duration. Must match what you feed Create Video.
  • match_tail (default true) - truncate or zero-pad audio so its duration equals frames/fps exactly. This exists because H3's audio latent runs at 40 Hz against 24fps picture, and ComfyUI rounds the required audio steps to the nearest integer - so some valid H3 lengths decode ~8.3ms long and others ~8.3ms short. That tiny error accumulates down a chain, and match_tail kills it at the source.
  • retain_overlap_frames (default 0) - if you're handing frames to an external stitcher, a positive value makes the extra images_with_overlap output retain up to that many final repeated context frames. Audio always removes the complete overlap.

The outputs

  • images - delivered frames with the repeated leading context removed. This is your clean clip.
  • audio - trimmed by the same duration and, with match_tail on, fitted exactly to the delivered image duration.
  • images_with_overlap - the blend-ready stream (only meaningful when retain_overlap_frames > 0).
  • overlap_frames - the count of repeated leading frames retained in images_with_overlap; use it as the overlap count in a compatible stitcher.

When you'll meet it

This is an internal node, so in the reference graph it appears wired automatically. The reason it's worth reading about is the failure mode it prevents: if you hand-trim images and leave audio alone, the drift is invisible until a music-video-style edit makes it obvious. If you're building your own continuation chain, this is the node that keeps picture and sound locked together, and match_tail is the setting you want on unless you have a specific reason to turn it off.

Install the pack via ComfyUI Manager (H3 Relay) or git clone https://github.com/akatz-ai/h3-relay.git into custom_nodes. Needs ComfyUI 0.32.0+, FFmpeg, and the H3 files from MODELS.md. The MiniMax H3 community license excludes US/EU/UK/Korea - check it before downloading weights.

Categoryconditioning/minimax/contex_loop

Inputs (6)

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_tailoptBOOLEANtrueTruncate or zero-pad audio so its duration equals frames/fps exactly. H3 rounds its 40 Hz audio grid to the nearest step, producing about 8ms of excess or shortage on some lengths.
retain_overlap_framesoptINT00–4096Optional visual-only overlap for an external stitcher. 0 keeps the normal hard-trim output only. A positive value makes the extra image output retain up to that many of the final repeated context frames. Audio always removes the complete overlap.

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.
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.