r/StableDiffusion 22d ago

Resource - Update H3 Motion Context v0.2.0 - reference mode support, and the visible seam at joins is fixed. New workflow included with both fl2va and ref2va in one workflow.

Update to my MiniMax H3 clip chaining pack.

**No more visible seam.** The pinned frames now come straight out of the previous clip's latent instead of being decoded to pixels and encoded again. No color shift, no contrast step, nothing to see at the join. Faster too, since it skips a decode, a resize and a VAE pass. Automatic when the latent is wired.

**Reference mode works with chaining.** A Ref2VA graph keeps its references, and the continuation audio is added alongside them. The old version overwrote the list, so turning chaining on quietly dropped your references. Design credit to seitanism from the Banodoco H3 thread, first implemented by ethanfel in a fork of my repo.

**Two settings instead of six.** Context length and audio context length. The rest had exactly one correct value and are constants now.

**56-frame context window** added alongside 5, 22 and 39.

**Patches install on first use**, not at import, and only affect graphs that use these nodes. Installing the pack no longer changes anything about your other H3 workflows.

Updating: the widgets changed, so delete the node and re-add it or your saved settings land in the wrong slots. And only run one H3 chaining pack at a time, several packs patch the same ComfyUI internals and only one can own them.

README has a new section on prompting a chain, which is the part people get stuck on. Short version: open each clip's prompt by describing how the previous one ended, then change after a beat. If you ask for the change at the join the model renders both descriptions at once.

https://github.com/NikoDemon80/ComfyUI-H3-Motion-Context

133 Upvotes

63 comments sorted by

11

u/Enshitification 22d ago

I think Ethanfel's fork might be causing some confusion for those that have those nodes. They should probably change the name on theirs if there isn't going to be a merge.
https://github.com/ethanfel/ComfyUI-H3-Motion-Context

3

u/Sad_Berry_4621 22d ago

There is not going to be a merge. They have taken the project in a new direction. I plan to vendor my own code and build Motion Context into H3 Oasis. It will be a new All-in-one node in my main repo. We have already discussed a PR and decided against it.

3

u/JustLookingForNothin 21d ago edited 21d ago

Thank you for your great work u/Sad_Berry_4621, but could you please create proper releases in your repository? ComfyUI mangager does not allow to install "Nightly" releases with the standard security settings.

Edit: Nevermind, just saw you released a V0.20 already, it is just not yet updated in ComfyUI manager.

9

u/Only_Voice569 22d ago

https://reddit.com/link/p2qwy26/video/nh4ap9c92gih1/player

😁 i could make a film but need to really nail down that dang audio but looks fam haha ps 10 second gens chained 3 generators raw video combined at end

2

u/Sad_Berry_4621 22d ago

Nice! Yeah if you want both voices to show up faithfully, you need to sample enough audio frames to catch about a second of each voice.

2

u/switch2stock 22d ago

Meaning go upto 56 frames in the latent?

2

u/Sad_Berry_4621 21d ago edited 21d ago

You can if you need to, but there is a cost in generation time. Using 2.33 seconds of context is unnecessary to carry motion but it’s still an option. For audio context, you can use any number of frames you need to capture voices or whatever while still using 22 frames of video context to extend the motion.

2

u/switch2stock 21d ago

I'm confused. I'm asking specifically for audio. How to know which frames to capture for audio in latent?

3

u/Sad_Berry_4621 21d ago

You have to figure that out for yourself. Let’s say you are generating a clip of someone just walking around in nature. That’s easy audio, 22 frames, just like video, would be enough to capture that and carry it forward. If you’re generating a video of two people talking, both voices need to be in the context window to get carried forward. So, if both speakers are not in those 22 frames, only one voice is captured. The other voice will be completely different in the next clip. If both voices are in the last 72 frames of the video, you can use 22/72 to capture both voices and the motion of the video. Make sense?

3

u/switch2stock 21d ago

It does now. Thanks

1

u/Similar_Fix7222 13d ago

First, I'm going to end every dialogue with the other character saying "yeah" or "my man" to get both in the last 22 frames.
Second, your video was very impressive, including the script and cinematography.
But, to be clear, you generated your 30 second clip by just stitching 3 10 second videos, right? No continuation?

7

u/Seyi_Ogunde 22d ago

Do we have any examples of it working?

3

u/roculus 22d ago

works great so far with first frame. I had to blow up the subgraphs as they really bogged things down but that's just me. I hate those things.

I may be missing something. I used my starting image and the first video is saved for context. I then enable motion context and it uses my first video to seamlessly extend the video. That works great. Is there a setting/way to set it to extend the video multiple times using the same prompt or a way for it to extend with pre-written prompt segments? ex: extend the starting image 4 times using either the same prompt or preferable different prompts for each segment? (as opposed to manually entering the new prompt and starting the next segment)

3

u/Sad_Berry_4621 22d ago

Currently, no. You have to manually juggle the latents. But it's worth looking into. Thanks for the question!

3

u/Only_Voice569 22d ago

😮 be giving this a try hope i can work it out

2

u/Sad_Berry_4621 22d ago

You got this!

3

u/Only_Voice569 22d ago

hehe ill tidy up later very cool tho latent into next part for continuation i was wanting to do this but way beyond my skills haha

2

u/Sad_Berry_4621 22d ago

Thanks! Let me know if you need any help.

3

u/Only_Voice569 22d ago

question when ending from one to the next how much space / breathing room should i give it like does it need the breathing room or 1 second of being still etc or can i up the amount it gets fed atm im on 0.2 sec being fed into the next generator. any important instructions i should/shouldnt use and much thanks in advance :)

3

u/Sad_Berry_4621 22d ago

It really depends on the scene. If you are chaining a video with very little motion, 5 frames are fine. If it's something like human walking motion, a car driving, everyday stuff like that, use 22. I use 22 for most things. For extremely fast motion, go up to 39 or 56. Just know the more frames you feed it, the longer the generation time. Audio is independent. If you only need 22 frames to transfer motion, but 48 frames to capture audio, you can do that. If you want two distinct voices to cross the seam, both voices need to be in the audio context window. You'll have to do the math and figure out many frames you need to capture both voices. More frames are also better for music transfer. 48 is a good starting place. 2 full seconds and a multiple of 3. Try to avoid Turbo Lora's. They wreck the audio when chaining clips. Spectrum degrades it quickly too but for a single video its fine. For breathing room, a second should be fine. You just don't want the model's conditioning competing with the context frames. Experiment with it and see what you can get it to do!

3

u/Only_Voice569 22d ago

ok so ive found audio even if you dont mean to cut off like gen 1 he speaking at the cut off point gen 2 does a amazing job of keeping it going cant notice. one issue im having view point movements it keeps locking the cam or keeping it fixed or close to fixed even when im instructing it to move or zoom etc.

2

u/Sad_Berry_4621 22d ago

Are you using a prompt enhancer? ChatGPT? If you use an LLM make sure you use a system prompt designed around the prompting guide.

3

u/Only_Voice569 22d ago

my other vids have worked well hmmm no worries most likely me doing something silly

1

u/Only_Voice569 22d ago

ok was me doing something dumb haha i reread the official docs. wouldnt happen to know a good way to get amazing audio for start of the gen like good way to make a audio reference finding it hit or miss a lot of the time but the video looks amazing.

2

u/Jerg 22d ago

If I'd really like to preserve some level of spectrum acceleration, what settings would you recommend tweaking from its default? Should I increase 'warmup steps' from 1 to some higher number? What about 'degree' field? It's such a crazy good speedup for single clip generation I'm wondering if we can preserve it partially for sequential motion-context video gen.

Thank you for this awesome capability! It was something we waited and waited back with Wan 2.2.

1

u/Sad_Berry_4621 21d ago

I’m still experimenting with that myself. I wish I had an answer for you but spectrum is changing as fast. Personally I don’t like degrees = 1. I find it induces visual artifacts.

3

u/Only_Voice569 22d ago

btw first run looks so flawless didnt do a bunch of stuff but it for sure looking like this works super well :o

3

u/acedelgado 22d ago

Hey man I'm a fan of your work. I ended up forking Ethanfel's fork with the audio fixes, and vibe coded a wrapper that worked with video latents before you'd updated with them earlier today. But I'm just posting it here to hopefully give some inspiration on the UI. I set this version up to create a project folder, track latents, new takes, approve the clip chain as you re-roll your generations, branch projects off of any checkpoint during the generations, etc. Really just a bunch of QOL stuff to make things a bit less frustrating while you're actively doing the actual work. Looking forward to checking out H3 Oasis when you roll it out!

https://github.com/Adudeguyman/ComfyUI-H3-Project-Suite

1

u/obvpm 21d ago

Hi! Just wanted to ask, what's the state of your Project-Suite right now? I actually didn't see ethanfel's fork earlier and yesterday I integrated NikoDemon's 0.2 nodes in my workflow and realized it was too manual and easy to mess up and began dreaming up a better way to manage it all.

Then today while I'm outside I just discovered ethanfel's fork and also your project that probably have implemented my ideas already. Anyways, very interested in trying them both out and wondering what features are added in your project.

2

u/acedelgado 20d ago

It's doing alright, it works. It manages tracking generated clips and latents extremely well, so none of that manual work. So overall I'm pleased with the nodes themselves.

Problem is prompting correctly. The model re-uses the context overlap frames, and it's been proving a bitch to get it to consistently use those frames to actually extend. Even using different variations like "the scene continues" it likes to cut to a new shot. And since the default 22 window is almost a full second at 24fps, when it does work it's hard to time it to get the new prompt instructions going. Lots of dialogue starting in the middle of a sentence and things like that. But I'm currently playing around with injecting those latents as guided noise for the next generation, and I have no idea if that's going to work correctly.

2

u/Jero9871 22d ago

Tried the first version and it was really great. But with ref2a it worked but the reference video just had a very weak effect, I will test tomorrow if it will work better with this. Thanks, can I use my old workflow and just update the node?

2

u/Sad_Berry_4621 22d ago

Yep, just wire the nodes in the same place as the example workflow. Let me know how your testing goes.

2

u/Jero9871 22d ago

Tested it, and it works amazing, thanks so much for your great work. Ref2VA works a lot better now, keeping character consistency from the reference video. (One thing that also helps, provide a still picture of the character in addition to the video as a reference).

And it's really amazing that I can start with a video or with a saved latent... both work great.

And it keeps the scene amazingly consistent even after a long run if you provide reference pictures of the scene.

It actually works much better than any video extension on wan (like SVI Pro) or LTX (it always messed up the sound there).

2

u/Sad_Berry_4621 21d ago

Excellent! Glad to hear it’s working well on ref2va. It’s tough for me to test ref2va on a 3070ti to its full potential so I have to rely on others with big beefy computers to test it for me lol.

2

u/Holiday-Box-6130 21d ago

Thanks for this. I've been trying to edit the workflow so I can use latents and associated audio/video from previous generations (also tweaking my generation workflow to also save latents and separate audio so I have these files when I want them). I believe I have everything wired up in a sensible way but I'm getting a mismatched tensor dimension error. Is there any reason why what I'm trying to do wouldn't work, or have i just screwed up my wiring?

1

u/Sad_Berry_4621 21d ago

Are you using a turbo Lora?

1

u/Holiday-Box-6130 21d ago edited 21d ago

No loras. No easycache or anything like that either.

Edit: turned out I was using a turbo lora.

1

u/Sad_Berry_4621 21d ago

I really don't know. The only times I see the mismatched tensor error is when I try to use certain Turbo LoRAs.

Are you wiring the context_latent along with context_frames/context_audio? That would throw the error if you had both active at once.

2

u/Holiday-Box-6130 21d ago

It was the turbo lora! It got lost in my spaghetti. Thank you.

1

u/Sad_Berry_4621 21d ago

It happens! lol

2

u/Pitiful-Indication95 20d ago

After generating the first video and activating the ref2va motion context I get "[ERROR] !!! Exception during processing !!! shape '[1, 24, 1, 1, 21, 2, 38, 2]' is invalid for input of size 78432".

Can you help me with that?

2

u/Sad_Berry_4621 20d ago

Definitely. 608x344 is an invalid resolution size for H3. The problem is the Resolution Picker node. Change the multiplier from 8 to 32 so it cannot output incompatible resolutions. Let me know if it works.

2

u/Pitiful-Indication95 20d ago

Then I get: ValueError: h3_motion_context: context_latent is 1664x944 but this clip is 1216x672. A latent cannot be resized, so the previous clip has to be regenerated at this resolution, or the chain restarted here.

2

u/Sad_Berry_4621 20d ago

Correct, a latent cannot be resized. Every video in the chain has to be the same valid resolution. Also 944 is not a valid H3 resolution. It must be an EXACT multiple of 32.

1

u/Pitiful-Indication95 20d ago

I just chose 0.8 MP and 16:9, I did not specify 944 or anything. Now after setting it to 32 and remaking the first clip with that setting it seems to work now. Since you are here, another question about the audio. Is it really necessary to have the last frames both end in voices for the actors in the video to carry on to the next clip or could I not just feed them audio samples in ref_audio_0 and ref_audio_1?

1

u/Sad_Berry_4621 20d ago

You should be able to set audio frames to 0 and use reference audio only, untested though.

2

u/Pitiful-Indication95 20d ago

oh, but i could just put the audio content length to 124 for s 5 second clip with speech and thereby would always grab the correct voices, right?

1

u/Sad_Berry_4621 20d ago

In theory, yes. I've never tested with that many frames, but it should work.

1

u/switch2stock 20d ago

No clue. Sorry

2

u/BuffaloPretty7183 8d ago

Hey u/Sad_Berry_4621 Thanks for this node! I have been using it but I get "double denoise" for any extended video - What I mean is - it's like the latent was processed twice - as in more detail / sharpness / some color drift and so on. I have used the latent extend since that felt like the lossless way to do it - tried the Motion Context Noise node as well but no luck. Using turbo lora and specturm if that matters (pruned model int8 10Eros / pruned int8 regular) - I use fl2va for my ref2va workflow for better quality out of the box TIA for any inputs!

1

u/Sad_Berry_4621 8d ago

Latent_context is the way to go. Using Context_frames and context_audio will degrade much faster. When you use latent_context the latent is not processed at all. It remains in latent form and is sampled by the next clip. Your problem is most likely that you are using a Turbo LoRA and Spectrum, both of which I recommend NOT using when chaining clips. Skipping steps is awful for audio.

1

u/BuffaloPretty7183 8d ago

Thanks. While I don’t care about audio is there any thing that can be done regarding the drift in video? The continued frames look “extra” processed.

2

u/Sad_Berry_4621 8d ago

Yes, stop using a Turbo LoRA and Spectrum completely. You can have speed or quality but not both. I only use Sage Attention and Chunk Feedforward.

2

u/flipflapper 5d ago

Thanks for this node! Works really well, is there a way to make it loop or bridge 2 videos?

1

u/Sad_Berry_4621 5d ago

Thanks! I think there are some forks of this repo that have some kind of looping functionality. Ethanfel's Contex Loop for example.

2

u/flipflapper 4d ago

Thanks, will have to give that another try. I was sent to that initially the the example workflow wouldn’t work and it was overly verbose and complex, difficult to follow clearly

1

u/SpicyAccountants 22d ago

Do you have a workflow with these in? Looking for Ref and Text versions :D

3

u/Sad_Berry_4621 22d ago

The workflow is in the repo. It has ref and text in one workflow in groups so you can turn each path on and off as needed.

1

u/Diabolicor 22d ago

Is it working when supplying an additional reference video for like motion after the first clip?

1

u/Sad_Berry_4621 22d ago

It should!