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.
API
從程式碼使用此工作流
每個 Comfy 工作流都是一個 JSON 圖。下方的 payload 就是此工作流,與 ComfyUI 執行時完全相同 — 你可以從此 URL 取得、放入版本控制,或在 ComfyUI 載入並逐節點執行。
使用 Comfy SDK 以 TypeScript 或 Python 執行。相同程式碼可用於 Comfy Cloud 或你自架的 ComfyUI — 只需更改 base URL。
// Install (beta)
npm i @comfyorg/sdk
// Run "Wan2.1 VACE 擴圖" (TypeScript)
import { Comfy } from "@comfyorg/sdk";
const client = new Comfy({ apiKey: "comfyui-..." });
// This workflow, exported in API format (see note below)
const wf = await client.workflows.fromFile("video_wan_vace_outpainting_api.json");
wf.setInput("6", "text", "your prompt here"); // CLIPTextEncode
const job = await client.run(wf);
await job.getOutputs("69")[0].toFile("output.png"); // SaveVideoSDK 需使用 API 格式的工作流:請在 ComfyUI 開啟此工作流,並使用 檔案 → 匯出工作流(API)。
常見問題















