Nodes/ComfyUI-HunyuanVideoWrapper/HunyuanVideo TextImageEncode (IP2V)
ComfyUI Node Runs on cloud

HunyuanVideo TextImageEncode (IP2V)

Text + reference images in one embed

By kijai·Created 2 years ago·Updated 12 months ago· 2,595
HunyuanVideo TextImageEncode (IP2V)
  • text_encoders
  • custom_prompt_template
  • clip_l
  • image1
  • image2
  • hyvid_cfg
  • model_to_offload
  • hyvid_embeds
prompt
image_token_selection_expr::4
force_offloadtrue
prompt_templatevideo
clip_text_override

This is HyVideoTextEncode's sibling, and the "(IP2V)" in its display name tells you the difference straight away: image-prompt-to-video. Instead of just encoding text, it lets you feed in one or two reference images alongside your prompt, and the LLM text encoder looks at both together - the image tokens actually get mixed into the same embedding pass as your words, not bolted on afterward with a separate IP-Adapter-style pipeline.

The required inputs mirror the plain text-encode node - text_encoders, prompt - plus one new one: image_token_selection_expr, defaulting to "::4". This is a Python-slice-style expression that decides which of the image's vision tokens actually make it into the encoder. The default keeps every 4th token, which is a reasonable middle ground between "the model actually sees your reference image" and "you haven't blown your token budget or VRAM." Honestly, most people never need to touch this - it's there for when you're deliberately trying to dial image influence up or down and know what a token-selection expression does. If you don't, leave it.

The optional inputs are where the real controls live: image1 and image2 are your reference images (both optional - you can also just leave them empty and use this node exactly like the plain TextEncode). clip_text_override is a nice escape hatch: if you want the CLIP-L half of the conditioning to see different text than what the LLM half is reasoning over - say, a shorter tag-style string versus your full structured prompt - you can put that here instead of forcing both halves to read the identical string. Everything else - force_offload, prompt_template, custom_prompt_template, clip_l, hyvid_cfg, model_to_offload - works exactly like the plain text-encode node; see that article if you need the details on the prompt template structure, since it's the same five-part scaffolding (content, visual detail, actions, environment, camera) baked in on the video template default.

Output is the same hyvid_embeds type as everywhere else in this pack, so it slots straight into any of the sampler nodes - nothing IP2V-specific downstream, the image conditioning is fully baked into the embedding by the time it leaves this node.

Where this actually earns its keep: character or style consistency across a generation, or nudging composition toward a reference without the heavier setup of ControlNet. It's a lighter-weight tool than a full image-conditioning pipeline, and it's worth trying before reaching for something more involved - especially since it's just two extra image inputs on a node you'd be using anyway.

Install and models are identical to the rest of the pack: ComfyUI Manager search for "HunyuanVideoWrapper," or git clone https://github.com/kijai/ComfyUI-HunyuanVideoWrapper into custom_nodes followed by pip install -r requirements.txt - don't skip that pip step, it's the most common reason people end up with the node pack installed but half the nodes missing. You need the same LLM text encoder (Llava-Llama-3-8B) and CLIP-L weights as HyVideoTextEncode; nothing extra for the image side, since the vision tokens ride through the same encoder rather than needing a separate vision model.

One thing to watch: because this node makes an extra forward pass through the encoder for each reference image, it's slower and a bit heavier on VRAM than the plain text-encode path - if you're already tight on memory, force_offload staying on (the default) and keeping model_to_offload wired to your diffusion model both help more here than they do on a text-only encode.

CategoryHunyuanVideoWrapper

Inputs (12)

NameTypeDefaultDescription
text_encodersHYVIDTEXTENCODER
promptSTRING
image_token_selection_exprSTRING::4
force_offloadoptBOOLEANtrue
prompt_templateoptCOMBOvideoUse the default prompt templates for the llm text encoder
custom_prompt_templateoptPROMPT_TEMPLATE[object Object]
clip_loptCLIPUse comfy clip model instead, in this case the text encoder loader's clip_l should be disabled
image1optIMAGE
image2optIMAGE
clip_text_overrideoptSTRING
hyvid_cfgoptHYVID_CFG
model_to_offloadoptHYVIDEOMODELModel to move to offload_device before encoding

Outputs (1)

NameTypeDescription
hyvid_embedsHYVIDEMBEDS