$npx -y skills add cinience/alicloud-skills --skill aliyun-wan-videoeditUse 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.
| 1 | # Wan 2.7 Video Editing |
| 2 | |
| 3 | ## Validation |
| 4 | |
| 5 | ```bash |
| 6 | mkdir -p output/aliyun-wan-videoedit |
| 7 | python -m py_compile skills/ai/video/aliyun-wan-videoedit/scripts/edit_video.py && echo "py_compile_ok" > output/aliyun-wan-videoedit/validate.txt |
| 8 | ``` |
| 9 | |
| 10 | Pass criteria: command exits 0 and `output/aliyun-wan-videoedit/validate.txt` is generated. |
| 11 | |
| 12 | ## Output And Evidence |
| 13 | |
| 14 | - Save task IDs, polling responses, and final video URLs to `output/aliyun-wan-videoedit/`. |
| 15 | - Keep at least one end-to-end run log for troubleshooting. |
| 16 | |
| 17 | ## Prerequisites |
| 18 | |
| 19 | - Install SDK (recommended in a venv): |
| 20 | |
| 21 | ```bash |
| 22 | python3 -m venv .venv |
| 23 | . .venv/bin/activate |
| 24 | python -m pip install dashscope |
| 25 | ``` |
| 26 | - Set `DASHSCOPE_API_KEY` in your environment, or add `dashscope_api_key` to `~/.alibabacloud/credentials`. |
| 27 | |
| 28 | ## Critical model names |
| 29 | |
| 30 | - `wan2.7-videoedit` — supports style transfer and instruction-based video editing |
| 31 | |
| 32 | ## Capabilities |
| 33 | |
| 34 | | Capability | Description | Required media | |
| 35 | |---|---|---| |
| 36 | | Style transfer | Convert video to a different visual style (clay, anime, etc.) | `video` only | |
| 37 | | Instruction editing | Edit video content with text instructions and optional reference images | `video` + optional `reference_image` (up to 3) | |
| 38 | |
| 39 | ## API endpoint (async only) |
| 40 | |
| 41 | ``` |
| 42 | POST https://dashscope.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis |
| 43 | ``` |
| 44 | |
| 45 | Required headers: |
| 46 | - `Authorization: Bearer $DASHSCOPE_API_KEY` |
| 47 | - `Content-Type: application/json` |
| 48 | - `X-DashScope-Async: enable` |
| 49 | |
| 50 | Singapore endpoint: replace `dashscope.aliyuncs.com` with `dashscope-intl.aliyuncs.com`. |
| 51 | |
| 52 | ## Normalized interface |
| 53 | |
| 54 | ### Request |
| 55 | - `prompt` (string, optional) — up to 5000 characters, describes desired editing |
| 56 | - `negative_prompt` (string, optional) — up to 500 characters |
| 57 | - `media` (array, required) — media objects with `type` and `url` fields: |
| 58 | - `type`: `video` (required, exactly 1) | `reference_image` (optional, up to 3) |
| 59 | - `url`: public URL (HTTP/HTTPS) or OSS temporary URL |
| 60 | - `resolution` (string, optional) — `720P` or `1080P` (default: `1080P`) |
| 61 | - `ratio` (string, optional) — output aspect ratio: `16:9`, `9:16`, `1:1`, `4:3`, `3:4`. If omitted, follows input video ratio. |
| 62 | - `duration` (integer, optional) — truncate input video to this length in seconds, range [2, 10]. Default `0` (use input video duration). |
| 63 | - `audio_setting` (string, optional) — `auto` (default, AI decides) or `origin` (keep original audio) |
| 64 | - `prompt_extend` (boolean, optional) — AI prompt rewriting (default: true) |
| 65 | - `watermark` (boolean, optional) — add "AI generated" watermark (default: false) |
| 66 | - `seed` (integer, optional) — range [0, 2147483647] |
| 67 | |
| 68 | ### Media input limits |
| 69 | |
| 70 | **Video** (type=video): |
| 71 | - Formats: mp4, mov |
| 72 | - Duration: 2-10s |
| 73 | - Resolution: [240, 4096] pixels per side |
| 74 | - Aspect ratio: 1:8 to 8:1 |
| 75 | - Max size: 100MB |
| 76 | |
| 77 | **Reference images** (type=reference_image): |
| 78 | - Formats: JPEG, JPG, PNG (no transparency), BMP, WEBP |
| 79 | - Resolution: [240, 8000] pixels per side |
| 80 | - Aspect ratio: 1:8 to 8:1 |
| 81 | - Max size: 20MB |
| 82 | - Maximum 3 reference images |
| 83 | |
| 84 | ### Resolution output table |
| 85 | |
| 86 | | Resolution | Ratio | Output (W*H) | |
| 87 | |---|---|---| |
| 88 | | 720P | 16:9 | 1280*720 | |
| 89 | | 720P | 9:16 | 720*1280 | |
| 90 | | 720P | 1:1 | 960*960 | |
| 91 | | 720P | 4:3 | 1104*832 | |
| 92 | | 720P | 3:4 | 832*1104 | |
| 93 | | 1080P | 16:9 | 1920*1080 | |
| 94 | | 1080P | 9:16 | 1080*1920 | |
| 95 | | 1080P | 1:1 | 1440*1440 | |
| 96 | | 1080P | 4:3 | 1648*1248 | |
| 97 | | 1080P | 3:4 | 1248*1648 | |
| 98 | |
| 99 | ### Response (task creation) |
| 100 | - `output.task_id` (string) — use for polling, valid 24 hours |
| 101 | - `output.task_status` (string) — PENDING | RUNNING | SUCCEEDED | FAILED | CANCELED |
| 102 | - `request_id` (string) |
| 103 | |
| 104 | ### Response (task result) |
| 105 | - `output.video_url` (string) — edited video URL |
| 106 | - `usage.video_count` (integer) |
| 107 | - `usage.video_duration` (integer) — duration in seconds |
| 108 | |
| 109 | ## Quick start (Python + HTTP) |
| 110 | |
| 111 | ```python |
| 112 | import os |
| 113 | import json |
| 114 | import time |
| 115 | import requests |
| 116 | |
| 117 | API_KEY = os.getenv("DASHSCOPE_API_KEY") |
| 118 | BASE_URL = "https://dashscope.aliyuncs.com/api/v1" |
| 119 | |
| 120 | def create_videoedit_task(req: dict) -> str: |
| 121 | """Create a video editing task and return task_id.""" |
| 122 | payload = { |
| 123 | "model": "wan2.7-videoedit", |
| 124 | "input": { |
| 125 | "prompt": req.get("prompt", ""), |
| 126 | "media": req["media"], |
| 127 | }, |
| 128 | "parameters": { |
| 129 | "resolution": req.get("resolution", "1080P"), |
| 130 | "prompt_extend": req.get("prompt_extend", True), |
| 131 | "watermark": req.get("watermark", False), |
| 132 | }, |
| 133 | } |
| 134 | if req.get("negative_prompt"): |
| 135 | payload["input"]["negative_prompt"] = req["negative_prompt"] |
| 136 | if req.get("ratio"): |
| 137 | payload["parameters"]["ratio"] = req["ratio"] |
| 138 | if req.get("duration"): |
| 139 | payload["parameters"]["duration"] = req["duration"] |
| 140 | if req.get("audio_setting"): |
| 141 | payload["paramet |