Repository navigation
Description
Feature Summary
Let a MiniMax-H3 vid_gen request anchor image and audio guides at a frame index of the target video while also passing Ref2VA references, as ComfyUI's MiniMaxH3AddGuide node does.
Detailed Description
ComfyUI's video_minimax_h3_multiframe_reference template chains MiniMaxH3AddGuide after MiniMaxH3ReferenceToVideo (the plain video_minimax_h3_r2v template does not use guides). The template uses image guides only; the node also takes an audio input. One request can then carry all of:
- reference images / videos / audios (
<Picture N>in the prompt), - an image guide pinned to the first frame and another to the last frame,
- an audio guide anchored at a frame, which the generated soundtrack and lip movement follow.
This is the "keyframe completion + reference generation" task, and the audio guide is how a pre-made dialogue track is lip-synced.
In sd.cpp (master, 532d2c1) these cannot be combined:
- Keyframes and references are mutually exclusive.
src/pipeline/video.cpprejects the request:
https://github.com/leejet/stable-diffusion.cpp/blob/532d2c15c4/src/pipeline/video.cpp#L532-L535MiniMax-H3 keyframes and Ref2VA references cannot be used together - A keyframe is only the first or the last frame (
--init-img/--end-img);build_layoutplaces it at one of those two positions. - As far as I can tell from the source there is no audio guide: the MiniMax-H3 target audio latent is always created empty,
--ref-audio/--ref-video-audioare references rather than anchors on the target timeline, and--audiois Wan2.2 S2V only.
https://github.com/leejet/stable-diffusion.cpp/blob/532d2c15c4/src/pipeline/video.cpp#L525-L527
The restriction looks like a property of the layout code rather than of the model. ComfyUI's PackedLayout packs keyframes and references into the same sequence:
https://github.com/Comfy-Org/ComfyUI/blob/995456d018/comfy/ldm/minimax/model.py#L383-L427
- the cursor first advances over every reference block's span, so the target timeline starts after the references;
- each keyframe sits at
cond_t = cursor + FRAME_RESCALE * resolved_frame_indexon the target spatial grid; - a keyframe may carry a video latent, an audio latent, or both; the audio rows use the target audio
wpositions at the samecond_t, one unit per audio latent frame; - keyframe rows are condition rows (never denoised), like reference rows.
The node that fills this in:
https://github.com/Comfy-Org/ComfyUI/blob/995456d018/comfy_extras/nodes_minimax_h3.py#L182-L256
sd.cpp's build_layout has the same pieces in two separate branches, reference_blocks.empty() (keyframes) and the reference branch:
https://github.com/leejet/stable-diffusion.cpp/blob/532d2c15c4/src/model/diffusion/minimax_h3.hpp#L1116-L1198
A possible shape for the change:
build_layout: one path that emits keyframe condition rows atcursor_after_refs + FRAME_RESCALE * frame_index, then the reference blocks; add a condition-audio segment for a guide's audio latent.video.cpp: drop the exclusivity check for MiniMax-H3; accept guides at an arbitrary frame index (a single image, or a17k + 5frame clip as the ComfyUI node allows); encode guide audio with the audio VAE encoder already used for--ref-audio.- CLI /
sdcppAPI: repeatable guide inputs with a frame index, e.g.--guide-image <path>@<frame>and--guide-audio <wav>@<frame>;--init-img/--end-imgstay as shorthands for frame0and-1.
No change to weights or to the Qwen3-VL side should be needed: ComfyUI does not present guides to the text encoder, only references.
Alternatives you considered
- Passing the first frame as a reference image instead of a keyframe: a reference has no position on the target timeline, so it cannot be pinned to the first or the last frame.
- FL2VA with
--init-img/--end-imgand no references: loses the<Picture N>character and set references. - Neither covers anchoring an existing audio track.
Additional context
Use case: shots generated from a storyboard panel (pinned as the first and/or last frame), character reference images, and a pre-rendered dialogue stem the shot must lip-sync to. This is the one MiniMax-H3 workflow I cannot move from ComfyUI to sd.cpp.
I can test builds on an RTX 5090 (CUDA) against ComfyUI output for the same inputs.
Activity