NikoDemon80/ComfyUI-H3-Motion-Context

Clip chaining for MiniMax H3 in ComfyUI - motion and audio genuinely continue across joins

H3 Motion Context – seamless chaining for ComfyUI’s MiniMax‑H3

What it does

  • Adds a set of custom nodes that let you chain MiniMax‑H3 video‑plus‑audio generations so that motion and sound continue smoothly from one clip to the next.
  • The previous clip is passed as a latent (the internal representation of both video frames and audio) rather than being decoded to pixels and re‑encoded. This eliminates color drift, blur and the “softening” that normally appears after each link.
  • Audio is anchored correctly: the tail of the previous clip’s sound is copied into the next clip’s timeline, avoiding the audible “restart” most H3 workflows suffer from.

Why it exists

  • The built‑in Add Guide node can anchor a still or short clip, but it does not keep the motion/audio continuity when you generate a series of clips.
  • Normal chaining forces a decode‑resize‑encode round‑trip for every join, which degrades visual quality and introduces a subtle audio tick.
  • This pack solves both problems by slicing the latent directly and by placing the pinned audio at the exact frame where the new clip starts.

Installation

Drop the folder into ComfyUI/custom_nodes/ and restart ComfyUI.

You’ll see a console message confirming the nodes are registered and that layout checks passed. No other configuration is required.


Core nodes & wiring

Node Purpose How to connect
H3 Motion Context Takes the current generation, a latent from the previous clip, and produces a new clip that continues the motion/audio. Connect the normal MiniMax‑H3 generator to the left input, and the previous‑clip latent (from the Save/Load pair) to the right context_latent input.
H3 Motion Context Save Latent Writes the current clip’s latent (video + audio) to a file (clip_XXXXX.safetensors). Place after the sampler; set clip_index to the number you want to save (e.g., 1 for the first clip).
H3 Motion Context Load Latent Reads a previously saved latent and feeds it into the next run’s context_latent. Place before the Motion Context node; set clip_index to the clip you want to continue from (e.g., 0 for the first run, 1 for the second).
H3 Motion Context Trim Removes the pinned head frames from the output so you can concatenate the new clip after the old one. Wire trim_frames from the Motion Context node into this Trim node, then feed the trimmed video/audio to your final decoder or video‑save node.
H3 Motion Context Chain Convenience node that advances the Load/Save indices and queues the next clip automatically (use for long‑running chains). Group Load, Save and Chain together in a canvas group; press Chain to keep generating clips until you stop.

Typical flow

MiniMaxH3 → H3 Motion Context ← Load Latent
          → Sampler → Save Latent → (output video/audio)
          → Trim → Create Video

For the first clip, Load Latent index 0 reads nothing; the node still reports trim_frames = 0 so you can keep it enabled.


Key settings

  • context_length – how many frames of the previous video are pinned (options: 5, 22, 39, 56). Recommended 22 for a seamless look.
  • audio_context_length – frames of tail audio to pin (must be a multiple of 3). Recommended 18 for a good balance of continuity vs. muffling.
  • match_tail (on the Trim node) – keep enabled; it aligns the audio grid so the join is within ~8 ms.

All other parameters are fixed in the node code; you can tweak them only by editing nodes.py if you really need to.


Experimental drift‑reduction helpers (optional)

Node What it does
H3 Refine Blend Runs a quick second pass that re‑reads your references, then blends the result after the pinned frames.
H3 Join Match Adjusts brightness/contrast/fine‑detail between the last frames of the previous clip and the first frames of the new one.
H3 Sigmas Tail Tweaks the final noise schedule to reduce extra sharpness that can accentuate drift.

Place these inside the same canvas group as Load/Save/Chain so they stay in step with the chain.


Limitations & gotchas

  • Quality loss accumulates – each link re‑generates the clip from the previous latent, so visual artifacts and especially high‑frequency audio loss build up over many clips.
  • Audio offset – earlier versions had an ~8 ms lag; it is now snapped to the model’s 40 Hz audio grid, but the offset is still present (tiny, usually inaudible).
  • Sample rate – H3 outputs 32 kHz audio. If you need 48 kHz you must resample after concatenation.
  • Resolution is fixed – a latent cannot be resized, so all clips in a chain must share the same resolution.
  • Turbo LoRAs / Spectrum – these speed‑up samplers also degrade audio quality; keep them off for chaining.
  • Prompt design – the pinned frames are not a suggestion; any prompt that contradicts the held framing will be rendered in addition to the pinned content, often producing unwanted composites. Write the next prompt to start after the held frames (e.g., a brief “hold” then a new action).

Quick start checklist

  1. Install the folder under ComfyUI/custom_nodes/ and restart.
  2. Create a canvas group containing Load Latent, Motion Context, Save Latent, and optionally Chain.
  3. Set Load index 0, Save index 1, run the graph – you get clip 1.
  4. Press Approve (or Chain for automatic looping) to bump indices and generate clip 2, and so on.
  5. Use the Trim node to cut off the pinned head before concatenating clips.
  6. (Optional) Add Refine Blend / Join Match for drift reduction.

TL;DR

H3 Motion Context is a small but powerful add‑on for ComfyUI that lets you generate long, coherent MiniMax‑H3 videos with continuous motion and audio by passing latents directly between runs, trimming the pinned head, and providing helper nodes for automated chaining and drift reduction. It works with ComfyUI 0.34+ (or the compatibility version 0.3.1 for older builds).

Related

  • Project
  • Project
  • Project
  • Project
  • Project