ym-mediatoolkit
流式视频处理工具集 - 压缩、封面提取、音频转换,无需下载完整视频
Install via CLI (Recommended)
clawhub install openclaw/skills/skills/370299455cx-web/ym-mediatoolkitYM MediatoolToolkit
概述
一个高性能的流式视频处理 Skill,无需下载完整视频文件即可完成:
- 视频压缩 - 保持清晰度,体积可压缩至 1/10
- 封面提取 - 任意时间点或帧号提取封面
- 音频提取 - 转成 MP3 / WAV / AAC / M4A 格式
所有操作均采用流式处理,边下载边处理,大幅节省时间和磁盘空间。
安全特性
URL 验证 (SSRF/LFI 防护)
utils.validate_video_url() 在所有入口点和子进程调用前执行多层验证:
| 层级 | 检查项 | 防护目标 |
|---|---|---|
| 协议 | 仅允许 http:// / https:// | LFI (file://)、协议走私 |
| 字符 | 拦截 IDN/Unicode 同形字、Punycode (xn--) | 域名欺骗攻击 |
| IP 模式 | 正则匹配 + ipaddress 库双重校验私有 IP 段 (10.x/172.16-31.x/192.168.x/127.x/169.254.x/0.x) | IP 直连 SSRF |
| DNS 解析 | socket.getaddrinfo 解析域名 → ipaddress 检查所有解析 IP (IPv4+IPv6) | DNS 绑定到私有 IP 的 SSRF |
| IPv6 | 检查 ::1、fe80::、fc00::/fdff::、::ffff:0:0 (IPv4-mapped) | IPv6 SSRF |
DNS 错误策略:如果 DNS 解析失败(超时/网络错误),验证将拒绝请求(fail-close),而非放行。这是与早期版本的区别——之前版本在 DNS 失败时会发出警告并允许通过。
输出路径防护
utils.sanitize_output_path() 对所有用户提供的 output_path、save_path、output_dir 执行检查:
| 检查项 | 说明 |
|---|---|
| 路径穿越 | 拒绝包含 .. 的路径 |
| 保留设备名 | 拒绝 CON/NUL/COM1 等系统保留名 |
| 越界写入 | 拒绝解析后超出工作目录的路径 |
路径清理在所有入口点执行:
run.py—handle_compress、handle_thumbnail、handle_audio、handle_audio_batchaudio_extractor.py—extract_audio_streaming、extract_audio_batchframe_extractor.py—extract_thumbnail_from_url
快速开始
1. 安装依赖
pip install -r requirements.txt
2. 通过命令行使用
提供 JSON 参数:
# 压缩视频
python run.py -a compress -i '{"video_url": "https://example.com/video.mp4", "target_ratio": 0.1}'
# 提取封面(第 0 秒)
python run.py -a thumbnail -i '{"video_url": "https://example.com/video.mp4"}'
# 提取音频
python run.py -a audio -i '{"video_url": "https://example.com/video.mp4", "format": "mp3"}'
3. 通过配置文件
python run.py -i params.json
4. 启动 HTTP 服务
# 启动 API 服务
python run.py --serve
# 默认监听 127.0.0.1:8080(仅本地访问)
HTTP 模式需要 Flask:
pip install flask flask-cors
API 参考
所有端点接收 JSON body,响应 JSON。
POST /skill/compress
流式压缩视频。
请求参数:
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
video_url | string | 必填 | 视频 URL(仅 http/https) |
target_ratio | number | 0.1 | 目标体积比例 |
adaptive | boolean | true | 是否自动调整 CRF |
crf | integer | 24 | CRF 值(18-28) |
preset | string | "veryfast" | 编码预设 |
output_path | string | 自动生成 | 输出路径 |
响应示例:
{
"status": "success",
"output_path": "compressed_video.mp4",
"original_size_mb": 150.5,
"new_size_mb": 12.3,
"ratio": 0.082,
"crf_used": 24,
"streaming": true
}
POST /skill/thumbnail
从视频提取封面。
请求参数:
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
video_url | string | 必填 | 视频 URL |
time_seconds | number | 0 | 提取时间点(秒) |
frame_number | integer | - | 指定帧号(优先级高于 time) |
save_path | string | 不保存 | 封面保存路径 |
resize_width | integer | 原尺寸 | 缩放宽度 |
quality | integer | 85 | JPEG 质量(1-100) |
响应示例:
Metadata
Not sure this is the right skill?
Describe what you want to build — we'll match you to the best skill from 16,000+ options.
Find the right skillPaste this into your clawhub.json to enable this plugin.
{
"plugins": {
"official-370299455cx-web-ym-mediatoolkit": {
"enabled": true,
"auto_update": true
}
}
}Tags
Related Skills
doctorbot-ci-validator
Stop failing in production. Validate your GitHub Actions, GitLab CI & Keep workflows offline with surgical precision. Born from Keep bounty research, perfected for agents.
arc-shield
Output sanitization for agent responses - prevents accidental secret leaks
AURA Security Scanner
Scan AI agent skills for malware, credential theft, prompt injection, and dangerous permissions before installing them
context-compressor
Intelligently compress context — conversations, code, logs. Preserve key information while reducing token usage. Auto-detects content type and applies optimal compression.
sbom-explainer
把依赖清单或 SBOM 翻译成非技术可读的风险说明,按影响面排序。;use for sbom, dependencies, risk workflows;do not use for 伪造 CVE 状态, 替代专业漏洞扫描.