$npx -y skills add cinience/alicloud-skills --skill aliyun-happyhorse-videoeditUse when editing videos with DashScope HappyHorse 1.0 video editing model (happyhorse-1.0-video-edit). Use when implementing instruction-based video editing such as style transfer or local replacement, optionally guided by 0-5 reference images, via the video-synthesis async API o
| 1 | # HappyHorse 1.0 Video Editing |
| 2 | |
| 3 | ## Validation |
| 4 | |
| 5 | ```bash |
| 6 | mkdir -p output/aliyun-happyhorse-videoedit |
| 7 | python -m py_compile skills/ai/video/aliyun-happyhorse-videoedit/scripts/edit_happyhorse.py && echo "py_compile_ok" > output/aliyun-happyhorse-videoedit/validate.txt |
| 8 | ``` |
| 9 | |
| 10 | Pass criteria: command exits 0 and `output/aliyun-happyhorse-videoedit/validate.txt` is generated. |
| 11 | |
| 12 | ## Output And Evidence |
| 13 | |
| 14 | - Save task IDs, polling responses, and final video URLs to `output/aliyun-happyhorse-videoedit/`. |
| 15 | - Keep at least one end-to-end run log for troubleshooting. |
| 16 | |
| 17 | ## Prerequisites |
| 18 | |
| 19 | - Install dependencies (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 | |
| 28 | ## Critical model names |
| 29 | |
| 30 | - `happyhorse-1.0-video-edit` — instruction-based video editing with optional reference images and audio retention control |
| 31 | |
| 32 | ## Capabilities |
| 33 | |
| 34 | | Capability | Description | Required media | |
| 35 | |---|---|---| |
| 36 | | Style transfer | Convert the input video to a different visual style via a text instruction | exactly 1 `video` | |
| 37 | | Local replacement / instruction edit | Replace or modify subjects guided by a prompt and optional reference images | 1 `video` + 0-5 `reference_image` | |
| 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 | Polling endpoint: `GET https://dashscope.aliyuncs.com/api/v1/tasks/{task_id}` — recommended interval 15s. |
| 53 | |
| 54 | ## Normalized interface |
| 55 | |
| 56 | ### Request |
| 57 | - `model` (string, required) — fixed `happyhorse-1.0-video-edit` |
| 58 | - `input.prompt` (string, required) — up to 5000 non-CJK / 2500 CJK characters describing the edit |
| 59 | - `input.media` (array, required) — exactly 1 `video` element, plus 0-5 `reference_image` elements: |
| 60 | - `type`: `video` (required, exactly 1) | `reference_image` (optional, 0-5) |
| 61 | - `url`: public HTTP/HTTPS URL |
| 62 | - `parameters.resolution` (string, optional) — `720P` or `1080P` (default: `1080P`) |
| 63 | - `parameters.audio_setting` (string, optional) — `auto` (default, model decides) or `origin` (keep input audio) |
| 64 | - `parameters.watermark` (boolean, optional) — bottom-right "Happy Horse" watermark (default: `true`) |
| 65 | - `parameters.seed` (integer, optional) — range [0, 2147483647] |
| 66 | |
| 67 | ### Media input limits |
| 68 | |
| 69 | **Input video** (`type=video`): |
| 70 | - Formats: MP4, MOV (H.264 encoding recommended) |
| 71 | - Duration: 3-60 seconds (output is capped at 15s; videos >15s are truncated to the first 15s) |
| 72 | - Resolution: long side ≤ 2160 px, short side ≥ 320 px |
| 73 | - Aspect ratio: 1:2.5 ~ 2.5:1 |
| 74 | - Frame rate: > 8 fps |
| 75 | - Max size: 100 MB |
| 76 | |
| 77 | **Reference image** (`type=reference_image`): |
| 78 | - Formats: JPEG, JPG, PNG, WEBP |
| 79 | - Resolution: width and height ≥ 300 pixels |
| 80 | - Aspect ratio: 1:2.5 ~ 2.5:1 |
| 81 | - Max size: 10 MB |
| 82 | |
| 83 | ### Output duration rule |
| 84 | |
| 85 | - Input ≤ 15s → output duration = input duration. |
| 86 | - Input > 15s → input is truncated to the first 15s; output ≤ 15s. |
| 87 | |
| 88 | ### Response (task creation) |
| 89 | - `output.task_id` (string) — valid 24 hours |
| 90 | - `output.task_status` (string) — `PENDING` | `RUNNING` | `SUCCEEDED` | `FAILED` | `CANCELED` | `UNKNOWN` |
| 91 | - `request_id` (string) |
| 92 | |
| 93 | ### Response (task result, on SUCCEEDED) |
| 94 | - `output.video_url` (string) — edited MP4 (H.264) URL, valid 24 hours |
| 95 | - `output.orig_prompt` (string) |
| 96 | - `output.submit_time` / `output.scheduled_time` / `output.end_time` (string) |
| 97 | - `usage.duration` (float) — billable duration in seconds |
| 98 | - `usage.input_video_duration` (float) |
| 99 | - `usage.output_video_duration` (float) |
| 100 | - `usage.SR` (integer) — output resolution tier |
| 101 | - `usage.video_count` (integer) — fixed 1 |
| 102 | |
| 103 | ## Quick start (Python + HTTP) |
| 104 | |
| 105 | ```python |
| 106 | import os |
| 107 | import time |
| 108 | import requests |
| 109 | |
| 110 | API_KEY = os.getenv("DASHSCOPE_API_KEY") |
| 111 | BASE_URL = "https://dashscope.aliyuncs.com/api/v1" |
| 112 | |
| 113 | |
| 114 | def create_videoedit_task(req: dict) -> str: |
| 115 | """Create a video-edit task and return task_id.""" |
| 116 | media = [{"type": "video", "url": req["video_url"]}] |
| 117 | for url in req.get("reference_images", []): |
| 118 | media.append({"type": "reference_image", "url": url}) |
| 119 | if len(media) - 1 > 5: |
| 120 | raise ValueError("At most 5 reference images") |
| 121 | |
| 122 | payload = { |
| 123 | "model": "happyhorse-1.0-video-edit", |
| 124 | "input": {"prompt": req["prompt"], "media": media}, |
| 125 | "parameters": { |
| 126 | "resolution": req.get("resolution", "1080P"), |
| 127 | "watermark": req.get("watermark", True), |
| 128 | }, |