Nodes/ComfyUI-MiniMaxH3-Contex-Loop/MiniMax H3 Masking · Trim Source AV
ComfyUI Node

MiniMax H3 Masking · Trim Source AV

Clip source footage to a length H3 can actually eat

By ethanfel·Created 17 days ago·Updated about 20 hours ago· 315
MiniMax H3 Masking · Trim Source AV
  • frames
  • audio
  • trimmed_frames
  • trimmed_audio
  • h3_length
  • trim_info

H3 doesn't accept just any clip length. Its frame count has to satisfy length % 17 == 5 - valid runs like 5, 22, 39, 56, up to hundreds of frames - and if your source video is 143 frames you're stuck with a length that isn't valid. This tiny node fixes that by trimming your footage down to the largest valid H3 length, dropping trailing frames instead of padding or inventing any. It's a boring utility, and that's exactly why you want it: it removes a whole class of "why does my source refuse to load" errors.

What it does

Feed it frames (an IMAGE batch) and optionally the audio that belongs to it. It computes the largest valid 17k+5 frame count that fits inside your source, trims the video to that, and trims the audio to the matching duration at 24 fps so sound stays locked to picture. Frames are never resized or padded - if your source is 143 frames you get 124 back, not 143 with filler.

Outputs are the trimmed_frames, the trimmed_audio (an empty output if no audio was connected), h3_length with the exact valid count, and a human-readable trim_info string. That h3_length is the number to feed anywhere the workflow wants a raw H3 length.

It's a genuinely thin node. You'd typically put it right after loading source footage and before it hits the chain's masked AV or source-timeline path, so everything downstream sees a length H3 will accept.

Install and gotchas

Same pack install as the rest:

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

Restart ComfyUI, or install via ComfyUI Manager under "MiniMax H3 Contex Loop". No extra pip dependencies; bring your own H3 weights (check the MiniMax H3 Community License - local weights are restricted in the US/EU/UK/Korea), and a current ComfyUI with native Add Guide support (PR #15439) helps.

Two things to keep in mind. First, this trims - if your footage is shorter than any valid run (under 5 frames), there's nothing it can return, so don't use it as a fix for too-short material. Second, the audio trim assumes 24 fps, which is H3's timeline; if your source is a different frame rate, resample it to 24 before connecting, or the audio duration won't match the picture.

Categoryconditioning/minimax/contex_loop/masking

Inputs (2)

NameTypeDefaultDescription
framesIMAGESource video frames. Trailing frames are dropped to the largest valid H3 17k+5 length; frames are never padded or resized.
audiooptAUDIOOptional synchronized source audio, trimmed to the returned frame duration at 24 fps.

Outputs (4)

NameTypeDescription
trimmed_framesIMAGESource frames trimmed to the largest valid H3 17k+5 length.
trimmed_audioAUDIOSynchronized audio trimmed to the returned frame duration, or an empty output when no audio was connected.
h3_lengthINTThe valid H3 frame count represented by both returned streams.
trim_infoSTRINGHuman-readable summary of the frame and audio trimming performed.