Video Editor 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.
Core Design Philosophy
This skill adopts a separation of concerns design:
- 1. 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 references/ to generate Timeline JSON in Alibaba Cloud ICE format, then use scripts to submit tasks.
Prerequisites
Pre-check: Install Python Dependencies
CODEBLOCK0
Pre-check: Alibaba Cloud Credentials Required
Scripts automatically obtain credentials via the Alibaba Cloud default credential chain, supporting the following methods (in priority order):
- 1. Environment variable credentials
- Configuration file: INLINECODE1
- ECS RAM Role (when running on ECS)
It is recommended to use the aliyun configure command to set up credentials:
> aliyun configure
>
Or refer to the Alibaba Cloud Credential Configuration Documentation to configure the default credential chain.
OSS Bucket Configuration
OSS upload functionality requires Bucket information to be configured via environment variables:
> export OSS_BUCKET=your_bucket_name
> export OSS_ENDPOINT=oss-cn-shanghai.aliyuncs.com
>
If 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 Configuration
All Alibaba Cloud service calls must set User-Agent to AlibabaCloud-Agent-Skills.
The script scripts/video_editor.py has already automatically configured this User-Agent.
Workflow
Step 1: Understand User Requirements
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
Consult the corresponding documents in references/:
| Document | Applicable Scenario |
|---|
| INLINECODE6 | Timeline basic structure explanation |
| INLINECODE7 |
Multi-track audio mixing |
|
03-subtitles-and-titles.md | Subtitle and title effects |
|
04-effects-and-transitions.md | Visual effects and transitions |
|
05-slideshow-template.md | Slideshow video templates |
|
06-multi-clip-editing.md | Multi-clip video editing |
Step 3: Prepare Material URLs
- - 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
Step 4: Generate Timeline JSON
Generate a Timeline in Alibaba Cloud ICE format according to the reference documents:
CODEBLOCK3
Step 5: Submit Editing Task
Use the script to submit the task (based on Alibaba Cloud Common SDK):
CODEBLOCK4
Parameter Description:
| Parameter | Description | Required |
|---|
| INLINECODE12 | Timeline JSON file path or JSON string | Yes |
| INLINECODE13 |
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:
{
"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: 1080
1920, 19201080
After the task is submitted, a JobId will be returned.
Step 6: Poll Task Status
Use the script to query/wait for task completion:
CODEBLOCK6
When the task status is Success, call GetMediaInfo based on the returned MediaId to obtain the OSS URL with authentication, and return it.
Timeline Example
Simplest Slideshow
CODEBLOCK7
LLM Prompt Suggestions
When generating a Timeline, think like this:
- 1. 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
Related Files
CODEBLOCK8
视频编辑技能
基于提供的素材和编辑需求,自动提交阿里云剪辑任务,无需安装ffmpeg,等待任务完成并输出最终视频URL的自动化视频编辑工具。
核心设计理念
本技能采用关注点分离设计:
- 1. references/ - LLM知识库,包含各种场景的最佳实践文档
- scripts/ - 纯执行工具,仅负责提交任务和轮询状态
LLM应参考references/中的文档生成阿里云ICE格式的Timeline JSON,然后使用脚本提交任务。
前置条件
预检查:安装Python依赖
bash
pip install -r requirements.txt
预检查:需要阿里云凭证
脚本通过阿里云默认凭证链自动获取凭证,支持以下方式(按优先级):
- 1. 环境变量凭证
- 配置文件:~/.alibabacloud/credentials.ini
- ECS RAM角色(在ECS上运行时)
建议使用aliyun configure命令配置凭证:
bash
aliyun configure
或参考阿里云凭证配置文档配置默认凭证链。
OSS Bucket配置
OSS上传功能需要通过环境变量配置Bucket信息:
bash
export OSSBUCKET=yourbucket_name
export OSS_ENDPOINT=oss-cn-shanghai.aliyuncs.com
如果未配置OSS_BUCKET,则列出客户当前账号下的Bucket,让客户选择一个作为最终视频的输出Bucket。
OSS操作复用阿里云默认凭证链,无需单独配置OSS凭证。
User-Agent配置
所有阿里云服务调用必须将User-Agent设置为AlibabaCloud-Agent-Skills。
脚本scripts/video_editor.py已自动配置此User-Agent。
工作流程
步骤1:理解用户需求
分析用户想要创建的视频类型:
- - 幻灯片视频(图片轮播)
- 多轨音频混音(配音+音乐)
- 多片段拼接
- 添加字幕/标题
- 特效和转场
- 画中画/分屏效果
步骤2:参考最佳实践
查阅references/中对应的文档:
| 文档 | 适用场景 |
|---|
| 01-timeline-basics.md | 时间线基本结构说明 |
| 02-multi-track-audio.md |
多轨音频混音 |
| 03-subtitles-and-titles.md | 字幕和标题效果 |
| 04-effects-and-transitions.md | 视觉效果和转场 |
| 05-slideshow-template.md | 幻灯片视频模板 |
| 06-multi-clip-editing.md | 多片段视频剪辑 |
步骤3:准备素材URL
- - 如果是本地文件,需要调用oss-upload技能上传并获取OSS URL,可直接拼接到时间线中
- 如果已有URL,可直接拼接到时间线中
步骤4:生成Timeline JSON
根据参考文档生成阿里云ICE格式的Timeline:
json
{
VideoTracks: [...],
AudioTracks: [...],
SubtitleTracks: [...]
}
步骤5:提交剪辑任务
使用脚本提交任务(基于阿里云Common SDK):
bash
提交并等待完成
python scripts/video_editor.py submit \
--timeline timeline.json \
--output-config output.json \
--wait
仅提交,不等待
python scripts/video_editor.py submit \
--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
任务提交后会返回JobId。
步骤6:轮询任务状态
使用脚本查询/等待任务完成:
bash
查询状态
python scripts/video
editor.py status --job-id id>
等待任务完成
python scripts/videoeditor.py status --job-id id> --wait
当任务状态为Success时,根据返回的MediaId调用GetMediaInfo获取带鉴权的OSS URL,并返回。
Timeline示例
最简单的幻灯片
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提示建议
生成Timeline时,按以下思路思考:
- 1. 用户需要什么类型的视频?→ 查找对应的参考文档
- 需要哪些轨道?(视频轨道、音频轨道、字幕轨道)
- 每个轨道中有哪些片段?
- 是否需要设置In/Out/TimelineIn/TimelineOut(简单拼接不需要设置)?如果需要设置,In/Out/TimelineIn/TimelineOut分别是什么?
- 是否需要特效、转场、音量调整等?
- 生成完整的JSON
相关文件
alibabacloud-video-editor/
├── SKILL.md # 本文档
├── references/
│ ├── 01-timeline-basics.md # 时间线基础
│ ├── 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 # Common SDK脚本