跳转到主要内容
视频生成与编辑

通用视频编辑

重绘、延展与编辑

快捷链接:API 参考:wan2.7wan2.1

可用模型

支持的模型
模型功能输入模态输出视频规格
wan2.7-videoedit 推荐音频(自动/保留原声)、风格迁移、物体替换、参考图编辑文本、图片、视频分辨率:720P、1080P。时长:最长 10 秒。30 fps,MP4(H.264)
wan2.1-vace-plus视频无音频。多图参考、视频重绘、局部编辑、视频延展、画面扩展文本、图片、视频分辨率:720P。时长:最长 5 秒。30 fps,MP4(H.264 编码)

Wan 2.7 视频编辑

通过文本提示词和可选的参考图,以最高 1080P 分辨率编辑视频——支持风格转换、物体替换,以及将参考图中的内容迁移到源视频中。使用统一模型,无需设置 function 参数。

参数说明(wan2.7)

参数类型必选说明
modelstring"wan2.7-videoedit"
input.promptstring最多 5,000 字符。描述期望的编辑效果。
input.negative_promptstring最多 500 字符。需要排除的内容。
input.mediaarray必须包含一个 video 项。可选包含最多 4 个 reference_image 项。
parameters.resolutionstring"720P""1080P"(默认)。
parameters.ratiostring"16:9""9:16""1:1""4:3""3:4"。默认与输入视频比例一致。
parameters.durationinteger0 = 保持输入视频完整时长(默认)。2-10 = 截取输入视频指定时长。
parameters.audio_settingstring"auto"(默认,模型自动决定)或 "origin"(保留原声)。
parameters.prompt_extendboolean默认值:true
parameters.watermarkboolean默认值:false

示例:更改视频风格

  • curl
  • Python
第 1 步:创建任务
curl --location 'https://dashscope.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis' \
--header 'X-DashScope-Async: enable' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
  "model": "wan2.7-videoedit",
  "input": {
    "prompt": "Convert the entire scene to a claymation style",
    "media": [
      {
        "type": "video",
        "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260402/ldnfdf/wan2.7-videoedit-style-change.mp4"
      }
    ]
  },
  "parameters": {
    "resolution": "720P",
    "prompt_extend": true,
    "watermark": true
  }
}'
第 2 步:通过任务 ID 获取结果{task_id} 替换为上一步 API 返回的 task_id 值。
curl -X GET https://dashscope.aliyuncs.com/api/v1/tasks/{task_id} \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"

示例:使用参考图编辑

通过参考图替换视频中的物体:
curl --location 'https://dashscope.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis' \
--header 'X-DashScope-Async: enable' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
  "model": "wan2.7-videoedit",
  "input": {
    "prompt": "Replace the girl'\''s clothes in the video with the clothes from the image",
    "media": [
      {
        "type": "video",
        "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260403/nlspwm/T2VA_22.mp4"
      },
      {
        "type": "reference_image",
        "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260402/fwjpqf/wan2.7-videoedit-change-clothes.png"
      }
    ]
  },
  "parameters": {
    "resolution": "720P",
    "prompt_extend": true,
    "watermark": true
  }
}'

Wan 2.1 视频编辑(VACE)

wan2.1-vace-plus 模型支持 5 种专业编辑功能,通过 function 参数选择。

核心功能

多图参考

功能说明:支持最多 3 张参考图,涵盖主体和背景(人物、动物、服装、场景等)。模型将多张图片融合生成连贯的视频内容。 参数设置
  • function:必须设为 image_reference
  • ref_images_url:URL 数组,支持 1 到 3 张参考图。
  • obj_or_bg:标识每张图是主体(obj)还是背景(bg)。该数组长度必须与 ref_images_url 数组长度一致。
输入提示词输入参考图 1(主体参考)输入参考图 2(背景参考)输出视频
视频中,一位少女从古老而雾气弥漫的森林深处走出。她步伐轻盈,镜头捕捉着她每一个优雅的瞬间。当她停下脚步环顾四周郁郁葱葱的树木时,脸上绽放出惊喜与喜悦的微笑。这个光影交错的画面,记录了她与自然的美妙邂逅。
image
image
输出视频
调用 API 前,请先获取 API Key,然后将 API Key 设置为环境变量
  • curl
  • Python
  • Java
第 1 步:创建任务获取任务 ID
curl --location 'https://dashscope.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis' \
--header 'X-DashScope-Async: enable' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
  "model": "wan2.1-vace-plus",
  "input": {
    "function": "image_reference",
    "prompt": "In the video, a girl gracefully walks out from a misty, ancient forest. Her steps are light, and the camera captures her every nimble moment. When she stops and looks around at the lush woods, a smile of surprise and joy blossoms on her face. This scene, frozen in a moment of interplay between light and shadow, records her wonderful encounter with nature.",
    "ref_images_url": [
      "http://wanx.alicdn.com/material/20250318/image_reference_2_5_16.png",
      "http://wanx.alicdn.com/material/20250318/image_reference_1_5_16.png"
    ]
  },
  "parameters": {
    "prompt_extend": true,
    "obj_or_bg": ["obj","bg"],
    "size": "1280*720"
  }
}'
第 2 步:通过任务 ID 获取结果{task_id} 替换为上一步 API 返回的 task_id 值。
curl -X GET https://dashscope.aliyuncs.com/api/v1/tasks/{task_id} \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"

视频重绘

功能说明:从输入视频中提取主体的姿态和运动、构图和运动轮廓,或草图结构,然后结合文本提示词生成具有相同动态特征的新视频。也支持通过参考图替换主体。 参数设置
  • function:必须设为 video_repainting
  • video_url:必选。输入视频的 URL。必须为 MP4 格式,不超过 50 MB,时长不超过 5 秒。
  • control_condition:可选。视频特征提取方式,决定保留原视频的哪些特征:
    • posebodyface:提取面部表情和肢体动作,保留面部表情细节。
    • posebody:仅提取肢体动作,不含面部。仅控制身体运动。
    • depth:提取构图和运动轮廓,保留场景结构。
    • scribble:提取草图结构,保留草图边缘细节。
  • strength:可选。控制特征提取强度。范围:0.0--1.0。默认值:1.0。值越高,输出越接近原视频;值越低,创作自由度越大。
  • ref_images_url:可选。参考图的 URL,用于替换输入视频中的主体。
输入提示词输入视频输出视频
视频展示了一辆由绅士驾驶的黑色蒸汽朋克风格汽车,装饰着齿轮和铜管。背景是蒸汽动力糖果工厂,融合复古元素,营造出怀旧而趣味十足的场景。输入视频输出视频
  • curl
  • Python
  • Java
第 1 步:创建任务获取任务 ID
curl --location 'https://dashscope.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis' \
--header 'X-DashScope-Async: enable' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
  "model": "wan2.1-vace-plus",
  "input": {
    "function": "video_repainting",
    "prompt": "The video shows a black steampunk-style car driven by a gentleman. The car is decorated with gears and copper pipes. The background features a steam-powered candy factory and retro elements, creating a vintage and playful scene.",
    "video_url": "http://wanx.alicdn.com/material/20250318/video_repainting_1.mp4"
  },
  "parameters": {
    "prompt_extend": false,
    "control_condition": "depth"
  }
}'
第 2 步:通过任务 ID 获取结果{task_id} 替换为上一步 API 返回的 task_id 值。
curl -X GET https://dashscope.aliyuncs.com/api/v1/tasks/{task_id} \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"

局部编辑

功能说明:对视频指定区域进行精细编辑,支持添加、删除和修改元素,或替换主体和背景。上传蒙版图指定编辑区域——模型会自动跟踪目标并融合生成内容。 参数设置
  • function:必须设为 video_edit
  • video_url:必选。原始输入视频的 URL。
  • mask_image_url:可选。与 mask_video_url 二选一,推荐使用此参数。蒙版图的 URL。蒙版中白色区域为编辑区域,黑色区域保持不变。
  • mask_frame_id:可选。与 mask_image_url 配合使用,指定蒙版对应视频的哪一帧。默认为第一帧。
  • mask_type:可选。指定编辑区域的行为模式:
    • tracking(默认):编辑区域自动跟随目标的运动轨迹。
    • fixed:编辑区域保持固定位置。
  • expand_ratio:可选。仅在 mask_typetracking 时生效。
    • 蒙版区域向外扩展的比例。范围:0.0--1.0。默认值:0.05。
    • 值越小越贴合目标,值越大扩展区域越广。
  • size:可选。输出分辨率,格式为 宽*高(如 1280*720)。
  • ref_images_url:可选。参考图的 URL。编辑区域的内容将替换为参考图中的内容。
输入提示词输入视频输入蒙版图输出视频
视频展示了一家巴黎风格的法式咖啡馆,一只穿西装的狮子正优雅地品尝咖啡。它一只手端着咖啡杯轻轻啜饮,表情悠然自得。咖啡馆装饰考究,柔和的色调和温暖的灯光照亮了狮子所在的区域。输入视频
mask
白色区域为编辑区域。
输出视频
  • curl
  • Python
  • Java
第 1 步:创建任务获取任务 ID
curl --location 'https://dashscope.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis' \
--header 'X-DashScope-Async: enable' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
  "model": "wan2.1-vace-plus",
  "input": {
    "function": "video_edit",
    "prompt": "The video shows a Parisian-style French cafe where a lion in a suit is elegantly sipping coffee. It holds a coffee cup in one hand, taking a gentle sip with a relaxed expression. The cafe is tastefully decorated, with soft hues and warm lighting illuminating the area where the lion is.",
    "mask_image_url": "http://wanx.alicdn.com/material/20250318/video_edit_1_mask.png",
    "video_url": "http://wanx.alicdn.com/material/20250318/video_edit_2.mp4",
    "mask_frame_id": 1
  },
  "parameters": {
    "prompt_extend": false,
    "mask_type": "tracking",
    "expand_ratio": 0.05,
    "size": "1280*720"
  }
}'
第 2 步:通过任务 ID 获取结果{task_id} 替换为上一步 API 返回的 task_id 值。
curl -X GET https://dashscope.aliyuncs.com/api/v1/tasks/{task_id} \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"

视频延展

功能说明:基于输入的图片或视频片段,预测并生成连续内容。支持从首帧或首段片段向后延展,也支持从末帧或末段片段向前延展。生成的视频时长为 5 秒。 参数设置
  • function:必须设为 video_extension
  • prompt:必选。描述期望延展的内容。
  • first_clip_url:可选。首段视频片段的 URL(不超过 3 秒)。模型基于此片段生成后续视频。
  • last_clip_url:可选。末段视频片段的 URL(不超过 3 秒)。模型基于此片段生成前序内容。
  • first_frame_url:可选。首帧图片的 URL。视频从该帧向后延展。
  • last_frame_url:可选。末帧图片的 URL。视频从该帧向前生成。
first_clip_urllast_clip_urlfirst_frame_urllast_frame_url 至少指定其中一个。
输入提示词输入首段片段(1 秒)输出视频(延展后为 5 秒)
一只戴墨镜的狗在街上玩滑板,3D 卡通风格。输入视频输出视频
  • curl
  • Python
  • Java
第 1 步:创建任务获取任务 ID
curl --location 'https://dashscope.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis' \
--header 'X-DashScope-Async: enable' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
  "model": "wan2.1-vace-plus",
  "input": {
    "function": "video_extension",
    "prompt": "A dog wearing sunglasses is skateboarding on the street, 3D cartoon.",
    "first_clip_url": "http://wanx.alicdn.com/material/20250318/video_extension_1.mp4"
  },
  "parameters": {
    "prompt_extend": false
  }
}'
第 2 步:通过任务 ID 获取结果{task_id} 替换为上一步 API 返回的 task_id 值。
curl -X GET https://dashscope.aliyuncs.com/api/v1/tasks/{task_id} \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"

画面扩展

功能说明:基于提示词,将视频画面内容向四周(上、下、左、右)按比例扩展。保持视频主体的连续性,并确保与背景自然融合。 参数设置
  • function:必须设为 video_outpainting
  • video_url:必选。原始输入视频的 URL。
  • top_scale:可选。向上扩展比例。范围:1.0--2.0。默认值:1.0(不扩展)。
  • bottom_scale:可选。向下扩展比例。范围:1.0--2.0。默认值:1.0。
  • left_scale:可选。向左扩展比例。范围:1.0--2.0。默认值:1.0。
  • right_scale:可选。向右扩展比例。范围:1.0--2.0。默认值:1.0。
示例:将 left_scale 设为 1.5,表示画面左侧扩展为原始宽度的 1.5 倍。
输入提示词输入视频输出视频
一位优雅的女士正在热情地演奏小提琴,身后是一支完整的交响乐团输入视频输出视频
  • curl
  • Python
  • Java
第 1 步:创建任务获取任务 ID
curl --location 'https://dashscope.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis' \
--header 'X-DashScope-Async: enable' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
  "model": "wan2.1-vace-plus",
  "input": {
    "function": "video_outpainting",
    "prompt": "An elegant lady is passionately playing the violin, with a full symphony orchestra behind her.",
    "video_url": "http://wanx.alicdn.com/material/20250318/video_outpainting_1.mp4"
  },
  "parameters": {
    "prompt_extend": false,
    "top_scale": 1.5,
    "bottom_scale": 1.5,
    "left_scale": 1.5,
    "right_scale": 1.5
  }
}'
第 2 步:通过任务 ID 获取结果{task_id} 替换为上一步 API 返回的 task_id 值。
curl -X GET https://dashscope.aliyuncs.com/api/v1/tasks/{task_id} \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"

输入图片和视频

输入图片

  • 图片数量:参见上方各功能所需的数量说明。
  • 输入方式
    • 公开 URL:支持 HTTP 和 HTTPS 协议。示例:https://xxxx/xxx.png

输入视频

  • 视频数量:参见上方各功能所需的数量说明。
  • 输入方式
    • 公开 URL:支持 HTTP 和 HTTPS 协议。示例:https://xxxx/xxx.mp4

输出视频

  • 视频数量:1 个。
  • 格式:MP4。分辨率和尺寸详见下方视频规格说明。
  • URL 有效期**:24 小时**。
  • 尺寸:因所选功能而异。
    • 多图参考 / 局部编辑
      • 输出分辨率固定为 720P。
      • 具体宽高由 size 参数决定。
    • 视频重绘 / 视频延展 / 画面扩展
      • 输入视频分辨率为 720P 或更低时,输出分辨率与输入一致。
      • 输入视频分辨率高于 720P 时,输出等比缩放至 720P。

计费与限流

  • 免费额度和定价详见模型调用计费
  • 限流规则详见限流
  • 计费说明:
    • 输入免费。输出按成功生成的视频秒数计费。
    • 模型调用失败或处理异常不收费,也不消耗免费额度

API 参考

常见问题

多图参考最多支持几张图片?

最多支持 3 张参考图。超过 3 张时只取前 3 张。为获得最佳效果,建议主体图使用纯色背景以突出主体,背景图不要包含主体对象。

视频重绘何时应关闭提示词改写?

如果文本描述与输入视频内容不一致,模型可能会误解您的意图。此时建议手动关闭提示词改写,即设置 prompt_extend=false,并在提示词中提供清晰、具体的场景描述,以提高一致性和准确性。

局部编辑中蒙版图和蒙版视频的区别

通过 mask_image_url 指定蒙版图,或通过 mask_video_url 指定蒙版视频,二者选其一。推荐使用蒙版图,因为您只需在单帧中指定编辑区域,系统会自动跟踪目标。