Nodes/KJNodes for ComfyUI/HunyuanVideo Encode Keyframes To Cond
ComfyUI Node Runs on cloud

HunyuanVideo Encode Keyframes To Cond

Generate video that starts and ends on your frames

By kijai·Created 3 years ago·Updated about 17 hours ago· 2,930
HunyuanVideo Encode Keyframes To Cond
  • model
  • positive
  • vae
  • start_frame
  • end_frame
  • negative
  • model
  • positive
  • negative
  • latent
num_frames33
tile_size512
overlap64
temporal_size64
temporal_overlap8

First-frame-last-frame conditioning - you provide the exact image the clip should open on and the exact image it should end on, and the model fills in the motion between them - is one of the more useful controls a video model can offer, and it shows up across most of the current open video ecosystems in one form or another. HunyuanVideoEncodeKeyframesToCond is the node that wires it up for HunyuanVideo specifically: it takes your two keyframes, runs them through the VAE, and folds the result into your conditioning and a freshly sized latent, all in one step instead of you hand-assembling it.

How it works

start_frame and end_frame get VAE-encoded (using model and vae) and injected into your positive conditioning - and negative too, if you supply one - so the sampler is steered toward a clip that opens and closes on those specific images. Alongside that, the node prepares an empty latent sized for num_frames, ready to hand straight to your sampler. The tiling parameters exist because encoding two full frames (and preparing a full-length latent) can be memory-heavy - they're the same kind of tiled-VAE mitigation used elsewhere in ComfyUI when a frame or resolution is too big to encode in one pass.

The inputs and outputs that matter

  • model, positive, vae - your existing HunyuanVideo pipeline pieces, threaded through this node rather than working around it.
  • start_frame / end_frame - the two images you actually care about. This is the entire point of the node; get these framed and sized sensibly and the rest is plumbing.
  • num_frames (default 33, 2–4096) - how long the generated clip is, start to end.
  • negative (optional) - your negative conditioning, encoded through the same keyframe process if provided.

The tiling knobs - tile_size (default 512), overlap (default 64), temporal_size (default 64), temporal_overlap (default 8) - are memory-management settings for the VAE encode step. Leave them at defaults unless you're hitting VRAM limits or seeing visible tile seams in the encoded result; they're not something a beginner needs to tune on the first pass.

Four outputs come back: model, positive, negative, and latent - everything downstream needs, ready to plug straight into your sampler.

How to install it

Via ComfyUI Manager: search "KJNodes for ComfyUI," install, restart. Manually:

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

then restart. You'll also need HunyuanVideo's own model and VAE already set up in your environment - this node conditions an existing pipeline, it doesn't provide the model itself.

Common issues & troubleshooting

Out of memory during encode. This is the most likely failure point for this node specifically, since it's encoding two full frames plus preparing a full latent in one go. Lower tile_size and temporal_size before you lower resolution elsewhere - that's the lever this node gives you directly.

The generated clip doesn't actually resemble your end frame. First-frame-last-frame conditioning steers toward the endpoints, it doesn't guarantee pixel-perfect reproduction of either - how closely the result matches depends on how much motion has to happen between them and how far apart the two images actually are, visually. A shorter num_frames for a big change between start and end will look more rushed; give it more frames if the transition needs to travel further.

Tile seams visible in a very high-resolution encode. Increase overlap and temporal_overlap - those exist specifically to blend across tile boundaries; the defaults are a reasonable starting point, not a hard limit.

CategoryKJNodes/hunyuanvideo

Inputs (11)

NameTypeDefaultDescription
modelMODEL
positiveCONDITIONING
vaeVAE
start_frameIMAGE
end_frameIMAGE
num_framesINT332–4096
tile_sizeINT51264–4096
overlapINT640–4096
temporal_sizeINT648–4096Only used for video VAEs: Amount of frames to encode at a time.
temporal_overlapINT84–4096Only used for video VAEs: Amount of frames to overlap.
negativeoptCONDITIONING

Outputs (4)

NameTypeDescription
modelMODEL
positiveCONDITIONING
negativeCONDITIONING
latentLATENT