Skip to content
المشاريع

NikoDemon80/ComfyUI-H3-Motion-Context

عرض على GitHub

حول

ربط المقاطع لـ MiniMax H3 في ComfyUI، مع استمرار الحركة والصوت فعليًا عبر نقاط الوصل.

التصميم والوسائط

كيف تُقاس هذه الأرقام

1,470 نجمة166 التفرعات +7 خلال 24 ساعة

النمو المقاس للنجوم

خلال 24 ساعة
+٧
خلال 7 أيام
+٧٤
خلال 15 يومًا
+٩٧
خلال شهر
+١٢٤

تغيّر صافي النجوم خلال فترات متداخلة، وليس مجموعًا يوميًا. تبقى القياسات المفقودة فارغة. النجوم تقيس الاهتمام لا جودة البرمجيات.

README.md

الأصل

H3 Motion Context

Chain MiniMax H3 clips so motion and sound keep going across the cut.

Generate clip A. Feed its last frames and audio into this node. Generate clip B. B picks up where A left off: same motion, same speed, same direction, and the same audio continued rather than a new take that sounds similar. Repeat as long as you like.

Nothing on disk is edited and nothing in ComfyUI is modified. The nodes check their arithmetic against the live ComfyUI code before the first render, and if an update breaks an assumption they refuse to run and say what moved. A loud failure beats a bad render you don't notice.

Requires ComfyUI 0.34.0 or newer, which is where H3 gained arbitrary keyframe anchors. Version 0.3.1 runs on that and on everything older; see CHANGELOG.md.

Why this exists

ComfyUI can anchor a still or a short clip at any frame of an H3 generation, with the Add Guide for MiniMax H3 node. If that is all you need, use it. You do not need this pack for it.

Chaining is a different problem, and two parts of it are still unsolved by anything else.

The picture goes out to pixels and back at every link. Add Guide takes images and encodes them. Chain through it and every join costs a decode, a resize and a re-encode. That round trip is where the color drift and the softening down a long chain come from. This pack slices the previous clip's tail straight out of its latent, so the carried frames are the same numbers they were, bit for bit.

The sound restarts instead of continuing. Add Guide anchors audio starting at a frame and running forward. To actually continue a soundtrack, the carried window has to END at the join and reach backwards into the sound that already played. That is the difference between the model continuing your track and the model writing something that sounds like it, and on anything with a beat you hear it immediately.

Everything else here follows from those two: the Trim node that removes the carried head from the delivery, the Save/Load Latent pair that carries a clip across without touching pixels, the Seam Probe that measures whether a join is a real continuation or a convincing imitation, and Chain Upscale, which takes a finished chain to a higher resolution without reopening the joins.

Audio was the harder half, and it's the more useful half, since H3 generates picture and sound together. See "Why the audio needed work" below if you care how.

Install

Drop the folder in ComfyUI/custom_nodes/ and restart. At startup you'll just see:

h3_motion_context: nodes registered. ComfyUI is not modified; the layout
checks run on the first use of a Motion Context node.

Having the pack installed changes nothing about your other H3 workflows, and nothing runs until you actually chain a clip. The first time you do, you'll see:

h3_motion_context: ComfyUI H3 layout checks passed, anchors and pinned audio will land where intended

Anything else and the node refuses to run. The reason is logged.

On ComfyUI 0.33.4 or older the node says so and points you at version 0.3.1, which runs on both. That is read from the layout code itself rather than a version number, so a nightly or a fork gets the right answer.

If you had the separate ComfyUI-H3-Disk-Upscale pack installed, remove it. This pack replaces it.

Wiring

MiniMaxH3ImageToVideo / MiniMaxH3ReferenceToVideo (or the t2v path)
  -> H3 Motion Context      <- previous clip's latent (picture + sound)
  -> guider / sampler
  ...
  decoded IMAGE + AUDIO
  -> H3 Motion Context Trim         <- wire trim_frames and geiru_drop across
  -> Create Video / save

Wire trim_frames into the Trim node. The carried frames come back at the start of the new clip and have to come off before you concatenate, picture and sound together. Wire geiru_drop across too, so Trim follows the Geiru drop switch (see below).

With the pinned hold, H3 redraws the carried frames about 5% brighter than they were, and the first frame it makes itself is still at that level, so it flashes as one bright frame at the join. Trim's level_first_frame (on by default) brings that frame to the brightness and color of the frame after it, area by area. Its picture and motion are kept, and nothing is cut, so length and sync are unchanged. With the masked hold nothing is redrawn, so it can be off.

Pinned or masked hold

Motion Context's hold setting picks how the previous clip's frames are carried over.

  • pinned (the default) pins them as keyframes. The model redraws them along with the rest of the clip, and the carried sound rides alongside as its own keyframe.
  • masked writes them straight into this clip's latent and locks them with a noise mask of 0. The model reads them as finished frames, the same way it reads a pinned keyframe, so nothing is redrawn and it costs no extra tokens or time. Masked hold is Roycho's method, from seitanism's MultiRef.

Masked hold needs two things wired:

  • context_latent, from Load Latent. It does not work from frames.
  • Motion Context's latent output into the sampler's latent_image, instead of the empty latent. That output carries the held frames. With the pinned hold it is the empty latent passed through unchanged, so you can leave it wired either way.

Geiru drop

H3's last few frames of a clip come out slightly degraded, and a chain that continues from them carries that into the next clip, where it shows as the background drifting after the join. Geiru drop skips them: the previous clip is treated as ending 17 frames early, and the frames just before those are carried over instead. 17 frames is one whole latent cycle, so the arithmetic stays exact.

It is one switch, geiru_drop on Motion Context. Its geiru_drop output carries the setting to the two nodes that need to know:

  • Trim then also cuts this clip's last 17 frames, picture and sound, because the next clip carries on from before them.
  • Save Latent records it, so Chain Upscale matches it without being told.

Turn it on or off in one place and the rest follows. From Roycho's Geiru Context.

sound_release (masked hold, Geiru drop on) sets how gently the carried sound hands over to the new sound. It stops pops on noisy sound like water or wind. 12 is the default, 0 switches at once. With Geiru drop off there is no room for a handover, so the sound switches at once.

Carrying the previous clip across

The previous clip reaches the node as a latent, but you can't wire the sampler straight into context_latent. ComfyUI will call it a circular connection, and it's right: the latent you want is from the previous run, not this one. Two helper nodes move it across runs the same way your frames and audio already move across, through a file:

this run:   SamplerCustomAdvanced -> H3 Motion Context Save Latent
next run:   H3 Motion Context Load Latent -> context_latent

Both have a clip_index and the numbers mean what they say. On Load, the clip you're continuing FROM. On Save, the clip this one IS. First clip: Load 0, Save 1. Making clip 2 from clip 1: Load 1, Save 2. Load also outputs shot, the clip being made counting from 1, for picking per-shot prompts or settings.

Load 0 does not read a file. Motion Context then passes the incoming conditioning through and reports trim_frames 0, so you can leave the node enabled for the first clip. Do not mute it.

Do not use queue run on change to walk the chain. Each index change is a separate graph edit, so two widgets incrementing will queue two runs and skip slots. Use H3 Motion Context Chain instead of ComfyUI's Run button.

The Chain node only sees Load and Save if all three sit in the same canvas group (one of those colored boxes you draw around nodes). If they are not grouped together, every button does nothing. Select Load, Save, and Chain, then Group Selected (or drop Chain into the existing Motion Context group).

Subgraphs work too. Load, Save and Chain in one subgraph follow the same group rule inside it. Split across a subgraph's edge, a group cannot hold them all, so the Chain node looks through the whole workflow instead, and works as long as it holds exactly one Load and one Save.

  • Run/Re-roll is the Run button for this graph. It queues at the current Load/Save indices and does not advance them. First clip: leave Load 0 / Save 1 and click it. Hate the result? Click it again; the retry overwrites that slot.
  • Approve advances both indices, then queues the next clip once.
  • Chain is Approve on a loop. After a finished clip it bumps Load/Save and keeps going, so a 0/1 clip you already made becomes 1/2 rather than a re-roll. The exception is Load 0 / Save 1 with no clip 1 on disk: it generates that first clip, then auto-approves. segments is how many clips that loop runs: 5 means five clips then stop, 0 means keep going until you click Stop.
  • Reset sets Load 0 / Save 1. It does not queue and does not delete files.
  • Clear latents deletes numbered chain slots (clip_00001.safetensors and so on) in the Load folder. Files you renamed are left alone. Indices stay put.

Files are named the obvious way, clip_00002.safetensors is clip 2.

Auto-saved files (Save at 0) get a trailing underscore (clip_00002_.safetensors) because they're numbered by run, not by clip, and indexed loading skips them on purpose.

You can also point the loader at a specific file when clip_index is greater than 0; the file is loaded and the index is ignored. Index 0 never reads a file. Latent paths have to stay inside ComfyUI's output folder.

By default the loader's output is only for context_latent. Don't wire it into a decode node. Turn on stock_format if you want a standard H3 latent that stock nodes accept instead. Stock Save/Load Latent won't work here, it can't handle H3's paired video/audio latent.

The latent carries both streams, so with it wired you don't need to load the previous clip's video at all. The carried frames are sliced straight out of it rather than decoded to pixels and encoded again, so they're exactly what the model made instead of a reconstruction. Nothing shifts the color or the contrast, so there's no seam to see, and it's faster.

Nothing to set for any of that. Leave context_frames unwired. Resolution has to match between clips, since a latent can't be resized; if it doesn't the node refuses and names both resolutions rather than quietly dropping to the lossy path.

What Save Latent records

Save Latent has three optional inputs. Each one is written into the clip's latent file, so Chain Upscale can read it later without you setting anything:

  • pin_frames: wire Motion Context's trim_frames. The carried-over length.
  • geiru_drop: wire Motion Context's geiru_drop.
  • prompt: wire the prompt text. For H3 Chain Prompt.

Wire all three if you might upscale the chain later.

Portable latents

The latent file can also travel through ComfyUI's HTTP API, for tools that drive ComfyUI remotely and keep their own copy of every clip.

  • Save reports its file in the run's history the same way stock Save Latent does (outputs.<node>.latents: filename, subfolder, type: "output"), so a client can fetch it with GET /view.
  • Load has an optional folder widget, output (the default, the chain behavior above) or input. With input, latent_path names one file in ComfyUI's input folder, for example one sent with POST /upload/image. Index 0 still loads nothing; above 0 that file is loaded. Paths that leave the input folder are refused.

Workflows saved before folder existed load unchanged and keep reading from output.

There's an older path for graphs with no latent: the previous clip's frames into context_frames, its decoded audio into context_audio, and the H3 audio VAE into audio_vae. It works with the pinned hold only, but it costs a lossy round trip per link on both streams and it's where the visible seams came from. Use the latent unless you have a reason not to.

Reference mode

Put this node after MiniMaxH3ReferenceToVideo and wire it as above. Your reference blocks (image, video, video with audio, audio) are left alone entirely: the carried sound rides as a keyframe, not a reference, so the two mechanisms no longer share a list.

Nothing to configure. Worth mentioning only because versions before 0.2.0 overwrote that list, so turning chaining on quietly threw your references away, and because up to 0.3.1 the carried audio was added to it.

References still push the target timeline along, and the carried frames follow it. That is ComfyUI's own arithmetic now rather than this pack's.

Alongside Add Guide

Anchor whatever you like with Add Guide for MiniMax H3 and put this node after it. Both survive: the carried head decides how the clip starts, the guide decides what happens where you put it. Guides that carry audio keep their own placement, which is forward from the anchor frame, while the carried sound keeps its backwards-reaching window.

Guides anchored inside the carried head are dropped with a warning, for the same reason a first_frame anchor is.

Keeping a last-frame target

Wire last_frame on the stock conditioning node as usual and put this node after it. The anchor is kept and pinned alongside the head: the carried run decides how the clip starts, your image decides where it ends. It keeps the coordinates ComfyUI gave it, including the shift references apply, so it stays put whatever else is in the graph.

A first_frame anchor is dropped, with a warning. The carried head owns those frames, and a second block pinned at the same instant with different content would fight it. Older versions silently replaced both anchors, so if a chain graph carried a last-frame target before this version, it never reached the model.

Settings

context_length - frames of the previous clip's picture to carry over. 5, 22, 39 or 56. Those are the lengths that are a whole number of latent steps, which is why the others aren't offered. 5 is just barely fluid, 22 is nearly seamless. Longer windows carry more motion but they come off the front of the delivered clip, so 56 spends 2.3 seconds of every render on frames you throw away. Use 22.

audio_context_length (pinned hold only) - frames of tail audio to pin, independent of the picture window. It ends at the same instant as the carried video, so this only controls how far back the sound reaches. 0 follows context_length. Use 18. Longer windows hold the sound closer to the previous clip, but it gets a little more muffled and a little quieter at every join; at 24 that is audible within a few clips. Shorter windows keep the level and the joins clean, but the music wanders further from clip to clip. 18 is the best balance found so far on music chains. Some treble loss remains at every length. Any multiple of 3 lands exactly on the model's 40 Hz audio grid (a frame is 5/3 of an audio step), so the window is pinned at precisely the width you asked for. Off-grid values are widened to the nearest whole step.

hold - pinned or masked. See "Pinned or masked hold" above.

geiru_drop - on or off. See "Geiru drop" above.

sound_release (masked hold with Geiru drop on) - how gently the carried sound hands over. 12 is the default.

Everything else is fixed: the pinned run is encoded in one VAE call, it sits at the head of the clip where the Trim node removes it, and the pinned audio goes on this clip's own timeline. The alternatives all existed only to reproduce their own failures, so they're constants at the top of nodes.py now. Change one there if you ever need to see what they did.

level_first_frame on the Trim node is a setting so it can be switched off to compare, or with the masked hold. Leave it on with the pinned hold.

match_tail on the Trim node stays a setting because that node has no idea what the other one did. Leave it on. H3 rounds its audio grid to the nearest step, so every clip carries about 8ms too much or too little sound, and that error stacks at every join.

Reducing drift (experimental)

Long chains drift. Faces polish or age, fine detail builds up, and color and contrast shift a little at every join. These experimental nodes work on that. They reduce drift, they don't remove it, and how much they help depends on the scene. Their behavior and defaults may change in later versions.

H3 Refine Blend stays in 0.8 and retires in 1.0, along with any other node built only for the pinned hold. The masked hold and Chain Upscale's refine cover what it did.

  • H3 Refine Blend gives each clip a light second pass so it re-reads your references instead of only copying the previous clip. The pinned frames are kept exactly as sampled, so the join stays closed, and the refined version is blended in after them. Put it in the same canvas group as Load, Save and Chain; the Chain node keeps it in step.
  • H3 Join Match removes the small jump in brightness, contrast and fine detail between the previous clip's last frames and this clip's first new frames. It works best when the camera and scene hold still. On moving shots it mostly leaves the clip alone.
  • H3 Sigmas Tail reshapes the last few noise levels of the schedule so the final step adds less extra sharpness. Optional; results vary more from scene to scene than the other two.
  • H3 Start Noise makes the sigmas for a refine pass from a start noise in percent and a step count, in place of BasicScheduler and Split Sigmas. 63% and 4 steps is the tested setting.

Join Match defaults to tuning: auto, which reads each clip, tells a locked-off shot from a moving one, and picks its settings for you. manual uses the widgets as set.

BasicScheduler -> H3 Sigmas Tail (optional) -> main sampler, sigmas
H3 Start Noise -> refine sampler, sigmas

main sampler -+--------------------------------> Refine Blend (original)
              +-> refine sampler --------------> Refine Blend (refined)

Refine Blend -> H3 Join Match -> Save Latent, VAE Decode, VAE Decode Audio
Motion Context trim_frames -> Join Match context_length
Load Latent -> Join Match context_latent

Give the refine sampler the plain Reference to Video conditioning, not the Motion Context output, and its own random seed.

Save Latent and both decodes take Join Match's output, so the video you keep matches the latent the next clip continues from.

Sparse attention

ComfyUI's Model Sparse Attention lets each part of the picture look closely at only the parts it scores as relevant. A chained clip's join suffers under it, because the frames right after the join see the carried head only in part. H3 Sparse Hold (experimental) runs the join dense: the carried head and the frames right after it see every token exactly, and the rest of the clip stays sparse.

Load Diffusion Model -> Model Sparse Attention -> H3 Sparse Hold -> sampler
Motion Context trim_frames -> Sparse Hold hold_frames

dense_after is how far past the join the frames stay dense: 24 frames is a second. It works with Model Sparse Attention's sol-attn and sla methods. vsa reorders the picture before attention and is refused. Dense attention (flash, sage and the like) needs nothing.

Upscaling a chain (experimental)

Make the chain at a resolution your card can sample, then upscale it with H3 Chain Upscale. Upscaling each clip on its own reopens the joins, because each upscale invents its own fine detail. This node keeps them closed, and decodes straight to disk so a 4x clip never has to fit in RAM.

For each clip it:

  • reads the clip's low-res latent straight from the chain folder
  • upscales it in tiles sized from free VRAM
  • refines it in tiles stepped together, with the same noise as the previous clip across the frames they share, and with the previous clip's finished upscale of those frames written into its head and held there with a noise mask of 0. H3 reads mask-0 frames clean, the same way it reads a pinned keyframe, so the refine continues their detail, and the clip's own frames are drawn right next to the real ones. The held frames are part of the clip, so they cost no extra tokens. (Credit to Roycho for finding how H3 treats masked frames.) With refine off, nothing is held, so the head is faded in from the previous clip instead.
  • saves its own upscale for the next clip
  • decodes it to PNG frames on disk and writes the clip's video. Every clip after the first is decoded with the previous clip's last latent steps before the overlap in front of it, then those frames are dropped. The video VAE builds each frame from the ones before it, so a clip decoded from a cold start comes out a little brighter for its first frames, which showed as a flash at every join.

Upscaling never joins the movie. Line the clips up, then press the movie button once.

Geiru drop. A chain saved with Save Latent's geiru_drop wired records it, and the upscale follows it: it holds the same frames the low-res chain held, decodes the lead-in from just before them, and the movie leaves out each clip's last 17 frames, picture and sound, since the next clip never continued from them. Nothing to set. Each clip's own video keeps its full length, tail included.

For a chain that does not record it, such as one made with Roycho's Geiru Context Suite (drop_last 17), set Geiru drop in the Upscale card to 17. Leave it off for chains made without a drop. When the chain records it, that row is greyed out and the recorded value is used. (Credit to Roycho, Geiru Context Suite.)

Requirements

  • Comfyui-MMH3-UltimateUpscale installed. The node uses its upscaler code.
  • A minimax_h3_latent_upscaler_3d .safetensors checkpoint in ComfyUI/models/latent_upscale_models.

Wiring

H3 model                              -> model
plain Reference to Video conditioning -> conditioning
H3 video VAE                          -> vae
H3 audio VAE                          -> audio_vae (for chain audio)
an audio file (optional)              -> soundtrack
Save Latent latent_path (optional)    -> latent_path (one queue, below)

The refine's sampler, start noise and steps are set on the node itself, so there is no sampler or sigmas to wire.

Pick the chain in the panel. Nothing else needs wiring: no Load or Save Latent nodes.

The upscale needs to know the chain's pin, the Motion Context context_length. Chains saved with Save Latent's pin_frames wired record it (see "What Save Latent records" above). Chains saved without it show a Pin setting in the Chain card instead; set it to the context_length you used.

Prompts for each clip

The refine re-reads each clip's own prompt, so clip 3 has to be refined with clip 3's prompt. Let the chain remember them:

  • Low-res workflow: wire the prompt text into Save Latent's prompt input. Each clip's file records the prompt it was made with.
  • Upscale workflow: H3 Chain Prompt -> your text encoder -> Reference to Video -> H3 Chain Upscale's conditioning.

The panel sets H3 Chain Prompt to the clip it is about to run before every run, including skipped clips, redos and restarts, so the prompt cannot fall out of step with the clip. It works anywhere in the workflow; it does not have to share a group with Chain Upscale. A second pass reads the prompts the first pass carried into its upscales.

For a chain saved without prompts, drive your own list of prompts with H3 Chain Prompt's clip_index output (it counts from 1) and leave its prompt output unwired. If the prompt output is wired and a clip recorded no prompt, the node refuses and names the clip rather than refining it with an empty prompt.

Make and upscale in one queue

One workflow can make each clip and upscale it in the same run. Wire H3 Motion Context Save Latent's latent_path output into H3 Chain Upscale's latent_path input. That one wire:

  • makes the upscale run after the save, every time
  • upscales the clip just saved: the chain and clip come from the file Save Latent wrote, so Approve, Chain and Run/Re-roll on the Motion Context Chain node all just work, re-rolls included
  • switches the panel to follow Save Latent. Its upscale buttons are off; use the Chain node's buttons. The clip strip, status, player and settings still work.

Follow in the Chain card turns that off without unwiring: with it off, making clips upscales nothing and the panel's buttons work again.

Feed Chain Upscale the same model and plain Reference to Video conditioning as the low-res sampler. Every clip is made from the prompt in that run, so H3 Chain Prompt is not needed here.

Making clips never joins the movie, so nothing is encoded twice while the chain grows. The movie button works while following: it runs Chain Upscale on its own, without Save Latent or any other part of the workflow, so it never makes a new clip. To redo out of date clips from the panel, turn Follow off, or bypass Save Latent (or the whole generation group); the panel then runs on its own again.

Each run loads the base model, then the upscaler, then the base model again for the refine, and the upscale's memory peak comes on top of the low-res workflow's. Two separate passes are faster per clip and easier on VRAM; one queue saves the second sitting.

Save Latent at clip_index 0 numbers its files by run rather than by clip, so they are not part of a chain, and the upscale refuses them.

Chain Upscale, Save Latent and H3 Chain Prompt can each sit in a subgraph or on the main canvas. The panel follows the latent_path wire across subgraph edges, and keeps every H3 Chain Prompt in the workflow in step, whichever subgraph it is in.

The panel

The node is one panel. Its settings are set from there; the inputs on the left are wired as usual.

The node keeps whatever size you drag it to. Opening or folding a section never resizes it; the panel scrolls instead. It stays drawn at every zoom level. Rows that do not apply are greyed out, with the reason in their hover tip, rather than hidden, so the panel does not jump.

Always at the top:

  • Chain picks the chain to upscale from every chain found under output/, low-res chains and upscale folders alike, with the size it comes out at beside it.
  • The clip strip has one tile per clip, showing the clip's first frame: a rough preview straight from the latent at once, using ComfyUI's own sampler preview colors, and a sharp one decoded by the VAE after the node's first run on the chain. The border shows the state: green done, blue video needs re-encoding, amber out of date, striped stopped partway, grey not started. Click a tile to select that clip. The mark between two tiles turns amber when the second clip's head was faded into an older version of the first. Hover a tile for the reason it is out of date.
  • The status line says what the selected clip, the chain and the movie are up to, or what a run is doing. Hover it for the full story.
  • The main button always does the next thing the chain needs, and shows the run's progress inside it:
    • Upscale clip 3, Upscale clips 2 to 5 and so on, while any clip needs it. Finished clips are skipped, stopped ones pick up where they left off, and out of date ones are made again. Stop it any time and press it again to carry on. It does not make the movie.
    • Create movie once every clip is upscaled and current. It joins every clip into one movie in one run, upscaling nothing. It reads Rebuild movie when a clip or a Video setting changed since the movie was made, and Movie up to date when there is nothing to do. Hover it to see which clips are not ready, or whether this movie will be quick or slow, and why.
    • Stop while running. It interrupts the current run. Finished work is kept.
  • Clip N only runs the selected clip, if it needs it. Its tail is kept, so a single clip is always whole.
  • The menu holds Redo clip, which throws away the selected clip and makes it again from the chain (click it twice to confirm), and Clear frames, which deletes the PNG frames of every clip and shows how much disk that frees. Latents and videos stay.

Under those are two tabs, Player and Settings.

  • Player: plays the joined movie, or the selected clip's own video (whole, head and tail included), on a square black screen as wide as the node. Landscape clips get black bars above and below, portrait clips at the sides, so the panel never changes size with the clip. With nothing to play the screen stays, empty. Under the movie there is a marker at every join; click one to watch that join from a second before it.

    • Buttons step a frame back or forward, jump to the previous or next join, and loop, with a frame counter alongside.
    • Speed 1/4, 1/2 or 1x, for studying a join.
    • Loop join plays a second either side of the nearest join, over and over.
    • Full view fills the page. Scroll to zoom in, drag to move around, double-click to reset, Esc to close.
    • Keys, once you have clicked the player: Space plays or pauses, the arrows step a frame, Shift and the arrows jump to a join.
    • Drag frame drags the frame on screen out as a PNG, at full resolution: onto the canvas, onto a Load Image node, or into a folder.
    • A movie that no longer matches the clips is flagged above the picture, naming the clips that changed since it was made.
    • While following Save Latent, the player switches to each clip as its run finishes, so the latest render is the one on screen. Click a tile to play that clip instead; it does not change the clip being made.
    • The line under it gives the size, frame rate, codec, whether it was encoded on the GPU or CPU, and the file size.
    • Browsers can't show ProRes, and most can't show H.265. For those the player makes a browser copy (H.264, kept in ComfyUI's temp folder, made once per version of the file) and plays that. The file itself is never changed, and dragged frames come from the real file.
  • Settings: four cards. Each shows a one-line summary in its header and folds away. Refine and Video have their own on/off switch.

    • Chain: Follow (only with latent_path wired), Output, and Pin, which shows only when the chain does not record it.
    • Upscale: upscale model, scale, the size it comes out at, the shape of the join fade (refine off only), and Geiru drop (only for chains that do not record it).
    • Refine: sampler, start noise and upscale steps. While on, it shows how the refine will be tiled and how many tokens each step takes against the crash ceiling. The token budget, tile overlap and smallest tile are under Advanced.
    • Video: sound, codec, CRF, encoder speed, audio quality, GPU encoding, and whether to keep the frames. CRF, speed and audio are greyed out for ProRes, which has none of them. GPU only works when the server found a working NVIDIA encoder.

If the clip before the selected one is not done yet, the panel says so, since this clip will need redoing once that one is upscaled.

Changing codec, crf, encoder_speed, audio_kbps, gpu_encode or sound shows every clip made with the old settings as needing re-encoding, and the movie as out of date. The main button then re-encodes the clips from the saved upscales, without upscaling again, and Rebuild movie remakes the movie.

Redoing a clip makes the clip after it out of date, because that clip's head holds the old version's frames. The panel shows it as out of date, and the main button redoes it. Clips refined with an older join method show as out of date too, and are redone the same way.

With refine on, a different model, LoRA, prompt or reference image also makes a clip out of date. The panel can't see that ahead of time; the next run finds it and makes the clip again.

Settings

  • scale: 1.5x, 2x, 3x, 4x, or Custom, which shows a box for any scale from 1.1x to 4x. The size snaps to the nearest 32 pixels. Every clip of a chain needs the same scale.
  • refine: re-sample the upscale. Off is faster and softer, and the model never loads.
  • sampler_name: the sampler the refine uses. Default euler.
  • start_noise: how much the refine changes the clip, in percent. Lower only sharpens; higher redraws more detail, but faces and small things can change. Default 63.
  • upscale_steps: steps the refine takes. Default 4. 63 with 4 steps is the tested setting. More settles a heavy refine and helps tiles match, but each step is another pass over every tile.
  • make_video: decode each clip and write its video. Off makes the upscaled latents only, for a first pass that a second H3 Chain Upscale reads. The video settings are then not used.
  • sound: chain audio uses the sound the chain made, including sound shaped by an audio reference on the Reference to Video node. silent has none. A wired soundtrack replaces the joined movie's sound either way, cut or padded to the movie's length.
  • codec: H.264 plays almost everywhere. H.265 makes smaller files but encodes slower. ProRes 422 HQ makes a large .mov for editing software, visually lossless, with uncompressed sound. Changing codec replaces the old file rather than keeping both.
  • crf: picture quality. Lower is better and makes bigger files. 10 to 14 for files you will process further, 16 to 18 for a final movie (it looks the same at a fraction of the size), 23 for a quick draft. Avoid 0: huge files that many players will not play. Default 14. Not used by ProRes.
  • encoder_speed: CPU encoding only. Slower makes smaller files at the same quality. Default slow. Not used by ProRes.
  • audio_kbps: sound quality, 128 to 320. 192 is fine for sharing, 320 is the best. Not used by ProRes.
  • gpu_encode: encode H.264 and H.265 on an NVIDIA card when it works here. Much faster at 4K and up. If the GPU encoder fails partway, that file is made again on the CPU, so a run never fails because of it.
  • keep_frames: keep the PNG frames after the videos are built. Off, each clip's frames go as soon as its video is written. The movie does not need them. Kept, changing a Video setting later skips the decode.
  • follow_save_latent, pin_length, geiru_drop_last: see "Make and upscale in one queue" and "Geiru drop" above.
  • token_budget, tile_overlap, min_tile_size, blend_curve: advanced. Lower token_budget if the refine runs out of VRAM. Above about 74,900 the INT8 fast kernels crash. The held frames are part of the clip, so every clip uses the same budget as the first. blend_curve shapes the join fade, and is only used with refine off.

Changing any setting that alters the picture redoes the clips it affects. Changing only a Video setting re-encodes without upscaling again.

A second pass

The upscaler goes up to 4x in one pass. For more, or for two 2x steps with a refine at each size, run H3 Chain Upscale twice:

  • Pass 1: Chain the low-res chain, Output for example up_pass1, Video off. It makes the upscaled latents only.
  • Pass 2: Chain up_pass1, Output for example up_pass2, Video on. It reads pass 1's clips as its chain and makes the video.

Pass 2 reads the held frames, the pin, the Geiru drop and the prompts from pass 1. Pass 2 only reads pass 1 clips whose upscale is finished and current. Redo a clip in pass 1 and pass 2 shows it, and the clip after it, as out of date.

Pass 2 refines at the larger size. At 2x that is four times the pixels, so expect each clip to take about four times as long as in pass 1.

The joined movie

Each clip after the first starts with its own copy of the previous clip's last frames. The movie keeps one copy, cut in the right place for each:

  • Picture: the previous clip's copy is dropped. With refine on, this clip's head already is the previous clip's upscaled frames, held through the refine. With refine off, this clip's head is faded in from the previous clip's frames instead.
  • Sound: this clip's copy is dropped, which is where Motion Context's Trim cuts the low-res chain. The last 20 ms of the previous clip fade into this clip over the same moment, using real sound from both clips. Nothing is reversed or invented, so a beat on the join stays one beat.
  • Geiru drop: with it on, each clip's last 17 frames are left out too, picture and sound, just as Trim leaves them out of the low-res chain.

The movie comes out exactly as long as the low-res chain, in sync. The movie button stays off, naming the clips in its hover tip, while any is not upscaled or is out of date.

Each clip's video is written with a keyframe, a self-contained frame, exactly where the movie cuts it. The frames after a keyframe never look back past it, so the cut never needs a frame from the other side. H.265 is always written so that holds for every frame group, not only at the cut. So the movie is made by copying each clip's video up to its cut, with nothing decoded or compressed again: a 4K movie takes seconds, and it looks exactly like the clips. The sound is rebuilt from the clips' audio with the crossfade above.

The movie is made the slow way, decoding every clip to frames and encoding once, when:

  • a clip was encoded without a keyframe where the movie cuts it. Change CRF and back, or redo the clip, to give it the keyframe.
  • the clips were made with other Video settings than the movie's, or on a mix of GPU and CPU.

Where files go

The chain is only read from. The upscale goes into Output, a folder under output/, for example renders/mall_final. Leave it empty for output/h3_chain_upscale/<chain folder>/.

  • clip_00001/clip_00001.mp4 and so on, each clip whole, head and tail included (.mov for ProRes)
  • clip_00001/frames/ while frames are kept
  • <folder name>_upscaled.mp4, the joined movie (.mov for ProRes)
  • temp/h3_preview/, the player's browser copies. ComfyUI clears its temp folder when it starts.

One chain per output folder. The folder records which chain it holds, and pointing a different chain at it is refused rather than mixing the two.

H3 Disk Decode

Decodes any H3 video+audio latent to PNG frames on disk, then builds an MP4, so a large clip never has to fit in RAM. Use it for a single clip outside the upscale pass.

  • Writes frames to output/h3_disk_decode/<output_name>/frames and <output_name>.mp4 beside them, at 24 fps.
  • trim_frames cuts frames off the front, picture and sound. For a chained clip, wire it from H3 Motion Context.
  • Load the latent with Load Latent's stock_format on.
  • A stopped decode resumes when queued again with the same output_name. A different latent under the same name stops with an error.
  • The standard H3 video VAE decodes in tiles. Sol-H3-VAE also works, but holds the whole clip in VRAM at once.

Writing prompts for a chain

The settings get motion and sound across the join. What happens in the next clip is on you, and there are a few traps.

The model renders contradictions as unions. Clip N ends on a close-up of A, clip N+1's prompt opens with "a two-shot of B and C," and the model doesn't pick. You get all three. The carried frames aren't a suggestion, so a prompt describing a different arrangement of people reads as an addition to them, not a replacement.

The airlock. Don't ask for the change and the continuation at the same moment. Open clip N+1 holding clip N's exact closing framing, no dialogue, about two seconds, then cut to the new setup. Joins done this way measure tighter than an ordinary frame-to-frame cut. Joins that skip it measure like two different rooms spliced together.

Give the hold something to do. A held framing with nothing happening renders as a literal freeze, and two seconds of a motionless actor looks like the video stalled. Write in a breath, a weight shift, an eyeline change. The camera holds still, the performer doesn't. tests/freeze_detect.py finds these.

Budget the carried head in your timecodes. Every clip after the first comes out context_length frames shorter than it was sampled. At 22 that's 0.92 seconds. Your prompt timings land against the sampled version, which starts 0.92s earlier, so a beat you wrote for 4.0s shows up at 3.08s in the file.

With Geiru drop on, budget the tail too. Trim also cuts each clip's last 17 frames (0.71s), and the next clip carries on from before them. Anything said in those frames is cut and never continued, so a line that runs into them loses its last words. Keep dialogue inside this window, in the sampled clip's timecodes:

  • Start after the carried head, at frame context_length. The head is trimmed off, so anything before it is not in the clip.
  • Finish by frame length - 17. After that is the dropped tail.

For 192 frame clips with context_length 22 at 24 fps:

Sampled clip Delivered clip
Clip 2 onwards, length 192 frames, 8.0s 153 frames, 6.375s
Clip 2 onwards, dialogue frame 22 to 175, 0.92s to 7.29s 0s to 6.375s
Clip 1, length 192 frames, 8.0s 175 frames, 7.29s
Clip 1, dialogue finish by frame 175, 7.29s finish by 7.29s

Write your timecodes against the sampled column; that is what the model sees.

Why the audio needed work

The first version ran pinned audio through H3's reference mechanism, which is where audio conditioning normally goes. Every join had a small tick, like the audio briefly sped up and went offbeat. Looking at the waveform showed nothing wrong. Both sides of every join were smooth on their own.

Cross-correlating each clip's opening against the previous clip's ending (that's tests/seam_probe.py) showed what was actually happening: the new clip's audio resembled the old one. Same instruments, same groove, never the same recording. A cover band. The model was reading the reference as "a separate clip that sounds like this," which is what references are for and exactly wrong for continuation.

The fix is the same one that already worked for video. The rows the model sees are identical either way. What differs is their time coordinates, and the coordinates are what say "separate clip" versus "this clip, earlier." So the pinned audio is placed on the new clip's own timeline, ending exactly where the pinned video ends. The timing locked to a flat offset that doesn't grow from join to join, and the tick was gone.

It isn't a perfect continuation yet. Measured in the latent, the model still regenerates part of the pinned sound rather than carrying all of it through, which is where the treble loss down a chain comes from. The beat stays put and the join stops sounding like a splice, but the sound is partly continued and partly redrawn.

Limitations

Quality degrades down a chain. The big one, and it's mostly audio. Each clip is generated from the previous clip's output, which came from the one before it. Losses compound like photocopying a photocopy, and in audio the top end goes first. Timing and tempo stay locked, but after several clips the sound gets duller and more muffled. Picture holds up much better.

Two things stack per link: the model's own smoothing, and a round trip out to pixels and back. context_latent removes the second one for both streams. On picture that's the difference between a visible join and no join at all. On sound it helps, but the model's own smoothing is still there. Long chains are worth listening to critically, and restarts land best at a natural musical transition. For the picture side, see "Reducing drift (experimental)" above.

A small audio offset, now believed fixed. Chained clips used to come out about 8ms late. The cause was arithmetic: a frame is 5/3 of an audio step, so unless the pinned window's length works out to a whole number of steps it landed between the ones the model was filling. The window is now snapped to that grid. The offset was constant, well under where lip-sync errors get noticeable, and it didn't grow down a chain, so this is a tidy-up rather than a rescue. tests/seam_probe.py reports the lag in milliseconds if you want to check it on your own material.

H3 emits 32 kHz audio, not 48. Read the rate off the clip in any script that remuxes or concatenates. A stream-copy concat can't change rate partway, so a hardcoded 48000 silently turns the tail of a long episode into nothing while every duration check still passes. tests/level_step.py prints every clip's rate and flags a mismatch.

Turbo LoRAs and Spectrum both cost you audio. A turbo LoRA hits a result in very few steps, and fine detail is what those last steps were for. It thickens the sound and softens the picture. Step-skipping optimizers like ComfyUI-Spectrum-MiniMax-H3 do the same thing to the audio, less so to the picture, and they also mispredict the pinned rows, which never change. Run both together and it stacks. If a chain sounds duller or closer than you expected, try turning these off before blaming the chaining. Keep Spectrum off for these graphs.

Resolution can't change mid-chain while using context_latent. A latent can't be resized, so the node refuses. Regenerate the previous clip at the new resolution, or start a fresh chain there. To end up at a higher resolution, upscale the finished chain instead; see "Upscaling a chain (experimental)" above.

Prompting a chain takes work, especially with reference mode. Every reference conditions the whole clip; there's no way to say "this one starts two seconds in." Timing has to come from the shot structure and the description. See "Writing prompts for a chain" above.

Tested narrowly. Joins have been verified on dense beat-driven electronic music, where timing errors are most audible, and on spoken word through the latent path, where nothing hides a seam. One Windows machine, one resolution, one sampler. The math self-tests every startup. The perceptual results are one person's renders.

ComfyUI's H3 support is young. This pack no longer patches any of it, but it still depends on how the layout places things, and one of those dependencies has no upstream test behind it: the pinned audio window is positioned with a fractional, negative anchor index. That is legal arithmetic in the layout and no stock node can produce one, so nothing upstream exercises it. layout_contract.py checks it before the first render and refuses if it ever stops holding.

The failure mode after a ComfyUI update is therefore "the node won't run," not bad output. There is a worked example: when the layout constructor changed, 0.3.0 of this pack refused until 0.3.1 caught up. Annoying, but the alternative was joins landing at the wrong instant with nothing to tell you.

License. The H3 community license reportedly doesn't currently cover the EU, UK, Korea or the US. Check for yourself before shipping anything on it.

Recommended starting point

context_length 22, audio_context_length 18, context_latent wired through the Save/Load Latent pair, Trim node wired for picture and sound with match_tail on, Spectrum off. Every "it works" in this README means that config.

For Chain Upscale: refine on, start noise 63 with 4 steps, and CRF 16 to 18 for a final movie.

Testing

Eleven scripts run without ComfyUI or a GPU.

python tests/_mock_harness.py        # the layout checks against a fake stock model
python tests/_node_smoke_test.py     # the node end to end, refs + save/load
python tests/_probe_node_test.py     # the seam probe node, joins with known answers
python tests/_disk_plan_test.py      # upscale tiling, decode resume and audio fit math
python tests/_upscale_plan_test.py   # chain upscale: clip state, joined movie and sound
python tests/_upscale_node_test.py   # chain upscale end to end with fakes
python tests/_geiru_drop_test.py     # Geiru drop from Motion Context through Trim, Save Latent and the upscale
python tests/_video_out_test.py      # video writing, GPU fallback, copy join, browser copies (needs PyAV)
python tests/seam_probe.py A.flac B_untrimmed.flac    # is the join real continuation?
python tests/level_step.py clip*.flac                 # does the level or room tone jump?
python tests/freeze_detect.py clip*.mp4               # did a held shot render as a still?

The first eight print their checks and end with a pass line. The other three measure real output; level_step and freeze_detect take --self-test to check their own math on made-up data first, and seam_probe's math is what _probe_node_test.py exercises.

tests/_disk_torch_test.py checks the disk decode and the tiled upscale against stock behavior with small fake networks. It needs ComfyUI's own Python and torch, and runs from the ComfyUI folder. No checkpoints or GPU.

The three measurement scripts ask different questions and a join can fail any one on its own. seam_probe is timing: is the audio the same waveform continued, or a sound-alike. level_step is volume: does the loudness, or the room tone underneath it, jump at the cut. freeze_detect is picture: is anything happening in that shot.

For seam_probe and level_step, give them the UNTRIMMED audio of the new clip. Branch the audio decode to a second Save Audio node alongside the Trim.

Measuring a join in-graph

The H3 Motion Context Seam Probe node runs the same measurements inside the graph, where the seam position is known exactly rather than inferred from file ends (that inference is where the CLI probe's phantom ~8 ms lag came from). Wire it inline between the audio VAE decode and the Trim node:

clip_a_latent     the same latent wired into context_latent
audio_vae         the same audio VAE
clip_b_untrimmed  this clip's audio off the VAE decode, before the trim
trim_frames       from the Motion Context node, same value the Trim gets

The audio output is the input unchanged, so it drops into an existing chain without changing the render. The report goes to a Preview Text node: lag, correlation, broadband and floor steps, judged against the same thresholds the CLI scripts document.

Upgrading

CHANGELOG.md lists what changed in each release and which ComfyUI H3 layout it works with. Worth a look before opening an issue or starting a fork: several fixes people have rebuilt from scratch were already in an earlier release.

ComfyUI stores widget values by position, so a workflow saved against a much older version can load its numbers into the wrong slots. New widgets in this pack are added last so that does not happen, but if a node's settings look scrambled after an upgrade, delete it, add it again and rewire it. Takes a minute and beats rendering with scrambled settings.

Only install this once. A fork of this repo, a manual clone next to a Manager install, or a renamed backup still sitting in custom_nodes will all load. Renaming a folder does not stop ComfyUI loading it.

Older versions of this pack, and other H3 packs, patch ComfyUI's layout code at runtime. This one does not, so it no longer competes for that code and will run alongside them. If it finds the layout wrapped it says who by, then checks whether anchors still land correctly and carries on if they do. Keeping one H3 chaining pack installed is still the quiet life.

Credits

The Ref2VA multi-reference support was worked out by seitanism in the Banodoco MiniMax H3 seamless-extension thread and first implemented in ethanfel's fork of this repo. The code here is written independently, but the idea is theirs and they got there first.

The masked hold, and the finding that H3 reads mask-0 frames clean, are Roycho's (roycho87), from seitanism's MultiRef. Geiru drop comes from Roycho's Geiru Context Suite. He also tested 0.8 before release, running the chain and upscale workflow end to end.

drozbay wrote the ComfyUI changes this pack stands on: the H3 layout rewrite that lets a keyframe anchor at any frame, which is why nothing in ComfyUI is patched any more, and the mask path the masked hold uses.

The prompting section comes out of a 16-clip, 4:34 multicam sitcom episode chained with this pack at 736x576 on a 5070 Ti, about two hours of generation. The airlock, the freeze warning, the 32 kHz trap and the timecode budget are all that build's findings. Same run measured a video-only chain at a median seam level step of 0.905, dropping to 0.16 with the audio carried across.

javawock7618 and azra1l reported the layout change that broke 0.3.0 and narrowed it to specific commits, which turned a hunt into a diff. ChimeraWerks found and fixed the audio grid overhang. feigo313's issue #25 is why Load 0 means the first clip and why the Chain node exists. Pendair added portable latents (PR #53), so tools like Calliope can move clips through ComfyUI's HTTP API.

H3 Chain Upscale's refine tile grid solver, shared noise field and joint stepping are ported from bbaudio-2025's Comfyui-MMH3-UltimateUpscale (MIT), in the form found in PlagueKind's H3 Ultimate Upscale (LD) node, from ComfyUI-PlagueKind-Nodes 1.6.0 (MIT), which added auto tiling and joint steps.

If you build something long with this, numbers are more useful than praise. Open an issue.

Files

File Role
layout_contract.py Proves ComfyUI still places anchors and pinned audio where this pack needs them, once, before the first render. Modifies nothing.
nodes.py The core nodes: Motion Context (pinned or masked hold, Geiru drop), Trim, the latent Save/Load pair, and Chain.
csrf_guard.py Makes sure requests to the Chain node's routes come from ComfyUI's own page.
probe_node.py The Seam Probe node: measures a join in-graph, with the seam at a known sample instead of inferred from file ends.
refine_blend.py H3 Refine Blend (experimental, retires in 1.0): holds the pinned frames and blends in a refined version of the rest of the clip.
join_match.py H3 Join Match (experimental): removes the step in brightness, contrast and fine detail at each join.
sigma_tools.py H3 Start Noise, sigmas for a refine pass, and H3 Sigmas Tail (experimental), which reshapes the last few noise levels of the schedule.
sparse_hold.py H3 Sparse Hold (experimental): runs the join dense under ComfyUI's sparse attention.
badge_node.py, web/h3_badge.js H3 Motion Context Badge: the pack's badge, on the canvas.
upscale_pass.py H3 Chain Upscale (experimental): upscale, refine, join fade, decode and movie, one clip per run. Also H3 Chain Prompt, which hands it each clip's recorded prompt.
upscale_plan.py Chain folders, clip state, recorded labels, and the joined movie's picture and sound cuts. No torch.
chain_upscale.py The refine: tiles sized from a token budget, stepped together, with the head held.
chain_noise.py Noise laid on the chain timeline, so clips share it across the overlap.
video_out.py Writes clip and movie videos (H.264, H.265, ProRes), on the GPU when it can with a CPU fallback, joins clips into the movie by copying their video, and makes the player's browser copies and dragged frames. No torch.
upscale_join_blend.py The fade from the previous clip's upscale into this clip's head, with refine off.
level_match.py Brings the bright first frame after a join to its neighbors' brightness and color, area by area. Used by Trim and Chain Upscale. No torch.
disk_upscale.py H3 Disk Decode, plus the tiled upscale and the video writer the upscale pass uses.
tile_plan.py Upscale and refine tiling, decode resume and audio fit math. No torch.
web/h3_motion_context.js The Chain node's buttons, and keeping Load, Save and Refine Blend indices in step.
web/h3_chain_upscale.js The Chain Upscale panel: chain picker, clip strip, main button, player, settings cards, progress, and the whole-chain run.
tests/seam_probe.py Is a join's audio a real continuation, a sound-alike, or drifting.
tests/level_step.py Level and room-tone continuity at each join. Also catches sample-rate mismatches.
tests/freeze_detect.py Stretches where the picture stops moving.
tests/_mock_harness.py, tests/_node_smoke_test.py, tests/_probe_node_test.py Layout, node and probe tests, numpy only.
tests/_disk_plan_test.py Upscale and disk decode math, plain Python.
tests/_upscale_plan_test.py, tests/_upscale_node_test.py Chain Upscale planning and the node end to end, numpy only.
tests/_geiru_drop_test.py Geiru drop through every node that uses it, no torch.
tests/_video_out_test.py Video writing in every codec, the GPU fallback, B-frame copy joins, browser copies and frame grabs, with real PyAV.
tests/_disk_torch_test.py The disk decode and tiled upscale against stock behavior. Needs ComfyUI's Python.
CHANGELOG.md What changed in each release, and which ComfyUI H3 layout it works with.

استكشف مشاريع مشابهة ومرتبطة

جارٍ التحميل…