Wan2.1 VACE 擴圖
透過使用Wan萬相擴圖擴充影片尺寸,產生延展影片。
關於
This ComfyUI workflow teaches you how to outpaint a video—expanding its canvas while keeping the original content intact—using Wan 2.1 VACE. It loads your source clip with LoadVideo and extracts dimensions and frame count via GetVideoComponents and PreviewImage. You then define where to expand using ImagePadForOutpaint and a mask built from ImageToMask/MaskToImage, replicated across time with RepeatImageBatch. Prompts are encoded with CLIPTextEncode, and generation runs through KSampler with ModelSamplingSD3 scheduling on a Wan 2.1 VACE UNet/Decoder stack (UNETLoader, VAELoader), with VAEDecode converting latents to frames.
WanVaceToVideo handles video-specific conditioning, and TrimVideoLatent ensures temporal shapes align. The result is assembled with CreateVideo and saved via SaveVideo.
Technically, two alignment rules matter for stable inference: the spatial size you set for outpainting must be divisible by 16 (a constraint of WanVaceToVideo and the VAE), and the sequence length must satisfy the temporal constraint (Length - 1 divisible by 4), which TrimVideoLatent addresses. Because core Comfy nodes don’t yet expose video size/frame-count utilities, this template uses PreviewImage as a practical workaround; you can swap in custom utility nodes if available.
The workflow includes model groups for Wan2.1-VACE-1.3B (lighter, recommended for 480p) and Wan2.1-VACE-14B (higher quality, suitable for higher resolutions like 720p if resources allow). Default generation settings are steps: 20 and cfg: 6.0, with optional CausVid LoRA tuning at steps: 2–4 and cfg: 1.0.
您提供的內容
- 正在讀取工作流程
在 ComfyUI 中執行。 此工作流程無法在此頁面上執行。請在已載入所有內容的 Comfy Cloud 中開啟,或下載到您自己的 ComfyUI。
在 Cloud 中試用工作流程內部
節點圖的唯讀預覽。請在 Comfy Cloud 中開啟,或下載後編輯節點。
Loading the graph
Open full-size workflow preview從程式碼使用此工作流程
可行時會根據工作流程圖和輸入內容產生;否則會顯示儲存的範例。執行可能產生費用的程式碼前,請檢查認證資訊和端點。
What you need
- Runs on
- Comfy Cloud
- 金鑰
- COMFY_API_KEY
需要付費 Cloud 方案與點數。
# Python 3.10+: pip install comfy-sdk==0.4.0
import os
from comfy_sdk import Comfy
api_key = os.environ.get("COMFY_API_KEY", "").strip()
if not api_key: raise RuntimeError("Set COMFY_API_KEY")
os.environ.setdefault("COMFY_BASE_URL", "https://cloud.comfy.org")
client = Comfy(api_key=api_key)
workflow = client.workflows.from_json({
"3": {
"class_type": "KSampler",
"inputs": {
"cfg": 1,
"denoise": 1,
"latent_image": [
"49",
2
],
"model": [
"48",
0
],
"negative": [
"49",
1
],
"positive": [
"49",
0
],
"sampler_name": "uni_pc",
"scheduler": "simple",
"seed": 776767434080331,
"steps": 3
},
"_meta": {
"title": "KSampler"
}
},
"6": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"165",
1
],
"text": "A portrait of a woman with her eyes closed, her head surrounded by white transparent glass flowers, with only her face exposed. The camera slowly moves in, and the girl smiles. There are other transparent glass flowers in the style of Nicoletta Ceccoli around her. The detailed painting features natural light and soft lighting, creating a beautiful, surreal, and emotionally expressive movie scene.\n"
},
"_meta": {
"title": "CLIP Text Encode (Positive Prompt)"
}
},
"7": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"165",
1
],
"text": "bad quality, blurry, messy, chaotic"
},
"_meta": {
"title": "CLIP Text Encode (Negative Prompt)"
}
},
"8": {
"class_type": "VAEDecode",
"inputs": {
"samples": [
"58",
0
],
"vae": [
"152",
0
]
},
"_meta": {
"title": "VAE Decode"
}
},
"48": {
"class_type": "ModelSamplingSD3",
"inputs": {
"model": [
"165",
0
],
"shift": 8.000000000000002
},
"_meta": {
"title": "ModelSamplingSD3"
}
},
"49": {
"class_type": "WanVaceToVideo",
"inputs": {
"batch_size": 1,
"control_masks": [
"130",
0
],
"control_video": [
"110",
0
],
"height": [
"139",
0
],
"length": [
"131",
0
],
"negative": [
"7",
0
],
"positive": [
"6",
0
],
"strength": 1,
"vae": [
"152",
0
],
"width": [
"137",
0
]
},
"_meta": {
"title": "WanVaceToVideo"
}
},
"58": {
"class_type": "TrimVideoLatent",
"inputs": {
"samples": [
"3",
0
],
"trim_amount": [
"49",
3
]
},
"_meta": {
"title": "Trim Video Latent"
}
},
"68": {
"class_type": "CreateVideo",
"inputs": {
"bit_depth": "auto",
"codec": "none",
"color_space": "sRGB",
"fps": 16,
"images": [
"8",
0
]
},
"_meta": {
"title": "Create Video"
}
},
"69": {
"class_type": "SaveVideo",
"inputs": {
"filename_prefix": "video/ComfyUI",
"format": "auto",
"format.codec": "auto",
"video": [
"68",
0
]
},
"_meta": {
"title": "Save Video"
}
},
"71": {
"class_type": "LoadVideo",
"inputs": {
"file": "video_wan_vace_outpainting_input_video.mp4"
},
"_meta": {
"title": "Load Video"
}
},
"72": {
"class_type": "GetVideoComponents",
"inputs": {
"video": [
"71",
0
]
},
"_meta": {
"title": "Get Video Components"
}
},
"110": {
"class_type": "ImagePadForOutpaint",
"inputs": {
"bottom": 200,
"feathering": 0,
"image": [
"72",
0
],
"left": 120,
"right": 120,
"top": 120
},
"_meta": {
"title": "Pad Image for Outpainting"
}
},
"111": {
"class_type": "MaskToImage",
"inputs": {
"mask": [
"110",
1
]
},
"_meta": {
"title": "Convert Mask to Image"
}
},
"129": {
"class_type": "RepeatImageBatch",
"inputs": {
"amount": [
"131",
0
],
"image": [
"111",
0
]
},
"_meta": {
"title": "Repeat Image Batch"
}
},
"130": {
"class_type": "ImageToMask",
"inputs": {
"channel": "red",
"image": [
"129",
0
]
},
"_meta": {
"title": "Convert Image to Mask"
}
},
"131": {
"class_type": "PrimitiveInt",
"inputs": {
"value": 81
},
"_meta": {
"title": "Length"
}
},
"135": {
"class_type": "PreviewImage",
"inputs": {
"images": [
"110",
0
]
},
"_meta": {
"title": "Preview Image - Outpaint"
}
},
"137": {
"class_type": "PrimitiveInt",
"inputs": {
"value": 960
},
"_meta": {
"title": "Width"
}
},
"139": {
"class_type": "PrimitiveInt",
"inputs": {
"value": 960
},
"_meta": {
"title": "Height"
}
},
"143": {
"class_type": "PreviewImage",
"inputs": {
"images": [
"72",
0
]
},
"_meta": {
"title": "Preview Image - original"
}
},
"151": {
"class_type": "UNETLoader",
"inputs": {
"unet_name": "wan2.1_vace_14B_fp16.safetensors",
"weight_dtype": "default"
},
"_meta": {
"title": "Load Diffusion Model"
}
},
"152": {
"class_type": "VAELoader",
"inputs": {
"vae_name": "wan_2.1_vae.safetensors"
},
"_meta": {
"title": "Load VAE"
}
},
"161": {
"class_type": "CLIPLoader",
"inputs": {
"clip_name": "umt5_xxl_fp16.safetensors",
"device": "default",
"type": "wan"
},
"_meta": {
"title": "Load CLIP"
}
},
"165": {
"class_type": "LoraLoader",
"inputs": {
"clip": [
"161",
0
],
"lora_name": "Wan21_CausVid_14B_T2V_lora_rank32.safetensors",
"model": [
"151",
0
],
"strength_clip": 1,
"strength_model": 0.4000000000000001
},
"_meta": {
"title": "Load LoRA (Model and CLIP)"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)問答
WanVaceToVideo 與 VAE 會以 2 的次方下採樣,尺寸需對齊 16 才能產生乾淨潛變量。時序路徑要求(影格數-1)% 4 == 0。TrimVideoLatent 會自動處理時序,空間請自行設為 16 的倍數。
1.3B 適合較快運算與 480p 輸出,14B 適合高品質與高解析度(如 720p),但需較多 VRAM。14B 細節更佳但速度較慢。
用 ImagePadForOutpaint 增加指定邊緣畫布,再用遮罩(ImageToMask/MaskToImage)保護原區域,RepeatImageBatch 複製至每一影格。模型僅在未遮罩的新區域生成內容。
請檢查:1) 輸出寬高是否為 16 的倍數,2) 是否有用 TrimVideoLatent 校正(影格數-1 可被 4 整除),3) VAEDecode 是否連接於 CreateVideo/SaveVideo 前。也請確認 fps、影格數與遮罩長度一致。
相關工作流程
- Wan2.1, ChronoEdit, Nvidia
ChronoEdit 14B:圖像編輯
- Wan2.1, ChronoEdit, Nvidia
ChronoEdit 14B:圖像編輯
- Wan2.1, Wan
Wan 2.1 ControlNet
- Wan2.1, Wan
Wan 2.1 Fun Camera 1.3B
- Wan2.1, Wan
Wan 2.1 Fun Camera 14B
- Wan2.1, Wan
Wan 2.1 首尾幀影片 720p F16
- Wan2.1, Wan
Wan ATI
- Wan2.1, Wan
Wan VACE控制影片
- Wan2.1, Wan
Wan2.1 Alpha 文生影片
- Wan2.1, Wan
Wan2.1 VACE 區域性重繪
- Wan2.1, Wan
Wan2.1 VACE 參考生影片
- Wan2.1, Wan
Wan2.1 VACE 文生影片