LanPaint AV Decode
Unpacking MiniMax H3's AV latent and stitching it back at the original fps
- samples
- video
- vae
- audio_vae
- mask
- audio_mask
- video
- audio
LanPaint_AVEncode bundles video frames and an audio track into one nested latent for MiniMax H3 AV inpainting. LanPaint_AVDecode is the other side of that deal: it takes the inpainted nested latent, decodes both streams, and merges them back into your original video - keeping the source's frame rate and bit depth, and only touching the places you masked.
The merge logic is the part worth caring about, because it's what makes the result look like a fixed video rather than a Frankenstein clip. The video frames replace the original only inside the video mask, with a MaskBlend-style Gaussian boundary (the blend_overlap input, default 11 pixels). The audio replaces the original only inside the audio-mask intervals, with a short crossfade at each interval edge (default 0.02 seconds) so you don't hear a hard click where the inpainted sound meets the original. Frames and audio outside their masks are the original, untouched.
How it works
It unbinds the nested latent into its two streams, decodes the video with your video VAE and the audio with the MiniMax H3 audio VAE, and resizes the decoded frames to match the original's dimensions exactly - a VAE decode can round the size, and the README's examples live and die by pixel-perfect boundaries. Then the per-stream masks drive the two merges. The output video is rebuilt from components with the original's frame rate and bit depth, so what comes out matches what went in; the output audio is also returned separately, at the original sample rate.
The inputs that matter
- samples - the nested AV latent out of your LanPaint sampler.
- video - the original video (the same reference from the VideoMaskEditor). It's the source of the kept content and of the fps and bit depth.
- vae and audio_vae - the video VAE and the MiniMax H3 audio VAE you encoded with.
- mask and audio_mask - the same per-frame masks you fed to AVEncode, 1 = regenerate, 0 = keep.
- blend_overlap - boundary blend width in pixels for the video seam, default 11.
- audio_crossfade - crossfade in seconds at audio interval edges, default 0.02; 0 gives you a hard cut.
Outputs are video (the merged clip) and audio (the merged track). Both can be previewed or saved.
Install and gotchas
It ships with the LanPaint pack: ComfyUI Manager → search "LanPaint", or clone and restart:
cd ComfyUI/custom_nodes
git clone https://github.com/scraed/LanPaint
No pack-level pip dependencies. If the inpainted audio's sample rate differs from the original's, resampling needs torchaudio; without it, the node fails loudly instead of guessing.
Two behaviors to know about. If the source video has no audio track, the node just falls back to the inpainted audio - handy, but don't be surprised when a silent source comes back with sound. And keep audio_crossfade small; it's there to smooth the interval edges, not to fade the whole clip, and anything much past a few hundredths of a second starts bleeding into audio you asked to keep. Match the masks here to the ones you fed AVEncode - they're what decides what gets replaced, and the whole "untouched pixels stay untouched" promise of masked inpainting depends on them lining up.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| samples | LATENT | The nested AV latent to decode (from the sampler). | |
| video | VIDEO | The original video (from the mask editor): source of the kept content, fps and bit depth. | |
| vae | VAE | The video VAE. | |
| audio_vae | VAE | The audio VAE (e.g. the MiniMax H3 audio VAE). | |
| mask | MASK | Per-frame video mask [F, H, W] (1 = regenerate, 0 = keep). | |
| audio_mask | MASK | Audio mask [F] or [F, 1] at video frame rate (1 = regenerate that moment of the audio, 0 = keep). | |
| blend_overlap | INT | 111–51 | Boundary blend width in pixels between the inpainted and original video (MaskBlend-style). |
| audio_crossfade | FLOAT | 0.0200–1 | Crossfade in seconds at audio interval edges (0 = hard cut). |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| video | VIDEO | — |
| audio | AUDIO | — |