Alibaba Cloud Video Forge
One-stop video processing through Alibaba Cloud Media Processing Service (MPS), including cover generation, multi-resolution transcoding, content moderation, and more.
🚀 Quick Start
Easiest Way - One-click video processing:
CODEBLOCK0
Common Scenarios
Scenario 1: Bilibili Video Publishing
CODEBLOCK1
Scenario 2: UGC Content Moderation
CODEBLOCK2
Scenario 3: Multi-Resolution Transcoding
python scripts/mps_transcode.py \
--oss-object /input/course_video.mp4 \
--preset multi \
--output-prefix output/course_2024/
Scenario Description
This skill supports video distribution scenarios:
- 1. Transcoding — Multi-resolution transcoding with Narrowband HD compression
- Content Moderation — Auto-detect sensitive content (pornography, terrorism, advertising)
- Snapshot — Generate cover images and sprite sheets
- Anti-piracy — Configure encryption for content protection
Architecture
CODEBLOCK4
Components:
- - OSS: Store videos and outputs
- MPS Pipeline: Task queue management
- Transcoding Templates: Narrowband HD, Standard presets
- Moderation: Auto content safety checks
Target Users: Video platforms, content creators, corporate training, education platforms
Capability Overview
See references/capability-overview.md for detailed feature tree and automatic pipeline management.
Prerequisites
Pre-check: Aliyun CLI >= 3.3.1 required
Run aliyun version to verify >= 3.3.1. If not installed, see references/cli-installation-guide.md.
Then [MUST] run aliyun configure set --auto-plugin-install true to enable automatic plugin installation.
Pre-check: Python >= 3.10 required
Run python3 --version to verify.
Pre-check: Alibaba Cloud Credentials Required
Run aliyun configure list to check credential status. If no valid profile, configure via aliyun configure.
See references/security-guidelines.md for credential security rules.
Environment Variables
Required environment variables:
- -
ALIBABA_CLOUD_REGION - Service region (default: cn-shanghai) - INLINECODE7 - OSS Bucket name
- INLINECODE8 - OSS endpoint
- INLINECODE9 - MPS Pipeline ID (optional, auto-selected if not set)
Security Note: Credentials are managed via the Alibaba Cloud default credential chain. Configure credentials using aliyun configure command. NEVER handle AK/SK directly in scripts or commands.
🔒 Security Guidelines
See references/security-guidelines.md for complete security guidelines and credential management best practices.
SDK Installation
See references/sdk-installation.md for detailed installation guide and troubleshooting.
Run python3 --version to verify. Some scripts may fail with older Python versions.
RAM Permissions
[MUST] RAM Permission Pre-check: Verify that the current user has the following RAM permissions before execution.
See references/ram-policies.md for complete permission list and details.
[MUST] Permission Failure Handling: When any command or API call fails due to permission errors at any point during execution, follow this process:
- 1. Read
references/ram-policies.md to get the full list of permissions required by this SKILL - Use
ram-permission-diagnose skill to guide the user through requesting the necessary permissions - Pause and wait until the user confirms that the required permissions have been granted
Parameter Confirmation
IMPORTANT: Parameter Confirmation — Before executing any command or API call,
ALL user-customizable parameters (e.g., input video path, output bucket, template ID, etc.)
MUST be confirmed with the user. Do NOT assume or use default values without explicit user approval.
| Parameter | Required/Optional | Description | Default |
|---|
| input-url | Required | Input video URL or local path | - |
| output-bucket |
Optional | Output OSS Bucket | Environment variable value |
| output-path | Optional | Output path prefix | output/ |
| template-id | Optional | Transcoding template ID | System preset template |
| resolutions | Optional | Transcoding resolution list | 720p,1080p |
| audit | Optional | Whether to perform content moderation | true |
| pipeline-id | Optional | MPS Pipeline ID | Auto-select |
Core Workflow
Scenario 1: One-stop Video Standardization
Complete workflow: User provides video → Upload to OSS → Media info probe → Cover generation (snapshot) → Multi-resolution transcoding → Content moderation → Summary results (with download links)
Step 0: Automatic Pipeline Selection (Optional)
This skill supports automatic pipeline management, typically no manual Pipeline ID configuration needed. Scripts automatically select appropriate pipelines based on task type.
To manually specify:
CODEBLOCK5
Step 1: Upload Video to OSS
CODEBLOCK6
Step 2: Media Info Probe
CODEBLOCK7
Step 3: Cover Generation (Snapshot)
Use snapshot function to generate video cover at specified time:
CODEBLOCK8
Step 4: Adaptive Transcoding (Auto-select best resolution and Narrowband HD template)
CODEBLOCK9
Step 5: Content Moderation
CODEBLOCK10
Step 6: Poll Task Status
CODEBLOCK11
Complete Example
CODEBLOCK12
Other Scenarios
Scenario 2: Transcoding Only
Execute transcoding only, without snapshot and moderation:
CODEBLOCK13
Scenario 3: Content Moderation
Execute content moderation only:
CODEBLOCK14
Success Verification
After video processing, check results:
- 1. Script exit code is 0
- Output contains processed media info (OSS path)
- Transcoding job status is "Success"
- Content moderation shows no violations
- Artifacts downloaded locally (using
oss_download.py)
Notes on Artifact Retrieval:
- - OSS files require signing for online access, direct URL access returns 403 error
- Recommend using
oss_download.py to download results locally - For online preview, use
--sign-url parameter to generate temporary pre-signed URL
CODEBLOCK15
Troubleshooting
See references/troubleshooting.md for comprehensive troubleshooting guide.
Cleanup
Intermediate files and output files from this skill are stored in OSS. To clean up:
CODEBLOCK16
Note: Delete operations are irreversible. Confirm before executing. Use --dry-run to preview first.
Available Scripts
| Script | Description |
|---|
| INLINECODE19 | Environment variable loader, auto-scan and load Alibaba Cloud credentials |
| INLINECODE20 |
MPS async task poller, query task status |
|
scripts/oss_upload.py | Upload local file to OSS |
|
scripts/oss_download.py | Download file from OSS to local |
|
scripts/oss_list.py | List files in OSS Bucket |
|
scripts/oss_delete.py | Delete OSS files or directories (supports recursive delete) |
|
scripts/mps_mediainfo.py | Get media file info (resolution, bitrate, duration, etc.) |
|
scripts/mps_snapshot.py | Snapshot and sprite sheet generation (supports normal/sprite mode) |
|
scripts/mps_transcode.py | Video transcoding (supports adaptive Narrowband HD, multi-resolution presets, custom parameters) |
|
scripts/mps_audit.py | Content safety moderation (supports multiple moderation scenarios) |
|
scripts/mps_pipeline.py | Pipeline list query and auto-selection (get Pipeline ID) |
Best Practices
- 1. Always check environment variables first — Run
python scripts/load_env.py --check-only at the start of each session - Use polling instead of waiting — Use
poll_task.py to auto-poll status after submitting jobs - Choose resolutions wisely — Select appropriate transcoding resolutions based on target user devices
- Enable content moderation — For UGC content, always enable automatic moderation
- Use virtual environment — Ensure dependency isolation to avoid version conflicts
- Automatic pipeline management — No need to manually configure Pipeline ID, scripts auto-select appropriate pipelines based on task type
Reference Documentation
Script parameter documentation |
|
references/scripts-detail.md | Detailed script usage examples |
|
references/verification-method.md | Success verification methods |
|
references/related-commands.md | Related CLI commands |
|
references/cli-installation-guide.md | Aliyun CLI installation guide |
|
references/acceptance-criteria.md | Testing acceptance criteria |
CLI Command Standards
Important: If using aliyun CLI commands, all commands MUST include the --user-agent AlibabaCloud-Agent-Skills parameter.
Example: INLINECODE34
阿里云视频锻造
通过阿里云媒体处理服务(MPS)实现一站式视频处理,包括封面生成、多分辨率转码、内容审核等功能。
🚀 快速开始
最简单的方式 - 一键视频处理:
bash
方法1:使用端到端工作流脚本(推荐)
python scripts/video_workflow.py --input /path/to/video.mp4
方法2:先检查环境
python scripts/health_check.py
方法3:手动逐步执行
python scripts/oss_upload.py --local-file video.mp4 --oss-key input/video.mp4
python scripts/mps_transcode.py --oss-object input/video.mp4 --preset multi
python scripts/mps_audit.py --oss-object input/video.mp4
常见场景
场景1:B站视频发布
bash
python scripts/video_workflow.py \
--input my_video.mov \
--preset 720p \
--generate-cover \
--scenes porn terrorism ad
场景2:UGC内容审核
bash
python scripts/mps
audit.py --oss-object /input/useruploaded.mp4
场景3:多分辨率转码
bash
python scripts/mps_transcode.py \
--oss-object /input/course_video.mp4 \
--preset multi \
--output-prefix output/course_2024/
场景描述
本技能支持视频分发场景:
- 1. 转码 — 支持窄带高清压缩的多分辨率转码
- 内容审核 — 自动检测敏感内容(色情、暴恐、广告)
- 截图 — 生成封面图和雪碧图
- 防盗链 — 配置加密以保护内容
架构
OSS存储桶 + MPS管道 + 转码模板 + 审核服务
组件:
- - OSS:存储视频和输出文件
- MPS管道:任务队列管理
- 转码模板:窄带高清、标准预设
- 审核:自动内容安全检查
目标用户:视频平台、内容创作者、企业培训、教育平台
能力概览
详细功能树和自动管道管理请参见 references/capability-overview.md。
前置条件
预检:需要阿里云CLI >= 3.3.1
运行 aliyun version 验证版本 >= 3.3.1。如未安装,请参见 references/cli-installation-guide.md。
然后 [必须] 运行 aliyun configure set --auto-plugin-install true 启用自动插件安装。
预检:需要Python >= 3.10
运行 python3 --version 验证。
预检:需要阿里云凭证
运行 aliyun configure list 检查凭证状态。如无有效配置文件,通过 aliyun configure 配置。
凭证安全规则请参见 references/security-guidelines.md。
环境变量
必需的环境变量:
- - ALIBABACLOUDREGION - 服务地域(默认:cn-shanghai)
- ALIBABACLOUDOSSBUCKET - OSS存储桶名称
- ALIBABACLOUDOSSENDPOINT - OSS接入点
- ALIBABACLOUDMPSPIPELINEID - MPS管道ID(可选,未设置时自动选择)
安全提示: 凭证通过阿里云默认凭证链管理。使用 aliyun configure 命令配置凭证。切勿在脚本或命令中直接处理AK/SK。
🔒 安全指南
完整安全指南和凭证管理最佳实践请参见 references/security-guidelines.md。
SDK安装
详细安装指南和故障排除请参见 references/sdk-installation.md。
运行 python3 --version 验证。较旧Python版本可能导致某些脚本失败。
RAM权限
[必须] RAM权限预检: 执行前验证当前用户具有以下RAM权限。
完整权限列表和详情请参见 references/ram-policies.md。
[必须] 权限失败处理: 执行过程中任何命令或API调用因权限错误失败时,按以下流程处理:
- 1. 阅读 references/ram-policies.md 获取本技能所需完整权限列表
- 使用 ram-permission-diagnose 技能引导用户申请必要权限
- 暂停并等待用户确认所需权限已授予
参数确认
重要:参数确认 — 在执行任何命令或API调用前,
所有用户可自定义参数(如输入视频路径、输出存储桶、模板ID等)
必须与用户确认。未经用户明确批准,不得假设或使用默认值。
| 参数 | 必需/可选 | 描述 | 默认值 |
|---|
| input-url | 必需 | 输入视频URL或本地路径 | - |
| output-bucket |
可选 | 输出OSS存储桶 | 环境变量值 |
| output-path | 可选 | 输出路径前缀 | output/ |
| template-id | 可选 | 转码模板ID | 系统预设模板 |
| resolutions | 可选 | 转码分辨率列表 | 720p,1080p |
| audit | 可选 | 是否执行内容审核 | true |
| pipeline-id | 可选 | MPS管道ID | 自动选择 |
核心工作流
场景1:一站式视频标准化
完整工作流:用户提供视频 → 上传至OSS → 媒体信息探测 → 封面生成(截图) → 多分辨率转码 → 内容审核 → 结果汇总(含下载链接)
步骤0:自动管道选择(可选)
本技能支持自动管道管理,通常无需手动配置管道ID。脚本根据任务类型自动选择合适的管道。
如需手动指定:
bash
方法1:设置环境变量(最高优先级)
export ALIBABA
CLOUDMPS
PIPELINEID=your-pipeline-id
方法2:命令行参数
python scripts/mps_transcode.py --oss-object /input/video.mp4 --pipeline-id your-pipeline-id
方法3:使用脚本自动选择
export ALIBABA
CLOUDMPS
PIPELINEID=$(python scripts/mps_pipeline.py --select)
步骤1:上传视频至OSS
bash
source .venv/bin/activate
python scripts/oss_upload.py --local-file /path/to/video.mp4 --oss-key input/video.mp4
步骤2:媒体信息探测
bash
python scripts/mps_mediainfo.py --oss-object /input/video.mp4
步骤3:封面生成(截图)
使用截图功能在指定时间点生成视频封面:
bash
python scripts/mps_snapshot.py --oss-object /input/video.mp4 --mode normal --time 5000
步骤4:自适应转码(自动选择最佳分辨率和窄带高清模板)
bash
自适应模式:自动检测源视频分辨率,选择最佳质量,使用窄带高清模板
python scripts/mps_transcode.py --oss-object /input/video.mp4
或手动指定多路转码
python scripts/mps_transcode.py \
--oss-object /input/video.mp4 \
--preset multi
步骤5:内容审核
bash
python scripts/mps_audit.py --oss-object /input/video.mp4
步骤6:轮询任务状态
bash
python scripts/poll_task.py --job-id <步骤4返回的任务ID> --job-type transcode --region cn-shanghai
完整示例
bash
1. 激活虚拟环境
source .venv/bin/activate
2. 上传视频
python scripts/oss
upload.py --local-file ./myvideo.mp4 --oss-key input/my_video.mp4
3. 获取媒体信息
python scripts/mps
mediainfo.py --oss-object /input/myvideo.mp4
4. 封面生成(5秒处截图)
python scripts/mps
snapshot.py --oss-object /input/myvideo.mp4 --mode normal --time 5000
5. 提交转码任务(自适应模式:自动选择最佳分辨率)
python scripts/mps_transcode.py \
--oss-object /input/my_video.mp4
保存返回的job-id
6. 轮询转码任务状态
python scripts/poll_task.py --job-id
--job-type transcode --region cn-shanghai --interval 10
7. 内容审核
python scripts/mpsaudit.py --oss-object /input/myvideo