Wan 2.7 Video Editing
Validation
mkdir -p output/aliyun-wan-videoedit
python -m py_compile skills/ai/video/aliyun-wan-videoedit/scripts/edit_video.py && echo "py_compile_ok" > output/aliyun-wan-videoedit/validate.txt
Pass criteria: command exits 0 and output/aliyun-wan-videoedit/validate.txt is generated.
Output And Evidence
- Save task IDs, polling responses, and final video URLs to
output/aliyun-wan-videoedit/.
- Keep at least one end-to-end run log for troubleshooting.
Prerequisites
- Install SDK (recommended in a venv):
python3 -m venv .venv
. .venv/bin/activate
python -m pip install dashscope
- Set
DASHSCOPE_API_KEY in your environment, or add dashscope_api_key to ~/.alibabacloud/credentials.
Critical model names
wan2.7-videoedit — supports style transfer and instruction-based video editing
Capabilities
| Capability |
Description |
Required media |
| Style transfer |
Convert video to a different visual style (clay, anime, etc.) |
video only |
| Instruction editing |
Edit video content with text instructions and optional reference images |
video + optional reference_image (up to 3) |
API endpoint (async only)
POST https://dashscope.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
Required headers:
Authorization: Bearer $DASHSCOPE_API_KEY
Content-Type: application/json
X-DashScope-Async: enable
Singapore endpoint: replace dashscope.aliyuncs.com with dashscope-intl.aliyuncs.com.
Normalized interface
Request
prompt (string, optional) — up to 5000 characters, describes desired editing
negative_prompt (string, optional) — up to 500 characters
media (array, required) — media objects with type and url fields:
type: video (required, exactly 1) | reference_image (optional, up to 3)
url: public URL (HTTP/HTTPS) or OSS temporary URL
resolution (string, optional) — 720P or 1080P (default: 1080P)
ratio (string, optional) — output aspect ratio: 16:9, 9:16, 1:1, 4:3, 3:4. If omitted, follows input video ratio.
duration (integer, optional) — truncate input video to this length in seconds, range [2, 10]. Default 0 (use input video duration).
audio_setting (string, optional) — auto (default, AI decides) or origin (keep original audio)
prompt_extend (boolean, optional) — AI prompt rewriting (default: true)
watermark (boolean, optional) — add "AI generated" watermark (default: false)
seed (integer, optional) — range [0, 2147483647]
Media input limits
Video (type=video):
- Formats: mp4, mov
- Duration: 2-10s
- Resolution: [240, 4096] pixels per side
- Aspect ratio: 1:8 to 8:1
- Max size: 100MB
Reference images (type=reference_image):
- Formats: JPEG, JPG, PNG (no transparency), BMP, WEBP
- Resolution: [240, 8000] pixels per side
- Aspect ratio: 1:8 to 8:1
- Max size: 20MB
- Maximum 3 reference images
Resolution output table
| Resolution |
Ratio |
Output (W*H) |
| 720P |
16:9 |
1280*720 |
| 720P |
9:16 |
720*1280 |
| 720P |
1:1 |
960*960 |
| 720P |
4:3 |
1104*832 |
| 720P |
3:4 |
832*1104 |
| 1080P |
16:9 |
1920*1080 |
| 1080P |
9:16 |
1080*1920 |
| 1080P |
1:1 |
1440*1440 |
| 1080P |
4:3 |
1648*1248 |
| 1080P |
3:4 |
1248*1648 |
Response (task creation)
output.task_id (string) — use for polling, valid 24 hours
output.task_status (string) — PENDING | RUNNING | SUCCEEDED | FAILED | CANCELED
request_id (string)
Response (task result)
output.video_url (string) — edited video URL
usage.video_count (integer)
usage.video_duration (integer) — duration in seconds
Quick start (Python + HTTP)
import os
import json
import time
import requests
API_KEY = os.getenv("DASHSCOPE_API_KEY")
BASE_URL = "https://dashscope.aliyuncs.com/api/v1"
def create_videoedit_task(req: dict) -> str:
"""Create a video editing task and return task_id."""
payload = {
"model": "wan2.7-videoedit",
"input": {
"prompt": req.get("prompt", ""),
"media": req["media"],
},
"parameters": {
"resolution": req.get("resolution", "1080P"),
"prompt_extend": req.get("prompt_extend", True),
"watermark": req.get("watermark", False),
},
}
if req.get("negative_prompt"):
payload["input"]["negative_prompt"] = req["negative_prompt"]
if req.get("ratio"):
payload["parameters"]["ratio"] = req["ratio"]
if req.get("duration"):
payload["parameters"]["duration"] = req["duration"]
if req.get("audio_setting"):
payload["parameters"]["audio_setting"] = req["audio_setting"]
if req.get("seed") is not None:
payload["parameters"]["seed"] = req["seed"]
resp = requests.post(
f"{BASE_URL}/services/aigc/video-generation/video-synthesis",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
"X-DashScope-Async": "enable",
},
json=payload,
)
resp.raise_for_status()
data = resp.json()
return data["output"]["task_id"]
def poll_task(task_id: str, interval: int = 15) -> dict:
"""Poll until task completes. Returns final response."""
while True:
resp = requests.get(
f"{BASE_URL}/tasks/{task_id}",
headers={"Authorization": f"Bearer {API_KEY}"},
)
resp.raise_for_status()
data = resp.json()
status = data["output"]["task_status"]
if status in ("SUCCEEDED", "FAILED", "CANCELED"):
return data
time.sleep(interval)
Usage examples
# Style transfer — convert to clay style
media = [{"type": "video", "url": "https://example.com/input.mp4"}]
task_id = create_videoedit_task({
"prompt": "将整个画面转换为黏土风格",
"media": media,
"resolution": "720P",
})
# Instruction editing with reference image
media = [
{"type": "video", "url": "https://example.com/input.mp4"},
{"type": "reference_image", "url": "https://example.com/hat.jpg"},
]
task_id = create_videoedit_task({
"prompt": "为人物换上酷闪的衣服,再戴参考图里的帽子",
"media": media,
"audio_setting": "origin",
})
Error handling
| Error |
Likely cause |
Action |
| 401/403 |
Missing or invalid DASHSCOPE_API_KEY |
Check env var or credentials file |
400 InvalidParameter |
Bad resolution, missing video, too many reference images |
Validate parameters |
| "does not support synchronous calls" |
Missing X-DashScope-Async: enable header |
Add required header |
| 429 |
Rate limit or quota |
Retry with backoff |
Output location
- Default output:
output/aliyun-wan-videoedit/videos/
- Override base dir with
OUTPUT_DIR.
Anti-patterns
- Do not use model names other than
wan2.7-videoedit.
- Do not call this API synchronously — async header is required.
- Do not pass more than 1 video or more than 3 reference images.
- Video URLs expire after 24 hours; download and persist immediately.
- Do not use this API for video generation — use
aliyun-wan-i2v instead.
Workflow
- Confirm user intent: style transfer or instruction-based editing.
- Prepare media array with video (required) and optional reference images.
- Create async task and poll for results.
- Download and save edited video before URL expiration.
References
- See
references/api_reference.md for full HTTP API details.
- See
references/sources.md for source links.
1---2name: aliyun-wan-videoedit3description: Use when editing videos with DashScope Wan 2.7 video editing model (wan2.7-videoedit). Use when implementing video style transfer, instruction-based video editing with optional reference images, or video content modification via the video-synthesis async API.4---5
6# Wan 2.7 Video Editing
7
8## Validation
9
10```bash
11mkdir -p output/aliyun-wan-videoedit
12python -m py_compile skills/ai/video/aliyun-wan-videoedit/scripts/edit_video.py && echo "py_compile_ok" > output/aliyun-wan-videoedit/validate.txt
13```
14
15Pass criteria: command exits 0 and `output/aliyun-wan-videoedit/validate.txt` is generated.
16
17## Output And Evidence
18
19- Save task IDs, polling responses, and final video URLs to `output/aliyun-wan-videoedit/`.
20- Keep at least one end-to-end run log for troubleshooting.
21
22## Prerequisites
23
24- Install SDK (recommended in a venv):
25
26```bash
27python3 -m venv .venv
28. .venv/bin/activate
29python -m pip install dashscope
30```
31- Set `DASHSCOPE_API_KEY` in your environment, or add `dashscope_api_key` to `~/.alibabacloud/credentials`.
32
33## Critical model names
34
35- `wan2.7-videoedit` — supports style transfer and instruction-based video editing
36
37## Capabilities
38
39| Capability | Description | Required media |
40|---|---|---|
41| Style transfer | Convert video to a different visual style (clay, anime, etc.) | `video` only |
42| Instruction editing | Edit video content with text instructions and optional reference images | `video` + optional `reference_image` (up to 3) |
43
44## API endpoint (async only)
45
46```
47POST https://dashscope.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
48```
49
50Required headers:
51- `Authorization: Bearer $DASHSCOPE_API_KEY`
52- `Content-Type: application/json`
53- `X-DashScope-Async: enable`
54
55Singapore endpoint: replace `dashscope.aliyuncs.com` with `dashscope-intl.aliyuncs.com`.
56
57## Normalized interface
58
59### Request
60- `prompt` (string, optional) — up to 5000 characters, describes desired editing
61- `negative_prompt` (string, optional) — up to 500 characters
62- `media` (array, required) — media objects with `type` and `url` fields:
63 - `type`: `video` (required, exactly 1) | `reference_image` (optional, up to 3)
64 - `url`: public URL (HTTP/HTTPS) or OSS temporary URL
65- `resolution` (string, optional) — `720P` or `1080P` (default: `1080P`)
66- `ratio` (string, optional) — output aspect ratio: `16:9`, `9:16`, `1:1`, `4:3`, `3:4`. If omitted, follows input video ratio.
67- `duration` (integer, optional) — truncate input video to this length in seconds, range [2, 10]. Default `0` (use input video duration).
68- `audio_setting` (string, optional) — `auto` (default, AI decides) or `origin` (keep original audio)
69- `prompt_extend` (boolean, optional) — AI prompt rewriting (default: true)
70- `watermark` (boolean, optional) — add "AI generated" watermark (default: false)
71- `seed` (integer, optional) — range [0, 2147483647]
72
73### Media input limits
74
75**Video** (type=video):
76- Formats: mp4, mov
77- Duration: 2-10s
78- Resolution: [240, 4096] pixels per side
79- Aspect ratio: 1:8 to 8:1
80- Max size: 100MB
81
82**Reference images** (type=reference_image):
83- Formats: JPEG, JPG, PNG (no transparency), BMP, WEBP
84- Resolution: [240, 8000] pixels per side
85- Aspect ratio: 1:8 to 8:1
86- Max size: 20MB
87- Maximum 3 reference images
88
89### Resolution output table
90
91| Resolution | Ratio | Output (W*H) |
92|---|---|---|
93| 720P | 16:9 | 1280*720 |
94| 720P | 9:16 | 720*1280 |
95| 720P | 1:1 | 960*960 |
96| 720P | 4:3 | 1104*832 |
97| 720P | 3:4 | 832*1104 |
98| 1080P | 16:9 | 1920*1080 |
99| 1080P | 9:16 | 1080*1920 |
100| 1080P | 1:1 | 1440*1440 |
101| 1080P | 4:3 | 1648*1248 |
102| 1080P | 3:4 | 1248*1648 |
103
104### Response (task creation)
105- `output.task_id` (string) — use for polling, valid 24 hours
106- `output.task_status` (string) — PENDING | RUNNING | SUCCEEDED | FAILED | CANCELED
107- `request_id` (string)
108
109### Response (task result)
110- `output.video_url` (string) — edited video URL
111- `usage.video_count` (integer)
112- `usage.video_duration` (integer) — duration in seconds
113
114## Quick start (Python + HTTP)
115
116```python
117import os
118import json
119import time
120import requests
121
122API_KEY = os.getenv("DASHSCOPE_API_KEY")
123BASE_URL = "https://dashscope.aliyuncs.com/api/v1"
124
125def create_videoedit_task(req: dict) -> str:
126 """Create a video editing task and return task_id."""
127 payload = {
128 "model": "wan2.7-videoedit",
129 "input": {
130 "prompt": req.get("prompt", ""),
131 "media": req["media"],
132 },
133 "parameters": {
134 "resolution": req.get("resolution", "1080P"),
135 "prompt_extend": req.get("prompt_extend", True),
136 "watermark": req.get("watermark", False),
137 },
138 }
139 if req.get("negative_prompt"):
140 payload["input"]["negative_prompt"] = req["negative_prompt"]
141 if req.get("ratio"):
142 payload["parameters"]["ratio"] = req["ratio"]
143 if req.get("duration"):
144 payload["parameters"]["duration"] = req["duration"]
145 if req.get("audio_setting"):
146 payload["parameters"]["audio_setting"] = req["audio_setting"]
147 if req.get("seed") is not None:
148 payload["parameters"]["seed"] = req["seed"]
149
150 resp = requests.post(
151 f"{BASE_URL}/services/aigc/video-generation/video-synthesis",
152 headers={
153 "Authorization": f"Bearer {API_KEY}",
154 "Content-Type": "application/json",
155 "X-DashScope-Async": "enable",
156 },
157 json=payload,
158 )
159 resp.raise_for_status()
160 data = resp.json()
161 return data["output"]["task_id"]
162
163
164def poll_task(task_id: str, interval: int = 15) -> dict:
165 """Poll until task completes. Returns final response."""
166 while True:
167 resp = requests.get(
168 f"{BASE_URL}/tasks/{task_id}",
169 headers={"Authorization": f"Bearer {API_KEY}"},
170 )
171 resp.raise_for_status()
172 data = resp.json()
173 status = data["output"]["task_status"]
174 if status in ("SUCCEEDED", "FAILED", "CANCELED"):
175 return data
176 time.sleep(interval)
177```
178
179## Usage examples
180
181```python
182# Style transfer — convert to clay style
183media = [{"type": "video", "url": "https://example.com/input.mp4"}]
184task_id = create_videoedit_task({
185 "prompt": "将整个画面转换为黏土风格",
186 "media": media,
187 "resolution": "720P",
188})
189
190# Instruction editing with reference image
191media = [
192 {"type": "video", "url": "https://example.com/input.mp4"},
193 {"type": "reference_image", "url": "https://example.com/hat.jpg"},
194]
195task_id = create_videoedit_task({
196 "prompt": "为人物换上酷闪的衣服,再戴参考图里的帽子",
197 "media": media,
198 "audio_setting": "origin",
199})
200```
201
202## Error handling
203
204| Error | Likely cause | Action |
205|---|---|---|
206| 401/403 | Missing or invalid `DASHSCOPE_API_KEY` | Check env var or credentials file |
207| 400 `InvalidParameter` | Bad resolution, missing video, too many reference images | Validate parameters |
208| "does not support synchronous calls" | Missing `X-DashScope-Async: enable` header | Add required header |
209| 429 | Rate limit or quota | Retry with backoff |
210
211## Output location
212
213- Default output: `output/aliyun-wan-videoedit/videos/`
214- Override base dir with `OUTPUT_DIR`.
215
216## Anti-patterns
217
218- Do not use model names other than `wan2.7-videoedit`.
219- Do not call this API synchronously — async header is required.
220- Do not pass more than 1 video or more than 3 reference images.
221- Video URLs expire after 24 hours; download and persist immediately.
222- Do not use this API for video generation — use `aliyun-wan-i2v` instead.
223
224## Workflow
225
2261) Confirm user intent: style transfer or instruction-based editing.
2272) Prepare media array with video (required) and optional reference images.
2283) Create async task and poll for results.
2294) Download and save edited video before URL expiration.
230
231## References
232
233- See `references/api_reference.md` for full HTTP API details.
234- See `references/sources.md` for source links.