Video Style Repaint
Validation
mkdir -p output/aliyun-video-style-repaint
python -m py_compile skills/ai/video/aliyun-video-style-repaint/scripts/repaint_video.py && echo "py_compile_ok" > output/aliyun-video-style-repaint/validate.txt
Pass criteria: command exits 0 and output/aliyun-video-style-repaint/validate.txt is generated.
Output And Evidence
- Save task IDs, polling responses, and final video URLs to
output/aliyun-video-style-repaint/.
- 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 requests
- Set
DASHSCOPE_API_KEY in your environment, or add dashscope_api_key to ~/.alibabacloud/credentials.
- This API is only available in the Beijing region. You must use a Beijing-region API Key.
Critical model names
video-style-transform -- supports 8 preset artistic styles
Supported styles
| Style ID |
Name (EN) |
Name (CN) |
| 0 |
Japanese Manga |
日式漫画 |
| 1 |
American Comics |
美式漫画 |
| 2 |
Fresh Comics |
清新漫画 |
| 3 |
3D Cartoon |
3D 卡通 |
| 4 |
Chinese Cartoon |
国风卡通 |
| 5 |
Paper Art |
纸艺风格 |
| 6 |
Simple Illustration |
简易插画 |
| 7 |
Chinese Ink Painting |
国风水墨 |
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
Normalized interface
Request
video_url (string, required) -- public HTTP/HTTPS URL of the input video
style (integer, optional) -- style ID 0-7 (default: 0, Japanese Manga)
video_fps (integer, optional) -- output frame rate, range [15, 25] (default: 15)
animate_emotion (boolean, optional) -- facial expression optimization (default: true)
min_len (integer, optional) -- output short-side pixels, 720 or 540 (default: 720)
use_SR (boolean, optional) -- super-resolution enhancement (default: false)
Video input limits
- Formats: MP4, AVI, MKV, MOV, FLV, TS, MPG, MXF
- Resolution: [256, 4096] pixels per side, aspect ratio max 1.8:1
- Duration: up to 30 seconds
- Max size: 100MB
- URL: must be URL-encoded if contains non-ASCII characters
Response (task creation)
output.task_id (string) -- use for polling, valid 24 hours
output.task_status (string) -- PENDING | RUNNING | SUSPENDED | SUCCEEDED | FAILED
request_id (string)
Response (task result)
output.output_video_url (string) -- result video URL
output.task_status (string) -- final status
output.submit_time (string) -- task submission time
output.scheduled_time (string) -- task execution start time
output.end_time (string) -- task completion time
usage.duration (integer) -- video duration in seconds
usage.SR (integer) -- resolution used
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_style_repaint_task(video_url: str, style: int = 0) -> str:
"""Create a video style repaint task and return task_id."""
payload = {
"model": "video-style-transform",
"input": {
"video_url": video_url,
},
"parameters": {
"style": style,
"video_fps": 15,
},
}
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", "SUSPENDED"):
return data
time.sleep(interval)
Error handling
| Error |
Likely cause |
Action |
| 401/403 |
Missing or invalid DASHSCOPE_API_KEY |
Check env var or credentials file |
400 InvalidParameter |
Unsupported video format, bad dimensions, invalid style |
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-video-style-repaint/videos/
- Override base dir with
OUTPUT_DIR.
Anti-patterns
- Do not use model names other than
video-style-transform.
- Do not call this API synchronously -- async header is required.
- Do not use style IDs outside 0-7 range.
- Video URLs expire after 24 hours; download and persist immediately.
- Do not use Singapore endpoint -- this API is Beijing-region only.
Workflow
- Confirm user intent: select desired artistic style from the 8 presets.
- Prepare video URL with valid format and dimensions.
- Configure parameters (style, fps, resolution, super-resolution).
- Create async task and poll for results.
- Download and save transformed 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-video-style-repaint3description: Use when transforming video style with DashScope video-style-transform model. Use when converting videos to artistic styles such as Japanese manga, American comics, 3D cartoon, Chinese ink painting, paper art, or simple illustration via the video-synthesis async API.4---5
6# Video Style Repaint
7
8## Validation
9
10```bash
11mkdir -p output/aliyun-video-style-repaint
12python -m py_compile skills/ai/video/aliyun-video-style-repaint/scripts/repaint_video.py && echo "py_compile_ok" > output/aliyun-video-style-repaint/validate.txt
13```
14
15Pass criteria: command exits 0 and `output/aliyun-video-style-repaint/validate.txt` is generated.
16
17## Output And Evidence
18
19- Save task IDs, polling responses, and final video URLs to `output/aliyun-video-style-repaint/`.
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 requests
30```
31- Set `DASHSCOPE_API_KEY` in your environment, or add `dashscope_api_key` to `~/.alibabacloud/credentials`.
32- This API is only available in the Beijing region. You must use a Beijing-region API Key.
33
34## Critical model names
35
36- `video-style-transform` -- supports 8 preset artistic styles
37
38## Supported styles
39
40| Style ID | Name (EN) | Name (CN) |
41|---|---|---|
42| 0 | Japanese Manga | 日式漫画 |
43| 1 | American Comics | 美式漫画 |
44| 2 | Fresh Comics | 清新漫画 |
45| 3 | 3D Cartoon | 3D 卡通 |
46| 4 | Chinese Cartoon | 国风卡通 |
47| 5 | Paper Art | 纸艺风格 |
48| 6 | Simple Illustration | 简易插画 |
49| 7 | Chinese Ink Painting | 国风水墨 |
50
51## API endpoint (async only)
52
53```
54POST https://dashscope.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
55```
56
57Required headers:
58- `Authorization: Bearer $DASHSCOPE_API_KEY`
59- `Content-Type: application/json`
60- `X-DashScope-Async: enable`
61
62## Normalized interface
63
64### Request
65- `video_url` (string, required) -- public HTTP/HTTPS URL of the input video
66- `style` (integer, optional) -- style ID 0-7 (default: 0, Japanese Manga)
67- `video_fps` (integer, optional) -- output frame rate, range [15, 25] (default: 15)
68- `animate_emotion` (boolean, optional) -- facial expression optimization (default: true)
69- `min_len` (integer, optional) -- output short-side pixels, 720 or 540 (default: 720)
70- `use_SR` (boolean, optional) -- super-resolution enhancement (default: false)
71
72### Video input limits
73
74- Formats: MP4, AVI, MKV, MOV, FLV, TS, MPG, MXF
75- Resolution: [256, 4096] pixels per side, aspect ratio max 1.8:1
76- Duration: up to 30 seconds
77- Max size: 100MB
78- URL: must be URL-encoded if contains non-ASCII characters
79
80### Response (task creation)
81- `output.task_id` (string) -- use for polling, valid 24 hours
82- `output.task_status` (string) -- PENDING | RUNNING | SUSPENDED | SUCCEEDED | FAILED
83- `request_id` (string)
84
85### Response (task result)
86- `output.output_video_url` (string) -- result video URL
87- `output.task_status` (string) -- final status
88- `output.submit_time` (string) -- task submission time
89- `output.scheduled_time` (string) -- task execution start time
90- `output.end_time` (string) -- task completion time
91- `usage.duration` (integer) -- video duration in seconds
92- `usage.SR` (integer) -- resolution used
93
94## Quick start (Python + HTTP)
95
96```python
97import os
98import json
99import time
100import requests
101
102API_KEY = os.getenv("DASHSCOPE_API_KEY")
103BASE_URL = "https://dashscope.aliyuncs.com/api/v1"
104
105def create_style_repaint_task(video_url: str, style: int = 0) -> str:
106 """Create a video style repaint task and return task_id."""
107 payload = {
108 "model": "video-style-transform",
109 "input": {
110 "video_url": video_url,
111 },
112 "parameters": {
113 "style": style,
114 "video_fps": 15,
115 },
116 }
117 resp = requests.post(
118 f"{BASE_URL}/services/aigc/video-generation/video-synthesis",
119 headers={
120 "Authorization": f"Bearer {API_KEY}",
121 "Content-Type": "application/json",
122 "X-DashScope-Async": "enable",
123 },
124 json=payload,
125 )
126 resp.raise_for_status()
127 data = resp.json()
128 return data["output"]["task_id"]
129
130
131def poll_task(task_id: str, interval: int = 15) -> dict:
132 """Poll until task completes. Returns final response."""
133 while True:
134 resp = requests.get(
135 f"{BASE_URL}/tasks/{task_id}",
136 headers={"Authorization": f"Bearer {API_KEY}"},
137 )
138 resp.raise_for_status()
139 data = resp.json()
140 status = data["output"]["task_status"]
141 if status in ("SUCCEEDED", "FAILED", "CANCELED", "SUSPENDED"):
142 return data
143 time.sleep(interval)
144```
145
146## Error handling
147
148| Error | Likely cause | Action |
149|---|---|---|
150| 401/403 | Missing or invalid `DASHSCOPE_API_KEY` | Check env var or credentials file |
151| 400 `InvalidParameter` | Unsupported video format, bad dimensions, invalid style | Validate parameters |
152| "does not support synchronous calls" | Missing `X-DashScope-Async: enable` header | Add required header |
153| 429 | Rate limit or quota | Retry with backoff |
154
155## Output location
156
157- Default output: `output/aliyun-video-style-repaint/videos/`
158- Override base dir with `OUTPUT_DIR`.
159
160## Anti-patterns
161
162- Do not use model names other than `video-style-transform`.
163- Do not call this API synchronously -- async header is required.
164- Do not use style IDs outside 0-7 range.
165- Video URLs expire after 24 hours; download and persist immediately.
166- Do not use Singapore endpoint -- this API is Beijing-region only.
167
168## Workflow
169
1701) Confirm user intent: select desired artistic style from the 8 presets.
1712) Prepare video URL with valid format and dimensions.
1723) Configure parameters (style, fps, resolution, super-resolution).
1734) Create async task and poll for results.
1745) Download and save transformed video before URL expiration.
175
176## References
177
178- See `references/api_reference.md` for full HTTP API details.
179- See `references/sources.md` for source links.