Nodes/ComfyUI-MiniMaxH3-PrefixStream/MiniMax H3 Long Video Stitcher (AV Seamless)
ComfyUI Node

MiniMax H3 Long Video Stitcher (AV Seamless)

The node that makes clip 4 not look like a different film

By knoic·Created 4 days ago·Updated a day ago· 2
MiniMax H3 Long Video Stitcher (AV Seamless)
  • prev_images
  • curr_images
  • prev_audio
  • curr_audio
  • session
  • cache_config
  • stitched_images
  • stitched_audio
  • total_frames
trim_frames0
crossfade_frames4
luminance_matchtrue
luminance_fade_frames16
crossfade_ms15
fps24.00

Why the last 20% of this node is the node

MiniMax H3 tops out at short clips and generates audio together with the picture, not as a separate pass. So a "long video" is always several generations glued end to end, each one continuing from the tail of the last. The chaining part is a solved pattern by now; the same assembly loop shows up across the Wan projects and SCAIL-2 Infinity.

What is not solved by simply concatenating image batches is the join. Every generation has its own idea of global exposure, so clip 2 arrives a few percent brighter than clip 1 and the cut flashes. Every generation's audio starts at its own phase, so a naive splice produces the click you hear on cheap edits. And if you trim the overlapping frames with the wrong tool you either double the motion or desync the sound by a frame.

This node is the one that handles all three at once: trim, brightness match, and an audio-safe crossfade, all in pixel and waveform space. It's the pack's seam-polisher, and it's the reason segmented H3 output can pass as a single take.

How it works

It keeps both streams as decoded data - no VAE round trip at the seam, because re-encoding through a VAE is where causal flicker and colour drift sneak in.

For the audio it's sample-accurate: it converts the trim count to samples (trim_frames / fps × sample_rate), slices the head off the new clip, fits the remaining waveform to the exact expected length, and joins to the previous waveform with a short equal-power linear crossfade at the seam - crossfade_ms, default 15ms. That's the anti-click.

For the picture it does more work than you'd expect. It measures relative luminance (proper Rec.709 weights) on the overlapping frames, at a 4× pixel subsample, ignoring near-black and near-white pixels, takes the median ratio, and clamps the resulting gain to ±10%. Then it applies that gain with a cosine-shaped fade so the correction is strong at the seam and relaxes back to the clip's native brightness over luminance_fade_frames - no tinted clips. Finally it blends the overlapping tail and head with a cosine S-curve (0.5 - 0.5·cos(πt)) over crossfade_frames, then concatenates the rest.

One detail from the source rather than the README: the crossfade length is capped at however many frames are actually in the overlap, so an ambitious crossfade_frames collapses to a plain hard cut.

The inputs that matter

trim_frames is the one to understand. It's the number of leading frames to drop from the incoming clip - the overlap that was generated twice. Leave it at 0 and the node resolves it for you: from the connected session's rolling context, or from cache_config. There's a nice safety in there too: if the clip was already trimmed upstream by MiniMax Trim Prefix, the session records that and the stitcher skips its own trim rather than eating a second chunk of your frames.

Then the seam controls - crossfade_frames (4 is a sane default, the tooltip's own advice is 2–6; push it higher and you're smearing motion), luminance_match (on by default and you should leave it on), luminance_fade_frames (16), crossfade_ms (15), and fps to keep the sample math honest.

Four optional inputs do the actual wiring: prev_images / prev_audio are the accumulated long video so far - leave them empty on the first segment, the node handles that case - and curr_images / curr_audio are this clip, straight from your VAEDecode / VAEDecodeAudio (or from Trim Prefix, if you're trimming upstream).

Outputs are stitched_images, stitched_audio and total_frames. Feed the images into your save/combine node, and loop both back into the next generation's prev_ inputs as you go. total_frames is your running length.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/knoic/ComfyUI-MiniMaxH3-PrefixStream.git
cd ComfyUI-MiniMaxH3-PrefixStream
pip install -r requirements.txt

Restart ComfyUI and the pack appears under MiniMaxH3/PrefixStream - or install from ComfyUI Manager by searching the pack title. Requirements are light: torch, safetensors, pillow. This node never touches a file, so it doesn't need FFmpeg, but the pack's clip bin and disk streamer do - keep it on PATH if you're using those.

Common issues

Audio rate or channel mismatch is a hard error. The stitcher requires the previous and current waveforms to share sample rate and channel count; if they don't, it raises and tells you to resample upstream. That's better than a silent drift, but it means you should standardise audio before the seam.

Watch the crossfade against the overlap. crossfade_frames blends frames from inside the trimmed head, so if it's larger than trim_frames there simply isn't enough overlap to blend and you're back to a butt cut. Same class of bug as double trimming: if an upstream Trim Prefix already removed the head, don't also ask this node to trim.

Memory still grows. This node holds the entire accumulated IMAGE batch in RAM - exactly the ceiling the pack's MiniMax H3 Disk Video Stream exists to remove. Split the job: disk streamer when length is the constraint, this stitcher when the seams are.

CategoryMiniMaxH3/PrefixStream

Inputs (12)

NameTypeDefaultDescription
trim_framesINT00–192当前片段在缝合前需要裁切的前缀帧数。设为 0 时若连接了 session/config 将自动获取
crossfade_framesINT40–30画面重叠接缝处的余弦 S 曲线混合平滑过渡帧数 (推荐 2~6 帧)
luminance_matchBOOLEANtrue自动检测并平滑纠正前后片段的全局亮度色差,杜绝接缝闪光
luminance_fade_framesINT161–60亮度增益向原生亮度平滑回退过渡的帧数
crossfade_msFLOAT150–500音频重叠区线性交叉淡化时长 (毫秒),彻底消除接缝爆音 (Click/Pop)
fpsFLOAT24.001–120
prev_imagesoptIMAGE前置已累积的长视频画面。首段生成时可留空
curr_imagesoptIMAGE当前生成的片段画面 (来自 VAEDecode 或 TrimPrefix)
prev_audiooptAUDIO前置已累积的音频流。首段生成时可留空
curr_audiooptAUDIO当前生成的音频流 (来自 VAEDecodeAudio 或 TrimPrefix)
sessionoptMINIMAX_SESSION
cache_configoptMINIMAX_CACHE_CONFIG

Outputs (3)

NameTypeDescription
stitched_imagesIMAGE
stitched_audioAUDIO
total_framesINT