Nodes/SDXL Auto Prompter/APNext H3 Refine Encode (v2v AV latent)
ComfyUI Node

APNext H3 Refine Encode (v2v AV latent)

Encode your refined H3 clip so the mouth guard has something clean to protect

By dagthomas·Created 3 years ago·Updated 2 days ago· 289
APNext H3 Refine Encode (v2v AV latent)
  • frames
  • vae
  • source_latent
  • audio
  • audio_vae
  • latent
  • frame_count
  • width
  • height

APNext H3 Refine Encode is the setup step for the pack's face-refine second pass: it takes your rendered pass-1 clip, upscaled, and turns it back into a clean MiniMax H3 AV latent - video and audio together - that a refine pass can re-render from without wrecking what made pass 1 good.

Here's the workflow it belongs to. H3 is a 33B omni-modal video model, and its first pass is rarely the final word on a face - the likeness is a bit off, the detail soft. So you upscale the pass-1 frames and re-render them v2v toward reference face images. That refine restores likeness, but it also re-denoises the mouth and strips the lip-sync. That's what H3MouthGuard fixes - and the guard can only fix it if the latent it's protecting is the encoded pass-1 content, not a half-noised mess. Refine Encode is what makes that true.

How it works

The input frames go through the H3 video VAE (width and height must be multiples of 32), and the frame count is snapped down to the model's 17k+5 grid - 22, 39, 56, 73 frames, that shape - if it's off it. The pass-1 audio is then copied into the same latent: verbatim from source_latent when that's connected (the preferred route, because it's the exact lip-sync source), or encoded from an audio track using audio_vae when it isn't. The result is a NestedTensor carrying both streams, which is what "AV latent" means in this pack.

It's also fussy in a good way. It refuses to encode if the source latent's audio is shorter than the frames need, and it raises a hard error rather than ship a phase-shifted latent if the VAE returns the wrong number of frames. Those checks exist so a broken refine doesn't silently eat your lip-sync.

The inputs that matter

  • frames - pass-1 frames, upscaled to the refine resolution. Keep them on a /32 grid; a clean 2x upscale of an H3 canvas stays on it.
  • vae - the MiniMax H3 video VAE. Required.
  • source_latent (optional) - the pass-1 AV latent. Its audio stream is copied verbatim. Preferred over audio.
  • audio + audio_vae (optional) - fallback soundtrack when source_latent isn't connected.

Outputs are latent, plus frame_count, width and height that mirror the encoded geometry. Wire those three straight into MiniMax H3 Reference to Video - its own LATENT output gets discarded, only its conditioning is used.

Installing it

Part of the comfyui_dagthomas pack. ComfyUI Manager → search "comfyui_dagthomas", or:

cd ComfyUI/custom_nodes
git clone https://github.com/dagthomas/comfyui_dagthomas
cd comfyui_dagthomas
pip install -r requirements.txt

Restart, then pull the H3 model files (the example workflow h3_face_refine_mouthguard.json carries the download links). The pack's own requirements are LLM SDKs - this node itself just needs the H3 VAE files.

Issues you'll actually hit

  • "Frame size is not a multiple of 32" - scale with a /32-snapped target. A clean 2x upscale of an H3 canvas is fine.
  • "Needs at least 5 frames" - H3's grid starts at 17; you can't refine a 4-frame clip.
  • "Source latent audio covers N ticks but M frames need N" - the pass-1 latent is shorter than your frames. Re-encode the frames at the pass-1 length, or supply audio instead.
  • The refine pass must use RandomNoise + BasicScheduler with denoise ~0.35–0.5. Never a pre-noised / DisableNoise flow - the sampler restores protected regions from the input latent, so a pre-noised input preserves noise instead of lips.

Think of it as the bookend to H3SaveClip: that one gets the render to disk, this one gets it back off the disk and into a form worth re-rendering.

Categorycomfyui_dagthomas/H3

Inputs (5)

NameTypeDefaultDescription
framesIMAGEPass-1 frames, upscaled to the refine resolution. Width and height must be multiples of 32; the frame count is trimmed down to the 17k+5 grid if it is off it.
vaeVAEThe MiniMax H3 video VAE.
source_latentoptLATENTThe pass-1 AV latent: its audio stream is copied verbatim (the exact lip-sync source). Preferred over the audio input.
audiooptAUDIOFallback soundtrack, encoded with audio_vae when source_latent is not connected.
audio_vaeoptVAEThe MiniMax H3 audio VAE (required with audio).

Outputs (4)

NameTypeDescription
latentLATENT
frame_countINT
widthINT
heightINT