2026-04-19 23:24:28 +00:00
---
name: video-product-snapshot
2026-04-25 07:13:07 +00:00
description: "Detect ecommerce products in video frames using Claude Vision, extract the best product snapshot, and optionally search via image-search API. Use when the user provides a video and wants to find/identify products shown in it. / 检测视频中的商品, 提取最佳商品截图, 并通过图片搜索在1688找同款。当用户提供视频想找商品时使用。"
2026-04-19 23:24:28 +00:00
---
2026-04-25 07:13:07 +00:00
# Video Product Snapshot — 视频商品截图
2026-04-19 23:24:28 +00:00
2026-04-25 07:13:07 +00:00
从视频中提取最佳商品画面,通过 Claude Vision 检测并截取,然后在 1688 上以图搜图 + 关键词重排序找到同款商品。
2026-04-19 23:24:28 +00:00
2026-04-25 07:13:07 +00:00
## 运行
2026-04-19 23:24:28 +00:00
```bash
bun dist/run.js < command > [args] [--dry-run]
```
2026-04-25 07:13:07 +00:00
## 命令列表
2026-04-19 23:24:28 +00:00
2026-04-25 07:13:07 +00:00
| 命令 | 使用场景 |
|------|---------|
2026-04-25 08:30:01 +00:00
| `detect-video-and-search <video>` | **推荐。** 直接上传视频到 API 识别商品主体,然后 1688 关键词搜索。跳过本地抽帧,无需 Vision API。 |
| `detect-best-and-search <video>` | 旧版。抽帧 + Vision 排名 + 搜图。需要 Vision API key。 |
| `detect-video <video>` | 只识别商品描述和生成关键词,不搜图。 |
| `detect-best <video>` | 旧版。只提取最佳画面,不搜图。 |
2026-04-25 07:13:07 +00:00
| `search <image-path>` | 已经有商品截图了,跳过检测直接搜图。 |
2026-04-25 08:30:01 +00:00
| `detect-and-search <video>` | 旧版。**不推荐。** |
2026-04-25 07:13:07 +00:00
| `session` | 获取当前认证会话 token。 |
2026-04-19 23:24:28 +00:00
2026-04-25 08:30:01 +00:00
## `detect-video` / `detect-video-and-search`
上传视频到 API 直接识别商品主体,不走本地抽帧。
流程:
1. 上传视频 → 获取公开 URL( 复用现有上传接口)
2. 调用 LiteLLM( Chat Completions + `video_url` )分析视频内容
3. 识别商品名称、材质、颜色、功能
4. 生成中文搜索关键词
5. 1688 关键词搜索(`detect-video-and-search`)
依赖:
- `auth-rt` client key( 自动, 无需额外配置)
- LiteLLM 代理支持 `video_url` 内容类型
- 上传接口返回公开 URL
2026-04-25 07:13:07 +00:00
## `detect-best` / `detect-best-and-search` 选项
2026-04-19 23:24:28 +00:00
2026-04-25 07:13:07 +00:00
| 参数 | 默认值 | 说明 |
|------|--------|------|
| `--interval=<秒>` | `0.5` | 抽帧间隔(秒) |
| `--max-frames=<数量>` | `60` | 最多抽帧数 |
| `--output-dir=<目录>` | 视频同目录 | 帧图片保存目录 |
2026-04-19 23:24:28 +00:00
2026-04-25 07:13:07 +00:00
## 画面选择原理
2026-04-19 23:24:28 +00:00
2026-04-25 07:13:07 +00:00
两轮 Vision 流水线:
2026-04-19 23:24:28 +00:00
2026-04-25 07:13:07 +00:00
1. **过滤轮** (仅 `detect` / `detect-and-search` )—— 每帧二分类:保留/丢弃。可能过于严格返回空。
2. **排名轮** —— 所有候选帧一起发给模型,从中选出最清晰、最完整、最突出的一张商品图。
2026-04-19 23:24:28 +00:00
2026-04-25 07:13:07 +00:00
`detect-best` 跳过第一轮,所有帧直接进排名轮。超过 20 帧时会均匀采样到 20 帧再调用。**只要视频能出帧,就一定返回结果。**
2026-04-19 23:24:28 +00:00
2026-04-25 07:13:07 +00:00
## 输出格式
2026-04-19 23:24:28 +00:00
```json
{
2026-04-25 07:13:07 +00:00
"bestSnapshot": {
"frameIndex": 4,
"timestampSeconds": 2,
"imagePath": "/path/to/frame_0004.jpg",
"croppedImagePath": "/path/to/frame_0004_cropped.jpg",
"confidence": 0.95,
"description": "White sneaker with blue logo, left side view",
"boundingHint": "Product fully visible, centered, no hands"
},
"rerank": {
"results": [...]
}
2026-04-19 23:24:28 +00:00
}
```
2026-04-25 07:13:07 +00:00
## 结果展示格式
2026-04-22 00:23:35 +00:00
2026-04-25 07:13:07 +00:00
CLI 执行完成后,将 `rerank.results` 格式化为 markdown 表格,**每页 5 行**(如不足 5 行则全显示)。
2026-04-22 00:23:35 +00:00
| # | 商品名称 | 价格 | 销量 | 链接 |
|---|----------|------|------|------|
| 1 | {title} | ¥{promotion_price \|\| price} | {sales ?? —}件 | [查看 ](https://detail.1688.com/offer/{num_iid}.html ) |
2026-04-25 07:13:07 +00:00
- 有 `promotion_price` 用促销价,否则用原价
- `sales` 缺失或为零时显示 `—`
- 始终用 markdown 表格展示,不要用列表
## 执行规则
2026-04-22 00:23:35 +00:00
2026-04-25 07:13:07 +00:00
### 视频命令(慢 — 用 sub-agent 执行)
2026-04-19 23:24:28 +00:00
2026-04-25 08:30:01 +00:00
涉及命令:`detect-video-and-search`、`detect-best-and-search`、`detect-best`、`detect-and-search`、`detect-video`
2026-04-21 00:20:37 +00:00
2026-04-25 07:13:07 +00:00
使用 `sessions_spawn` 创建 sub-agent 执行,**不要直接运行**。
2026-04-21 00:20:37 +00:00
```
sessions_spawn(
2026-04-25 07:13:07 +00:00
task: "Run this command and return the raw JSON output:\n\nbun dist/run.js < 完整命令 > \n\nCopy the entire JSON output as your reply.",
2026-04-21 00:20:37 +00:00
label: "video-product-snapshot",
runTimeoutSeconds: 300,
)
```
2026-04-25 07:13:07 +00:00
- 通知用户处理已开始,告知 `runId`
- 等待 sub-agent 返回结果,然后解析并展示
2026-04-21 00:20:37 +00:00
2026-04-25 07:13:07 +00:00
### `search` 和 `session`(快 — 直接运行)
2026-04-21 00:20:37 +00:00
2026-04-25 07:13:07 +00:00
直接在本会话中运行,不需要 sub-agent。
2026-04-21 00:20:37 +00:00
2026-04-25 07:13:07 +00:00
### 通用规则
2026-04-21 00:20:37 +00:00
2026-04-25 08:30:01 +00:00
1. **视频输入 → 优先用 `detect-video-and-search`。** 比抽帧方案更可靠。如果没配视频模型,降级到 `detect-best-and-search` 。不要用 `detect-and-search` 。
2026-04-25 07:13:07 +00:00
2. **不要重试。** 命令失败就直接报错。
3. **信任工具输出。** CLI 内部已处理 session 管理和错误格式化。