[节点详解](/zh/comfyui-nodes "节点详解")[Conditioning](/zh/comfyui-nodes/conditioning/3d-models "Conditioning")[video-models](/zh/comfyui-nodes/conditioning/video-models/svd-img2vid-conditioning "video-models")WanFunControlToVideo

### [Qwen-Image-Layered 发布 - 支持图像分层编辑的生成模型](/zh/news/2025-12-19-qwen-image-layered-release)

2025/12/19

# ComfyUI WanFunControlToVideo 节点

![ComfyUI WanFunControlToVideo 节点](images/e15279e1063ccc5321e719edfde7729a.jpg)

该节点是为了支持阿里巴巴的 Wan Fun Control 模型而添加的,用于视频生成,并在 [此提交](https://github.com/comfyanonymous/ComfyUI/commit/3661c833bcc41b788a7c9f0e7bc48524f8ee5f82) 之后添加。

* **目的:** 准备使用 Wan 2.1 Fun Control 模型进行视频生成所需的条件信息。

WanFunControlToVideo 节点是 ComfyUI 的一个附加功能,旨在支持用于视频生成的 Wan Fun Control 模型,旨在利用 WanFun 控制进行视频创作。

该节点作为准备必要条件信息的起点,并初始化潜在空间的中心点,指导后续使用 Wan 2.1 Fun 模型的视频生成过程。节点的名称清楚地表明了其功能:它接受各种输入并将其转换为适合在 WanFun 框架内控制视频生成的格式。

该节点在 ComfyUI 节点层次结构中的位置表明,它在视频生成管道的早期阶段操作,专注于在实际采样或解码视频帧之前操纵条件信号。

## WanFunControlToVideo 节点详细分析

### 输入参数

参数名称| 必需| 数据类型| 描述| 默认值
---|---|---|---|---
positive| 是| CONDITIONING| 标准 ComfyUI 正条件数据,通常来自“CLIP Text Encode”节点。正提示描述用户设想的生成视频的内容、主题和艺术风格。| N/A
negative| 是| CONDITIONING| 标准 ComfyUI 负条件数据,通常由“CLIP Text Encode”节点生成。负提示指定用户希望在生成视频中避免的元素、风格或伪影。| N/A
vae| 是| VAE| 需要与 Wan 2.1 Fun 模型系列兼容的 VAE(变分自编码器)模型,用于编码和解码图像/视频数据。| N/A
width| 是| INT| 输出视频帧的期望宽度(以像素为单位),默认值为 832,最小值为 16,最大值由 nodes.MAX_RESOLUTION 决定,步长为 16。| 832
height| 是| INT| 输出视频帧的期望高度(以像素为单位),默认值为 480,最小值为 16,最大值由 nodes.MAX_RESOLUTION 决定,步长为 16。| 480
length| 是| INT| 生成视频中的总帧数,默认值为 81,最小值为 1,最大值由 nodes.MAX_RESOLUTION 决定,步长为 4。| 81
batch_size| 是| INT| 一次生成的视频数量,默认值为 1,最小值为 1,最大值为 4096。| 1
clip_vision_output| 否| CLIP_VISION_OUTPUT| (可选)由 CLIP 视觉模型提取的视觉特征,允许进行视觉风格和内容指导。| 无
start_image| 否| IMAGE| (可选)影响生成视频开头的初始图像。| 无
control_video| 否| IMAGE| (可选)允许用户提供经过预处理的 ControlNet 参考视频,以指导生成视频的运动和潜在结构。| 无

### 输出参数

参数名称| 数据类型| 描述
---|---|---
positive| CONDITIONING| 提供增强的正条件数据,包括编码的 start_image 和 control_video。
negative| CONDITIONING| 提供同样增强的负条件数据,包含相同的 concat_latent_image。
latent| LATENT| 一个字典,包含一个空的潜在张量,键为“samples”。

## 节点示例工作流

请访问 [Wan Fun Control 节点示例工作流程](/zh/tutorial/advanced/video/wan2.1/fun-control) 以了解 ComfyUI 如何原生支持 Wan Fun Control 模型。

## 节点源代码

节点源代码,代码版本 [3661c833bcc41b788a7c9f0e7bc48524f8ee5f82](https://github.com/comfyanonymous/ComfyUI/commit/3661c833bcc41b788a7c9f0e7bc48524f8ee5f82)

class WanFunControlToVideo:
@classmethod
def INPUT_TYPES(s):
return {"required": {"positive": ("CONDITIONING", ),
"negative": ("CONDITIONING", ),
"vae": ("VAE", ),
"width": ("INT", {"default": 832, "min": 16, "max": nodes.MAX_RESOLUTION, "step": 16}),
"height": ("INT", {"default": 480, "min": 16, "max": nodes.MAX_RESOLUTION, "step": 16}),
"length": ("INT", {"default": 81, "min": 1, "max": nodes.MAX_RESOLUTION, "step": 4}),
"batch_size": ("INT", {"default": 1, "min": 1, "max": 4096}),
},
"optional": {"clip_vision_output": ("CLIP_VISION_OUTPUT", ),
"start_image": ("IMAGE", ),
"control_video": ("IMAGE", ),
}}

RETURN_TYPES = ("CONDITIONING", "CONDITIONING", "LATENT")
RETURN_NAMES = ("positive", "negative", "latent")
FUNCTION = "encode"

CATEGORY = "conditioning/video_models"

def encode(self, positive, negative, vae, width, height, length, batch_size, start_image=None, clip_vision_output=None, control_video=None):
latent = torch.zeros([batch_size, 16, ((length - 1) // 4) + 1, height // 8, width // 8], device=comfy.model_management.intermediate_device())
concat_latent = torch.zeros([batch_size, 16, ((length - 1) // 4) + 1, height // 8, width // 8], device=comfy.model_management.intermediate_device())
concat_latent = comfy.latent_formats.Wan21().process_out(concat_latent)
concat_latent = concat_latent.repeat(1, 2, 1, 1, 1)

if start_image is not None:
start_image = comfy.utils.common_upscale(start_image[:length].movedim(-1, 1), width, height, "bilinear", "center").movedim(1, -1)
concat_latent_image = vae.encode(start_image[:, :, :, :3])
concat_latent[:,16:,:concat_latent_image.shape[2]] = concat_latent_image[:,:,:concat_latent.shape[2]]

if control_video is not None:
control_video = comfy.utils.common_upscale(control_video[:length].movedim(-1, 1), width, height, "bilinear", "center").movedim(1, -1)
concat_latent_image = vae.encode(control_video[:, :, :, :3])
concat_latent[:,:16,:concat_latent_image.shape[2]] = concat_latent_image[:,:,:concat_latent.shape[2]]

positive = node_helpers.conditioning_set_values(positive, {"concat_latent_image": concat_latent})
negative = node_helpers.conditioning_set_values(negative, {"concat_latent_image": concat_latent})

if clip_vision_output is not None:
positive = node_helpers.conditioning_set_values(positive, {"clip_vision_output": clip_vision_output})
negative = node_helpers.conditioning_set_values(negative, {"clip_vision_output": clip_vision_output})

out_latent = {}
out_latent["samples"] = latent
return (positive, negative, out_latent)

### encode 函数分析

WanFunControlToVideo 节点中的 encode 函数负责将输入参数转换为条件信息和潜在空间,这些信息将被后续的视频生成模型使用。

该函数首先初始化一个名为 latent 的空潜在张量,具有特定的形状:[batch_size, 16, ((length - 1) // 4) + 1, height // 8, width // 8]。该张量被放置在 comfy.model_management.intermediate_device() 上,通常是可用的 GPU。接下来,另一个与 latent 形状相同的潜在张量 concat_latent 被初始化,用于存储来自可选的 start_image 和 control_video 输入的编码信息。

在处理可选的视觉输入后,concat_latent 张量现在包含来自 start_image 和 control_video(如果提供)的编码信息,并通过 node_helpers.conditioning_set_values 函数将其添加到正向和负向条件信息中的 “concat_latent_image” 键下。

最后,函数检查是否提供了 clip_vision_output。如果提供了,它也会被添加到正向和负向条件中的 “clip_vision_output” 键下。这使得由 CLIP 模型提取的视觉特征能够进一步优化生成过程。

## 额外的 Wan Fun Control 相关内容

WanFun Control 主要与 Wan 2.1 模型系列一起使用。该方法受到 ControlNet 的启发,ControlNet 是一种广泛用于图像生成的强大技术,通过各种空间和结构输入来调节输出。WanFun Control 将这些原则扩展到视频的时间域,使用户能够对生成的视频内容产生较高的影响,超越纯文本驱动方法的局限。它利用从输入视频中提取的视觉信息(例如深度图、边缘轮廓(Canny)或人体姿势(OpenPose))来促进受控视频的创建。

Wan 2.1 模型系列是 WanFun Control 的基础,提供了包括 1.3B 和 14B 模型在内的不同参数变体,为用户提供了在计算资源与所需输出质量和复杂性之间取得平衡的选项。

WanFun Control 的基本概念是利用参考视频中的视觉线索来指导 AI 的创作过程。用户可以提供一个“控制视频”,该视频体现了所需的运动或空间排列,而不仅仅依赖文本提示来确定生成视频的运动、结构和风格。这使得创建具有特定特征的视频变得更加直接和直观。例如,用户可能提供一个人走路的视频,而 WanFun Control 系统将生成一个不同主体执行相同走路动作的新视频,同时遵循文本提示中对主体外观和整体场景的描述。这种将视觉数据与文本描述相结合的结构化视频生成方法,能够实现更高的运动准确性、改善的风格化效果以及更有意图的视觉转换能力。

## 相关模型和代码库

* [Wan-Video/Wan2.1: 开放和先进的大规模视频生成模型](https://github.com/Wan-Video/Wan2.1)
* [Wan2.1-Fun-1.3B-Control](https://huggingface.co/alibaba-pai/Wan2.1-Fun-1.3B-Control)
* [Wan2.1-Fun-14B-Control](https://huggingface.co/alibaba-pai/Wan2.1-Fun-14B-Control)
* [VideoX-Fun](https://github.com/aigc-apps/VideoX-Fun)

[SVD_图像到视频_条件节点](/zh/comfyui-nodes/conditioning/video-models/svd-img2vid-conditioning "SVD_图像到视频_条件节点")[Save Animated PNG - 保存APNG](/zh/comfyui-nodes/image/animation/save-animated-png "Save Animated PNG - 保存APNG")

主题授权提示:请在后台主题设置-主题授权-激活主题的正版授权,授权购买:RiTheme官网

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。