alibabacloud-video-editor
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseVideo Editor Skill
视频编辑Skill
Automated video editing tool that submits Alibaba Cloud editing tasks based on provided materials and editing requirements, without requiring ffmpeg installation, waits for task completion, and outputs the final video URL.
自动化视频编辑工具,可基于提供的素材和编辑需求提交阿里云编辑任务,无需安装ffmpeg,等待任务完成后输出最终视频URL。
Core Design Philosophy
核心设计理念
This skill adopts a separation of concerns design:
- references/ - LLM knowledge base containing best practice documentation for various scenarios
- scripts/ - Pure execution tools responsible only for submitting tasks and polling status
The LLM should refer to documents in to generate Timeline JSON in Alibaba Cloud ICE format, then use scripts to submit tasks.
references/本skill采用关注点分离设计:
- references/ - LLM知识库,包含各类场景的最佳实践文档
- scripts/ - 纯执行工具,仅负责提交任务和轮询状态
LLM应参考下的文档生成阿里云ICE格式的Timeline JSON,再使用脚本提交任务。
references/Prerequisites
前置条件
Pre-check: Install Python Dependenciesbashpip install -r requirements.txt
Pre-check: Alibaba Cloud Credentials RequiredScripts automatically obtain credentials via the Alibaba Cloud default credential chain, supporting the following methods (in priority order):
- Environment variable credentials
- Configuration file:
~/.alibabacloud/credentials.ini- ECS RAM Role (when running on ECS)
It is recommended to use thecommand to set up credentials:aliyun configurebashaliyun configureOr refer to the [Alibaba Cloud Credential Configuration Documentation](https://help.aliyun.com/document_detail/China Site/2China Site/Chinese2Chinese10China Site/Chinese0China Site/Chinese6China Site/Chinese2China Site.html) to configure the default credential chain.
OSS Bucket ConfigurationOSS upload functionality requires Bucket information to be configured via environment variables:bashexport OSS_BUCKET=your_bucket_name export OSS_ENDPOINT=oss-cn-shanghai.aliyuncs.comIf OSS_BUCKET is not configured, list the buckets under the customer's current account and let the customer choose one as the output bucket for the final video.OSS operations reuse the Alibaba Cloud default credential chain; no separate OSS credential configuration is needed.
User-Agent ConfigurationAll Alibaba Cloud service calls must set User-Agent to. The scriptAlibabaCloud-Agent-Skillshas already automatically configured this User-Agent.scripts/video_editor.py
预检查:安装Python依赖bashpip install -r requirements.txt
预检查:需要阿里云凭证脚本通过阿里云默认凭证链自动获取凭证,支持以下方式(按优先级排序):
- 环境变量凭证
- 配置文件:
~/.alibabacloud/credentials.ini- ECS RAM角色(在ECS上运行时)
推荐使用命令设置凭证:aliyun configurebashaliyun configure也可参考[阿里云凭证配置文档](https://help.aliyun.com/document_detail/China Site/2China Site/Chinese2Chinese10China Site/Chinese0China Site/Chinese6China Site/Chinese2China Site.html)配置默认凭证链。
OSS Bucket配置OSS上传功能需要通过环境变量配置Bucket信息:bashexport OSS_BUCKET=your_bucket_name export OSS_ENDPOINT=oss-cn-shanghai.aliyuncs.com如果未配置OSS_BUCKET,列出客户当前账户下的所有bucket,让客户选择一个作为最终视频的输出bucket。OSS操作复用阿里云默认凭证链,无需单独配置OSS凭证。
User-Agent配置所有阿里云服务调用必须将User-Agent设置为。AlibabaCloud-Agent-Skills脚本已经自动完成该User-Agent配置。scripts/video_editor.py
Workflow
工作流程
Step 1: Understand User Requirements
步骤1:理解用户需求
Analyze the type of video the user wants to create:
- Slideshow video (image carousel)
- Multi-track audio mixing (voiceover + music)
- Multi-clip stitching
- Add subtitles/titles
- Effects and transitions
- Picture-in-picture/split-screen effects
分析用户想要制作的视频类型:
- 幻灯片视频(图片轮播)
- 多轨音频混音(旁白+音乐)
- 多片段拼接
- 添加字幕/标题
- 特效与转场
- 画中画/分屏效果
Step 2: Reference Best Practices
步骤2:参考最佳实践
Consult the corresponding documents in :
references/| Document | Applicable Scenario |
|---|---|
| Timeline basic structure explanation |
| Multi-track audio mixing |
| Subtitle and title effects |
| Visual effects and transitions |
| Slideshow video templates |
| Multi-clip video editing |
查阅下的对应文档:
references/| 文档 | 适用场景 |
|---|---|
| Timeline基础结构讲解 |
| 多轨音频混音 |
| 字幕与标题特效 |
| 视觉特效与转场 |
| 幻灯片视频模板 |
| 多片段视频编辑 |
Step 3: Prepare Material URLs
步骤3:准备素材URL
- If it is a local file, you need to call the oss-upload skill to upload it and obtain the OSS URL, which can be directly spliced into the timeline
- If you already have a URL, you can directly splice it into the timeline
- 如果是本地文件,需要调用oss-upload skill上传获取OSS URL,可直接拼接进timeline
- 如果已有URL,可直接拼接进timeline
Step 4: Generate Timeline JSON
步骤4:生成Timeline JSON
Generate a Timeline in Alibaba Cloud ICE format according to the reference documents:
json
{
"VideoTracks": [...],
"AudioTracks": [...],
"SubtitleTracks": [...]
}根据参考文档生成阿里云ICE格式的Timeline:
json
{
"VideoTracks": [...],
"AudioTracks": [...],
"SubtitleTracks": [...]
}Step 5: Submit Editing Task
步骤5:提交编辑任务
Use the script to submit the task (based on Alibaba Cloud Common SDK):
bash
undefined使用脚本提交任务(基于阿里云通用SDK):
bash
undefinedSubmit and wait for completion
提交并等待完成
python scripts/video_editor.py submit
--timeline timeline.json
--output-config output.json
--wait
--timeline timeline.json
--output-config output.json
--wait
python scripts/video_editor.py submit
--timeline timeline.json
--output-config output.json
--wait
--timeline timeline.json
--output-config output.json
--wait
Submit only, do not wait
仅提交,不等待
python scripts/video_editor.py submit
--timeline timeline.json
--output-config output.json
--timeline timeline.json
--output-config output.json
**Parameter Description:**
| Parameter | Description | Required |
|------|------|------|
| `--timeline, -t` | Timeline JSON file path or JSON string | Yes |
| `--output-config, -o` | Output configuration JSON file path or JSON string | Yes |
| `--region, -r` | Region ID (default: cn-shanghai) | No |
| `--wait, -w` | Wait for task completion | No |
OutputMediaConfig example:
```json
{
"MediaURL": "https://{your-bucket}.oss-cn-shanghai.aliyuncs.com/{your-target-video-path}",
"Width": 1080,
"Height": 1920
}If the output resolution is not explicitly specified in the context, use common resolutions: 10801920, 19201080
After the task is submitted, a will be returned.
JobIdpython scripts/video_editor.py submit
--timeline timeline.json
--output-config output.json
--timeline timeline.json
--output-config output.json
**参数说明:**
| 参数 | 描述 | 是否必填 |
|------|------|------|
| `--timeline, -t` | Timeline JSON文件路径或JSON字符串 | 是 |
| `--output-config, -o` | 输出配置JSON文件路径或JSON字符串 | 是 |
| `--region, -r` | 区域ID(默认:cn-shanghai) | 否 |
| `--wait, -w` | 等待任务完成 | 否 |
OutputMediaConfig示例:
```json
{
"MediaURL": "https://{your-bucket}.oss-cn-shanghai.aliyuncs.com/{your-target-video-path}",
"Width": 1080,
"Height": 1920
}如果上下文中未明确指定输出分辨率,使用常用分辨率:10801920、19201080
任务提交后会返回。
JobIdStep 6: Poll Task Status
步骤6:轮询任务状态
Use the script to query/wait for task completion:
bash
undefined使用脚本查询/等待任务完成:
bash
undefinedQuery status
查询状态
python scripts/video_editor.py status --job-id <job_id>
python scripts/video_editor.py status --job-id <job_id>
Wait for task completion
等待任务完成
python scripts/video_editor.py status --job-id <job_id> --wait
When the task status is `Success`, call GetMediaInfo based on the returned MediaId to obtain the OSS URL with authentication, and return it.python scripts/video_editor.py status --job-id <job_id> --wait
当任务状态为`Success`时,根据返回的MediaId调用GetMediaInfo获取带鉴权的OSS URL并返回。Timeline Example
Timeline示例
Simplest Slideshow
最简幻灯片
json
{
"VideoTracks": [{
"VideoTrackClips": [
{
"Type": "Image",
"MediaURL": "https://bucket.oss-cn-shanghai.aliyuncs.com/image1.jpg",
"In": 0,
"Out": 5,
"TimelineIn": 0,
"TimelineOut": 5
},
{
"Type": "Image",
"MediaURL": "https://bucket.oss-cn-shanghai.aliyuncs.com/image2.jpg",
"In": 0,
"Out": 5,
"TimelineIn": 5,
"TimelineOut": 10,
"Effects": [
{
"Type": "Transition",
"SubType": "linearblur",
"Duration":0.3
}
]
}
]
}],
"AudioTracks": [{
"AudioTrackClips": [{
"Type": "Audio",
"MediaURL": "https://bucket.oss-cn-shanghai.aliyuncs.com/music.mp3",
"In": 0,
"Out": 10,
"TimelineIn": 0,
"TimelineOut": 10,
"Effects": [
{
"Type": "Volume",
"Gain": 0.3
}
]
}]
}],
"SubtitleTracks": []
}json
{
"VideoTracks": [{
"VideoTrackClips": [
{
"Type": "Image",
"MediaURL": "https://bucket.oss-cn-shanghai.aliyuncs.com/image1.jpg",
"In": 0,
"Out": 5,
"TimelineIn": 0,
"TimelineOut": 5
},
{
"Type": "Image",
"MediaURL": "https://bucket.oss-cn-shanghai.aliyuncs.com/image2.jpg",
"In": 0,
"Out": 5,
"TimelineIn": 5,
"TimelineOut": 10,
"Effects": [
{
"Type": "Transition",
"SubType": "linearblur",
"Duration":0.3
}
]
}
]
}],
"AudioTracks": [{
"AudioTrackClips": [{
"Type": "Audio",
"MediaURL": "https://bucket.oss-cn-shanghai.aliyuncs.com/music.mp3",
"In": 0,
"Out": 10,
"TimelineIn": 0,
"TimelineOut": 10,
"Effects": [
{
"Type": "Volume",
"Gain": 0.3
}
]
}]
}],
"SubtitleTracks": []
}LLM Prompt Suggestions
LLM Prompt建议
When generating a Timeline, think like this:
- What type of video does the user need? → Find the corresponding reference document
- Which tracks are needed? (video track, audio track, subtitle track)
- What clips are in each track?
- Do you need to set In/Out/TimelineIn/TimelineOut (simple stitching does not require setting)? If setting is needed, what are In/Out/TimelineIn/TimelineOut respectively?
- Are effects, transitions, volume adjustments, etc. needed?
- Generate the complete JSON
生成Timeline时,按如下思路思考:
- 用户需要什么类型的视频?→ 找到对应的参考文档
- 需要哪些轨道?(视频轨道、音频轨道、字幕轨道)
- 每个轨道中有哪些片段?
- 是否需要设置In/Out/TimelineIn/TimelineOut(简单拼接无需设置)?如果需要设置,In/Out/TimelineIn/TimelineOut分别是多少?
- 是否需要特效、转场、音量调节等功能?
- 生成完整JSON
Related Files
相关文件
alibabacloud-video-editor/
├── SKILL.md # This document
├── references/
│ ├── 01-timeline-basics.md # Timeline basics
│ ├── 02-multi-track-audio.md # Multi-track audio
│ ├── 03-subtitles-and-titles.md # Subtitles and titles
│ ├── 04-effects-and-transitions.md # Effects and transitions
│ ├── 05-slideshow-template.md # Slideshow templates
│ └── 06-multi-clip-editing.md # Multi-clip editing
└── scripts/
├── requirements.txt # Python dependencies
└── video_editor.py # Common SDK scriptalibabacloud-video-editor/
├── SKILL.md # 本文档
├── references/
│ ├── 01-timeline-basics.md # Timeline基础
│ ├── 02-multi-track-audio.md # 多轨音频
│ ├── 03-subtitles-and-titles.md # 字幕与标题
│ ├── 04-effects-and-transitions.md # 特效与转场
│ ├── 05-slideshow-template.md # 幻灯片模板
│ └── 06-multi-clip-editing.md # 多片段编辑
└── scripts/
├── requirements.txt # Python依赖
└── video_editor.py # 通用SDK脚本