Files
hack/tools/scripts/llm-key-hunter/results/_cache/content/agentchengfeng_video-analyzer-skill.json
T

1 line
4.7 KiB
JSON
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{"repo": "agentchengfeng/video-analyzer-skill", "files": {"SKILL.md": {"5f0fa09feb18763423fbf2ff7e8583723affbee9": {"t": 1785674253.1585972, "n": 3079, "h": "f436ca0f85d8e35b", "c": "---\nname: video-analyzer\ndescription: 视频内容分析。当用户提到\"分析视频\"、\"视频分析\"、\"看看这个视频\"、\"这个视频讲了什么\"、\"视频笔记\"、\"总结视频\"时触发。支持 B站、YouTube 等平台链接和本地视频文件。\n---\n\n<!--\ninput: 视频 URL 或本地文件路径\noutput: 视频内容的详细分析笔记(含时间戳)\npos: 核心 skill,视频理解能力\n-->\n\n# 视频内容分析\n\n下载视频 → 压缩 → Files API 上传 → Responses API 分析。一次 API 调用出完整结果。\n\n## 依赖\n\n- `yt-dlp`(brew install yt-dlp)\n- `ffmpeg`(brew install ffmpeg)\n\n## 步骤\n\n### 1. 读取配置\n\n```bash\n# 从 ~/.claude/skills/video-analyzer/config/secrets.md 读取\nAPI_KEY=\"your-api-key-here\"\nAPI_URL=\"https://ark.cn-beijing.volces.com/api/v3/responses\"\nMODEL=\"doubao-seed-2-0-pro-260215\"\n```\n\n### 2. 获取视频\n\n**本地文件**:直接用。\n\n**在线视频**(B站/YouTube 等):\n```bash\nyt-dlp -f \"bv*+ba/b\" -o \"/tmp/video-analyzer-%(id)s.%(ext)s\" --no-playlist \"URL\"\n```\n\nB站高清需要 Cookie:\n```bash\nyt-dlp --cookies-from-browser chrome -f \"bv*+ba/b\" -o \"/tmp/video-analyzer-%(id)s.%(ext)s\" --no-playlist \"URL\"\n```\n\n### 3. 压缩(超过 100MB 时)\n\n```bash\nffmpeg -i \"输入文件\" -vf \"scale='min(720,iw)':-2\" -c:v libx264 -crf 28 -preset fast -c:a aac -b:a 64k -y /tmp/video-analyzer-compressed.mp4\n```\n\n实测效果:327MB → 74MB。如果还大,加 `-crf 32` 或 `-t 600` 截前 10 分钟。\n\n### 4. 上传 Files API\n\n```bash\ncurl -s https://ark.cn-beijing.volces.com/api/v3/files \\\n -H \"Authorization: Bearer $API_KEY\" \\\n -F \"purpose=user_data\" \\\n -F \"file=@/tmp/video-analyzer-compressed.mp4\"\n```\n\n返回 `{\"id\": \"file-xxx\", \"status\": \"processing\"}`,提取 `id` 即 file_id。\n\n### 5. 等待文件处理完成\n\n文件上传后状态为 `processing`,必须等处理完才能调用分析。\n\n| 文件大小 | 等待时间 |\n|---------|---------|\n| < 30MB | sleep 15 |\n| 30-100MB | sleep 45 |\n| > 100MB | sleep 60,或轮询状态 |\n\n如果调用分析返回 `OperationDenied.InvalidState` 说明还没处理完,再等 15 秒重试。\n\n### 6. 调用 Responses API\n\n```bash\ncurl -s \"$API_URL\" \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer $API_KEY\" \\\n -d '{\n \"model\": \"'\"$MODEL\"'\",\n \"input\": [{\n \"role\": \"user\",\n \"content\": [\n {\"type\": \"input_video\", \"file_id\": \"'\"$FILE_ID\"'\"},\n {\"type\": \"input_text\", \"text\": \"提示词\"}\n ]\n }]\n }'\n```\n\n**关键**:用 `\"file_id\"` 字段引用视频,不要用 `\"video_url\"` 传 file_id(会报 `invalid scheme`)。\n\n### 7. 默认提示词\n\n```\n你是一个视频内容分析助手。请按时间线详细梳理视频内容,要求:\n1. 标注准确的时间戳 [mm:ss]\n2. 提取所有关键信息:讲解的知识点、出现的文字、图表、公式、人物动作、场景变化\n3. 生成结构化的内容笔记\n请用中文详细回答。\n```\n\n用户可指定侧重点(\"重点分析代码\"、\"提取公式\"、\"总结观点\"),融入 prompt。\n\n### 8. 解析响应\n\n响应 `output` 数组包含两类:\n- `\"type\": \"reasoning\"` — 模型思考过程(忽略)\n- `\"type\": \"message\"` — 最终结果,取 `content[].text`\n\n```python\nfor item in result[\"output\"]:\n if item[\"type\"] == \"message\":\n for c in item[\"content\"]:\n if c[\"type\"] == \"output_text\":\n print(c[\"text\"])\n```\n\n### 9. 清理\n\n```bash\nrm -f /tmp/video-analyzer-*\n```\n\n### 10. 输出格式\n\n拿到原始分析后,根据用户意图决定输出详细程度:\n- 用户说\"分析视频\"、\"视频笔记\" → 直接输出完整笔记\n- 用户说\"简单描述\"、\"讲了什么\" → 用自己的话精简概括,不贴原文\n\n## 踩坑记录\n\n| 问题 | 原因 | 解决 |\n|------|------|------|\n| `invalid scheme` | 用 `video_url` 传了 file_id | 改用 `file_id` 字段 |\n| `OperationDenied.InvalidState` | 文件还在 processing | 多等一会儿再调用 |\n| 429 RequestBurstTooFast | base64 直传请求体太大触发突发保护 | 改用 Files API 上传,不要用 base64 |\n| `input_file` 报 not pdf | `input_file` 类型只支持 PDF | 视频用 `input_video` + `file_id` |\n| yt-dlp 下载 480p | B站高清需登录 | 加 `--cookies-from-browser chrome` |\n"}}}}