Nodes/ComfyUI-WanVideoWrapper/WanVideoLongCatAvatarExtendEmbeds
ComfyUI Node Runs on cloud

WanVideoLongCatAvatarExtendEmbeds

The node that makes a LongCat talking head longer than one window

By kijai·Created 2 years ago·Updated 22 days ago· 6,849
WanVideoLongCatAvatarExtendEmbeds
  • prev_latents
  • audio_embeds
  • ref_latent
  • samples
  • prev_images
  • vae
  • image_embeds
  • samples_slice
◄num_frames93►
◄overlap13►
◄frames_processed0►
◄if_not_enough_audiopad_with_start►
◄ref_frame_index10►
◄ref_mask_frame_range3►

What this thing actually does

LongCat-Video-Avatar is Meituan's audio-driven talking-head model - filed by the community as "smoother, more realistic talking vids but it ain't exactly instant." The quality end of the avatar spectrum; InfiniteTalk is the fast end. It isn't a Wan model at all; it just ships inside Kijai's WanVideoWrapper because the plumbing was close enough.

One generation gets you one window - 93 frames, about six seconds at 16 fps. Longer needs a second pass, and a naive second pass drifts the face, desyncs the mouth by a fraction of a second, and loops the body gesture. This node is the glue for pass two, three and eight: previous latents in, overlap kept, next audio slice aligned, a bundle out. Chain one copy per window, bumping frames_processed each time.

How the mechanism works

Latent continuation. With overlap above zero it keeps the tail of the previous latents as conditioning. The VAE compresses time about 4x, so overlap in latent frames is ((overlap - 1) // 4) + 1 - the 13-frame default is four latent frames of context, not thirteen. They ride along in the embeds as an extra conditioning latent, which the sampler reads as already-decided frames at the head of the new window. overlap=0 means no continuation, i.e. text-to-video.

Audio windowing. MULTITALK_EMBEDS hold per-frame audio features for the whole clip. The node derives a start index from frames_processed - overlap and slices exactly num_frames worth, so window two gets window two's audio. Misfeed frames_processed and you get the wrong slice - the "why is he saying that line again" bug.

Reference attention masking. LongCat conditions on a reference latent sitting at a RoPE temporal position you set with ref_frame_index. The failure mode is entropy collapse - it likes that pose so much it repeats it. ref_mask_frame_range drops reference attention for a span of frames around that position, freeing them to invent motion.

Inputs that matter, and the two outputs

  • prev_latents - the previous sampler's LATENT output, full length. On the first window Kijai's example feeds the encoded still in here with overlap=1, pinning frame one to your image.
  • audio_embeds - MULTITALK_EMBEDS, full length, from MultiTalkWav2VecEmbeds (v1.0) or LongCatAvatarWhisperEmbeds (v1.5, Whisper-large-v3).
  • num_frames / overlap - 93 frames per window, 13 overlapping, ceiling 256 and 16. Keep num_frames at 4n+1 or you'll come up short after encoding; bigger overlap is a smoother seam and less new content.
  • frames_processed - frames generated so far. Increment by your window length every pass, or the chain lies.
  • ref_frame_index / ref_mask_frame_range - the anti-repetition pair. Tooltip suggests 0–24 for consistency, higher values (like 30) to break loops, and 3 as a sane mask range; wider helps more but smears.

Optional ref_latent wants the init image latent, for identity lock. samples is the vid2vid path: the sampler's samples get sliced per window. The 1.5-only pair, prev_images plus vae, re-encodes the trailing overlap decoded frames through the VAE as overlap conditioning instead of slicing latents. Both or neither.

Two outputs: image_embeds (WANVIDIMAGE_EMBEDS) into the sampler's image embeds input, and samples_slice (LATENT) into its samples input for vid2vid.

Installing it

ComfyUI Manager, search "ComfyUI-WanVideoWrapper", or by hand (deps are accelerate, diffusers, peft, gguf, pyloudnorm):

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

On a portable install, swap pip for python_embeded\python.exe -m pip and run it from the ComfyUI_windows_portable folder.

Weights: the Avatar checkpoint into ComfyUI/models/diffusion_models (Kijai's conversions live under Kijai/LongCat-Video_comfy), a Wan 2.1 VAE, a UM-T5 text encoder, Wav2Vec2 in models/wav2vec2 or Whisper large-v3 for 1.5. Then load the bundled LongCatAvatar_audio_image_to_video_example_01.json before building your own - three chained copies of this node, wired right.

Where people get burned

bf16 only, and SageAttention 1.0.6 is broken with it. Both straight from Kijai's workflow notes. Don't get clever with a quantized checkpoint; if attention output looks like noise, that's suspect one.

The old LongCat distill LoRA isn't for the Avatar model. Kijai warns it hurts extension specifically - the thing this node does.

The node is missing from the menu. LongCat is an optional module in the pack's __init__.py. If its import fails, the pack logs WanVideoWrapper WARNING: LongCat nodes not available: … and loads the rest fine. Read the startup log before reinstalling.

A visible seam, or an obvious loop. Seam: raise overlap and make sure stitching drops the duplicates - the example uses KJNodes' ImageBatchExtendWithOverlap. Loop: nudge ref_frame_index up, widen the mask range to 5–7.

Not enough audio features in the console. Audio shorter than the window pads per if_not_enough_audio: pad_with_start holds frame one, mirror_from_end plays the tail backwards. Harmless at the very end, a red flag elsewhere.

VRAM. LongCat is a 48-block model and block-swaps; reports put Avatar 1.5 near 16GB, and the example swaps 25 blocks.

CategoryWanVideoWrapper

Inputs (12)

NameTypeDefaultDescription
prev_latentsLATENTFull previous latents to be used to continue generation, continuation frames are selected based on 'overlap' parameter
audio_embedsMULTITALK_EMBEDSFull length audio embeddings
num_framesINT931–256Number of new frames to generate
overlapINT130–16Number of overlapping frames from previous latents for video continuation, set to 0 for T2V
frames_processedINT00–10000Number of frames already processed in the video, used to select audio features
if_not_enough_audioCOMBOpad_with_startWhat to do if there are not enough frames in pose_images for the window
ref_frame_indexINT100–1000Values between 0 - 24 ensures better consistency, while selecting other ranges (e.g., -10 or 30) helps reduce repeated actions
ref_mask_frame_rangeINT30–20Larger range can further help mitigate repeated actions, but excessively large values may introduce artifacts
ref_latentoptLATENTReference latent used for consistency, generally should be either the init image, or first latent from first generation
samplesoptLATENTFor the sampler 'samples' input, used for slicing samples per window for vid2vid
prev_imagesoptIMAGELongCat-Avatar-1.5: decoded frames from the previous segment. When provided together with `vae`, the trailing `overlap` frames are re-encoded through the VAE and used as the overlap conditioning (matches v1.5's use_vcond=False behavior). Leave disconnected for v1.0.
vaeoptWANVAELongCat-Avatar-1.5: VAE used to re-encode `prev_images` for the overlap region. Only used when `prev_images` is also provided.

Outputs (2)

NameTypeDescription
image_embedsWANVIDIMAGE_EMBEDSEmbeds for WanVideo LongCat Avatar generation
samples_sliceLATENTSliced latent samples for the new frames