$npx -y skills add cinience/alicloud-skills --skill aliyun-video-style-repaintUse 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.
| 1 | # Video Style Repaint |
| 2 | |
| 3 | ## Validation |
| 4 | |
| 5 | ```bash |
| 6 | mkdir -p output/aliyun-video-style-repaint |
| 7 | 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 |
| 8 | ``` |
| 9 | |
| 10 | Pass criteria: command exits 0 and `output/aliyun-video-style-repaint/validate.txt` is generated. |
| 11 | |
| 12 | ## Output And Evidence |
| 13 | |
| 14 | - Save task IDs, polling responses, and final video URLs to `output/aliyun-video-style-repaint/`. |
| 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 requests |
| 25 | ``` |
| 26 | - Set `DASHSCOPE_API_KEY` in your environment, or add `dashscope_api_key` to `~/.alibabacloud/credentials`. |
| 27 | - This API is only available in the Beijing region. You must use a Beijing-region API Key. |
| 28 | |
| 29 | ## Critical model names |
| 30 | |
| 31 | - `video-style-transform` -- supports 8 preset artistic styles |
| 32 | |
| 33 | ## Supported styles |
| 34 | |
| 35 | | Style ID | Name (EN) | Name (CN) | |
| 36 | |---|---|---| |
| 37 | | 0 | Japanese Manga | 日式漫画 | |
| 38 | | 1 | American Comics | 美式漫画 | |
| 39 | | 2 | Fresh Comics | 清新漫画 | |
| 40 | | 3 | 3D Cartoon | 3D 卡通 | |
| 41 | | 4 | Chinese Cartoon | 国风卡通 | |
| 42 | | 5 | Paper Art | 纸艺风格 | |
| 43 | | 6 | Simple Illustration | 简易插画 | |
| 44 | | 7 | Chinese Ink Painting | 国风水墨 | |
| 45 | |
| 46 | ## API endpoint (async only) |
| 47 | |
| 48 | ``` |
| 49 | POST https://dashscope.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis |
| 50 | ``` |
| 51 | |
| 52 | Required headers: |
| 53 | - `Authorization: Bearer $DASHSCOPE_API_KEY` |
| 54 | - `Content-Type: application/json` |
| 55 | - `X-DashScope-Async: enable` |
| 56 | |
| 57 | ## Normalized interface |
| 58 | |
| 59 | ### Request |
| 60 | - `video_url` (string, required) -- public HTTP/HTTPS URL of the input video |
| 61 | - `style` (integer, optional) -- style ID 0-7 (default: 0, Japanese Manga) |
| 62 | - `video_fps` (integer, optional) -- output frame rate, range [15, 25] (default: 15) |
| 63 | - `animate_emotion` (boolean, optional) -- facial expression optimization (default: true) |
| 64 | - `min_len` (integer, optional) -- output short-side pixels, 720 or 540 (default: 720) |
| 65 | - `use_SR` (boolean, optional) -- super-resolution enhancement (default: false) |
| 66 | |
| 67 | ### Video input limits |
| 68 | |
| 69 | - Formats: MP4, AVI, MKV, MOV, FLV, TS, MPG, MXF |
| 70 | - Resolution: [256, 4096] pixels per side, aspect ratio max 1.8:1 |
| 71 | - Duration: up to 30 seconds |
| 72 | - Max size: 100MB |
| 73 | - URL: must be URL-encoded if contains non-ASCII characters |
| 74 | |
| 75 | ### Response (task creation) |
| 76 | - `output.task_id` (string) -- use for polling, valid 24 hours |
| 77 | - `output.task_status` (string) -- PENDING | RUNNING | SUSPENDED | SUCCEEDED | FAILED |
| 78 | - `request_id` (string) |
| 79 | |
| 80 | ### Response (task result) |
| 81 | - `output.output_video_url` (string) -- result video URL |
| 82 | - `output.task_status` (string) -- final status |
| 83 | - `output.submit_time` (string) -- task submission time |
| 84 | - `output.scheduled_time` (string) -- task execution start time |
| 85 | - `output.end_time` (string) -- task completion time |
| 86 | - `usage.duration` (integer) -- video duration in seconds |
| 87 | - `usage.SR` (integer) -- resolution used |
| 88 | |
| 89 | ## Quick start (Python + HTTP) |
| 90 | |
| 91 | ```python |
| 92 | import os |
| 93 | import json |
| 94 | import time |
| 95 | import requests |
| 96 | |
| 97 | API_KEY = os.getenv("DASHSCOPE_API_KEY") |
| 98 | BASE_URL = "https://dashscope.aliyuncs.com/api/v1" |
| 99 | |
| 100 | def create_style_repaint_task(video_url: str, style: int = 0) -> str: |
| 101 | """Create a video style repaint task and return task_id.""" |
| 102 | payload = { |
| 103 | "model": "video-style-transform", |
| 104 | "input": { |
| 105 | "video_url": video_url, |
| 106 | }, |
| 107 | "parameters": { |
| 108 | "style": style, |
| 109 | "video_fps": 15, |
| 110 | }, |
| 111 | } |
| 112 | resp = requests.post( |
| 113 | f"{BASE_URL}/services/aigc/video-generation/video-synthesis", |
| 114 | headers={ |
| 115 | "Authorization": f"Bearer {API_KEY}", |
| 116 | "Content-Type": "application/json", |
| 117 | "X-DashScope-Async": "enable", |
| 118 | }, |
| 119 | json=payload, |
| 120 | ) |
| 121 | resp.raise_for_status() |
| 122 | data = resp.json() |
| 123 | return data["output"]["task_id"] |
| 124 | |
| 125 | |
| 126 | def poll_task(task_id: str, interval: int = 15) -> dict: |
| 127 | """Poll until task completes. Returns final response.""" |
| 128 | while True: |
| 129 | resp = requests.get( |
| 130 | f"{BASE_URL}/tasks/{task_id}", |
| 131 | headers={"Authorization": f"Bearer {API_KEY}"}, |
| 132 | ) |
| 133 | resp.raise_for_status() |
| 134 | data = resp.json() |
| 135 | status = data["output"]["task_status"] |
| 136 | if status in ("SUCCEEDED", "FAILED", "CANCELED", "SUSPENDED"): |
| 137 | return data |
| 138 | time.sleep(interval) |
| 139 | ``` |
| 140 | |
| 141 | ## Error handling |
| 142 | |
| 143 | | Error | Likely cause | Action | |
| 144 | |---|---|---| |
| 145 | | 401/403 | Missing or invalid `DASHSCOPE_API_KEY` | Check env var or credentials file | |
| 146 | | 400 `InvalidParameter` | Unsupported video format, bad dimensions, invalid style | Validate parameters | |
| 147 | | "does not support synchronous calls" | Mis |