[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6E3QWEF8ZK525XEFF92R51F":3,"skill-same:01M6E3QWEF8ZK525XEFF92R51F":103},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":28,"linkOnly":29,"markdownContent":30,"markdownBody":31,"frontMatter":32,"refName":36,"commitSha":37,"skillDirectory":38,"forksCount":13,"repositoryHtmlUrl":39,"repositoryHomepageUrl":40,"ownerHtmlUrl":41,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":42,"install":43,"resources":56},"01M6E3QWEF8ZK525XEFF92R51F","videodb",null,"视频与音频的查看、理解与行动。查看：从本地文件、URL、RTSP\u002F直播源或实时录制桌面获取内容；返回实时上下文和可播放流链接。理解：提取帧，构建视觉\u002F语义\u002F时间索引，并通过时间戳和自动剪辑搜索片段。行动：转码和标准化（编解码器、帧率、分辨率、宽高比），执行时间线编辑（字幕、文本\u002F图像叠加、品牌化、音频叠加、配音、翻译），生成媒体资源（图像、音频、视频），并为直播流或桌面捕获的事件创建实时警报。","7dvq6yrkgs-stack\u002Fplaywright","7dvq6yrkgs-stack","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F251638143?v=4","01M6E061J2AMGWYZ6TK7Y8NM74","01M6E061PQCQJGQMPBERMCFN5G",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002F7dvq6yrkgs-stack\u002Fplaywright\u002Fblob\u002Fmain\u002Fskills\u002Fvideodb\u002FSKILL.md",[],[5,18,19,20,21,22,23,24,25,26,27],"python","Bash","视频","生成","文本","翻译","grep","read","task","搜索","2026-11-10 10:12:30",false,"---\nname: videodb\ndescription: 视频与音频的查看、理解与行动。查看：从本地文件、URL、RTSP\u002F直播源或实时录制桌面获取内容；返回实时上下文和可播放流链接。理解：提取帧，构建视觉\u002F语义\u002F时间索引，并通过时间戳和自动剪辑搜索片段。行动：转码和标准化（编解码器、帧率、分辨率、宽高比），执行时间线编辑（字幕、文本\u002F图像叠加、品牌化、音频叠加、配音、翻译），生成媒体资源（图像、音频、视频），并为直播流或桌面捕获的事件创建实时警报。\norigin: ECC\nallowed-tools: Read Grep Glob Bash(python:*)\nargument-hint: \"[task description]\"\n---\n\n# VideoDB 技能\n\n**针对视频、直播流和桌面会话的感知 + 记忆 + 操作。**\n\n## 使用场景\n\n### 桌面感知\n\n* 启动\u002F停止**桌面会话**，捕获**屏幕、麦克风和系统音频**\n* 流式传输**实时上下文**并存储**片段式会话记忆**\n* 对所说的内容和屏幕上发生的事情运行**实时警报\u002F触发器**\n* 生成**会话摘要**、可搜索的时间线和**可播放的证据链接**\n\n### 视频摄取 + 流\n\n* 摄取**文件或URL**并返回**可播放的网络流链接**\n* 转码\u002F标准化：**编解码器、比特率、帧率、分辨率、宽高比**\n\n### 索引 + 搜索（时间戳 + 证据）\n\n* 构建**视觉**、**语音**和**关键词**索引\n* 搜索并返回带有**时间戳**和**可播放证据**的精确时刻\n* 从搜索结果自动创建**片段**\n\n### 时间线编辑 + 生成\n\n* 字幕：**生成**、**翻译**、**烧录**\n* 叠加层：**文本\u002F图片\u002F品牌标识**，动态字幕\n* 音频：**背景音乐**、**画外音**、**配音**\n* 通过**时间线操作**进行程序化合成和导出\n\n### 直播流（RTSP）+ 监控\n\n* 连接**RTSP\u002F实时流**\n* 运行**实时视觉和语音理解**，并为监控工作流发出**事件\u002F警报**\n\n## 工作原理\n\n### 常见输入\n\n* 本地**文件路径**、公共**URL**或**RTSP URL**\n* 桌面捕获请求：**启动 \u002F 停止 \u002F 总结会话**\n* 期望的操作：获取理解上下文、转码规格、索引规格、搜索查询、片段范围、时间线编辑、警报规则\n\n### 常见输出\n\n* **流URL**\n* 带有**时间戳**和**证据链接**的搜索结果\n* 生成的资产：字幕、音频、图片、片段\n* 用于直播流的**事件\u002F警报负载**\n* 桌面**会话摘要**和记忆条目\n\n### 运行 Python 代码\n\n在运行任何 VideoDB 代码之前，请切换到项目目录并加载环境变量：\n\n```python\nfrom dotenv import load_dotenv\nload_dotenv(\".env\")\n\nimport videodb\nconn = videodb.connect()\n```\n\n这会从以下位置读取 `VIDEO_DB_API_KEY`：\n\n1. 环境变量（如果已导出）\n2. 项目当前目录中的 `.env` 文件\n\n如果密钥缺失，`videodb.connect()` 会自动引发 `AuthenticationError`。\n\n当简短的內联命令有效时，不要编写脚本文件。\n\n编写內联 Python (`python -c \"...\"`) 时，始终使用格式正确的代码——使用分号分隔语句并保持可读性。对于任何超过约3条语句的内容，请改用 heredoc：\n\n```bash\npython \u003C\u003C 'EOF'\nfrom dotenv import load_dotenv\nload_dotenv(\".env\")\n\nimport videodb\nconn = videodb.connect()\ncoll = conn.get_collection()\nprint(f\"Videos: {len(coll.get_videos())}\")\nEOF\n```\n\n### 设置\n\n当用户要求“设置 videodb”或类似操作时：\n\n### 1. 安装 SDK\n\n```bash\npip install \"videodb[capture]\" python-dotenv\n```\n\n如果在 Linux 上 `videodb[capture]` 失败，请安装不带捕获扩展的版本：\n\n```bash\npip install videodb python-dotenv\n```\n\n### 2. 配置 API 密钥\n\n用户必须使用**任一**方法设置 `VIDEO_DB_API_KEY`：\n\n* **在终端中导出**（在启动 Claude 之前）：`export VIDEO_DB_API_KEY=your-key`\n* **项目 `.env` 文件**：将 `VIDEO_DB_API_KEY=your-key` 保存在项目的 `.env` 文件中\n\n免费获取 API 密钥，请访问 [console.videodb.io](https:\u002F\u002Fconsole.videodb.io)（50 次免费上传，无需信用卡）。\n\n**请勿**自行读取、写入或处理 API 密钥。始终让用户设置。\n\n### 快速参考\n\n### 上传媒体\n\n```python\n# URL\nvideo = coll.upload(url=\"https:\u002F\u002Fexample.com\u002Fvideo.mp4\")\n\n# YouTube\nvideo = coll.upload(url=\"https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=VIDEO_ID\")\n\n# Local file\nvideo = coll.upload(file_path=\"\u002Fpath\u002Fto\u002Fvideo.mp4\")\n```\n\n### 转录 + 字幕\n\n```python\n# force=True skips the error if the video is already indexed\nvideo.index_spoken_words(force=True)\ntext = video.get_transcript_text()\nstream_url = video.add_subtitle()\n```\n\n### 在视频内搜索\n\n```python\nfrom videodb.exceptions import InvalidRequestError\n\nvideo.index_spoken_words(force=True)\n\n# search() raises InvalidRequestError when no results are found.\n# Always wrap in try\u002Fexcept and treat \"No results found\" as empty.\ntry:\n    results = video.search(\"product demo\")\n    shots = results.get_shots()\n    stream_url = results.compile()\nexcept InvalidRequestError as e:\n    if \"No results found\" in str(e):\n        shots = []\n    else:\n        raise\n```\n\n### 场景搜索\n\n```python\nimport re\nfrom videodb import SearchType, IndexType, SceneExtractionType\nfrom videodb.exceptions import InvalidRequestError\n\n# index_scenes() has no force parameter — it raises an error if a scene\n# index already exists. Extract the existing index ID from the error.\ntry:\n    scene_index_id = video.index_scenes(\n        extraction_type=SceneExtractionType.shot_based,\n        prompt=\"Describe the visual content in this scene.\",\n    )\nexcept Exception as e:\n    match = re.search(r\"id\\s+([a-f0-9]+)\", str(e))\n    if match:\n        scene_index_id = match.group(1)\n    else:\n        raise\n\n# Use score_threshold to filter low-relevance noise (recommended: 0.3+)\ntry:\n    results = video.search(\n        query=\"person writing on a whiteboard\",\n        search_type=SearchType.semantic,\n        index_type=IndexType.scene,\n        scene_index_id=scene_index_id,\n        score_threshold=0.3,\n    )\n    shots = results.get_shots()\n    stream_url = results.compile()\nexcept InvalidRequestError as e:\n    if \"No results found\" in str(e):\n        shots = []\n    else:\n        raise\n```\n\n### 时间线编辑\n\n**重要提示：** 在构建时间线之前，请务必验证时间戳：\n\n* `start` 必须 >= 0（负值会被静默接受，但会产生损坏的输出）\n* `start` 必须 \u003C `end`\n* `end` 必须 \u003C= `video.length`\n\n```python\nfrom videodb.timeline import Timeline\nfrom videodb.asset import VideoAsset, TextAsset, TextStyle\n\ntimeline = Timeline(conn)\ntimeline.add_inline(VideoAsset(asset_id=video.id, start=10, end=30))\ntimeline.add_overlay(0, TextAsset(text=\"The End\", duration=3, style=TextStyle(fontsize=36)))\nstream_url = timeline.generate_stream()\n```\n\n### 转码视频（分辨率 \u002F 质量更改）\n\n```python\nfrom videodb import TranscodeMode, VideoConfig, AudioConfig\n\n# Change resolution, quality, or aspect ratio server-side\njob_id = conn.transcode(\n    source=\"https:\u002F\u002Fexample.com\u002Fvideo.mp4\",\n    callback_url=\"https:\u002F\u002Fexample.com\u002Fwebhook\",\n    mode=TranscodeMode.economy,\n    video_config=VideoConfig(resolution=720, quality=23, aspect_ratio=\"16:9\"),\n    audio_config=AudioConfig(mute=False),\n)\n```\n\n### 调整宽高比（适用于社交平台）\n\n**警告：** `reframe()` 是一项缓慢的服务器端操作。对于长视频，可能需要几分钟，并可能超时。最佳实践：\n\n* 尽可能使用 `start`\u002F`end` 限制为短片段\n* 对于全长视频，使用 `callback_url` 进行异步处理\n* 先在 `Timeline` 上修剪视频，然后调整较短结果的宽高比\n\n```python\nfrom videodb import ReframeMode\n\n# Always prefer reframing a short segment:\nreframed = video.reframe(start=0, end=60, target=\"vertical\", mode=ReframeMode.smart)\n\n# Async reframe for full-length videos (returns None, result via webhook):\nvideo.reframe(target=\"vertical\", callback_url=\"https:\u002F\u002Fexample.com\u002Fwebhook\")\n\n# Presets: \"vertical\" (9:16), \"square\" (1:1), \"landscape\" (16:9)\nreframed = video.reframe(start=0, end=60, target=\"square\")\n\n# Custom dimensions\nreframed = video.reframe(start=0, end=60, target={\"width\": 1280, \"height\": 720})\n```\n\n### 生成式媒体\n\n```python\nimage = coll.generate_image(\n    prompt=\"a sunset over mountains\",\n    aspect_ratio=\"16:9\",\n)\n```\n\n## 错误处理\n\n```python\nfrom videodb.exceptions import AuthenticationError, InvalidRequestError\n\ntry:\n    conn = videodb.connect()\nexcept AuthenticationError:\n    print(\"Check your VIDEO_DB_API_KEY\")\n\ntry:\n    video = coll.upload(url=\"https:\u002F\u002Fexample.com\u002Fvideo.mp4\")\nexcept InvalidRequestError as e:\n    print(f\"Upload failed: {e}\")\n```\n\n### 常见问题\n\n| 场景 | 错误信息 | 解决方案 |\n|----------|--------------|----------|\n| 为已索引的视频建立索引 | `Spoken word index for video already exists` | 使用 `video.index_spoken_words(force=True)` 跳过已索引的情况 |\n| 场景索引已存在 | `Scene index with id XXXX already exists` | 使用 `re.search(r\"id\\s+([a-f0-9]+)\", str(e))` 从错误中提取现有的 `scene_index_id` |\n| 搜索无匹配项 | `InvalidRequestError: No results found` | 捕获异常并视为空结果 (`shots = []`) |\n| 调整宽高比超时 | 长视频上无限期阻塞 | 使用 `start`\u002F`end` 限制片段，或传递 `callback_url` 进行异步处理 |\n| Timeline 上的负时间戳 | 静默产生损坏的流 | 在创建 `VideoAsset` 之前，始终验证 `start >= 0` |\n| `generate_video()` \u002F `create_collection()` 失败 | `Operation not allowed` 或 `maximum limit` | 计划限制的功能——告知用户关于计划限制 |\n\n## 示例\n\n### 规范提示\n\n* \"开始桌面捕获，并在密码字段出现时发出警报。\"\n* \"记录我的会话并在结束时生成可操作的摘要。\"\n* \"摄取此文件并返回可播放的流链接。\"\n* \"为此文件夹建立索引，并找到每个有人的场景，返回时间戳。\"\n* \"生成字幕，将其烧录进去，并添加轻背景音乐。\"\n* \"连接此 RTSP URL，并在有人进入区域时发出警报。\"\n\n### 屏幕录制（桌面捕获）\n\n使用 `ws_listener.py` 在录制会话期间捕获 WebSocket 事件。桌面捕获仅支持 **macOS**。\n\n#### 快速开始\n\n1. **选择状态目录**：`STATE_DIR=\"${VIDEODB_EVENTS_DIR:-$HOME\u002F.local\u002Fstate\u002Fvideodb}\"`\n2. **启动监听器**：`VIDEODB_EVENTS_DIR=\"$STATE_DIR\" python scripts\u002Fws_listener.py --clear \"$STATE_DIR\" &`\n3. **获取 WebSocket ID**：`cat \"$STATE_DIR\u002Fvideodb_ws_id\"`\n4. **运行捕获代码**（完整工作流程请参阅 reference\u002Fcapture.md）\n5. **事件写入**：`$STATE_DIR\u002Fvideodb_events.jsonl`\n\n每当开始新的捕获运行时，请使用 `--clear`，以免过时的转录和视觉事件泄露到新会话中。\n\n#### 查询事件\n\n```python\nimport json\nimport os\nimport time\nfrom pathlib import Path\n\nevents_dir = Path(os.environ.get(\"VIDEODB_EVENTS_DIR\", Path.home() \u002F \".local\" \u002F \"state\" \u002F \"videodb\"))\nevents_file = events_dir \u002F \"videodb_events.jsonl\"\nevents = []\n\nif events_file.exists():\n    with events_file.open(encoding=\"utf-8\") as handle:\n        for line in handle:\n            try:\n                events.append(json.loads(line))\n            except json.JSONDecodeError:\n                continue\n\ntranscripts = [e[\"data\"][\"text\"] for e in events if e.get(\"channel\") == \"transcript\"]\ncutoff = time.time() - 300\nrecent_visual = [\n    e for e in events\n    if e.get(\"channel\") == \"visual_index\" and e[\"unix_ts\"] > cutoff\n]\n```\n\n## 附加文档\n\n参考文档位于与此 SKILL.md 文件相邻的 `reference\u002F` 目录中。如果需要，请使用 Glob 工具来定位。\n\n* [reference\u002Fapi-reference.md](reference\u002Fapi-reference.md) - 完整的 VideoDB Python SDK API 参考\n* [reference\u002Fsearch.md](reference\u002Fsearch.md) - 视频搜索深入指南（口语词和基于场景的）\n* [reference\u002Feditor.md](reference\u002Feditor.md) - 时间线编辑、资产和合成\n* [reference\u002Fstreaming.md](reference\u002Fstreaming.md) - HLS 流和即时播放\n* [reference\u002Fgenerative.md](reference\u002Fgenerative.md) - AI 驱动的媒体生成（图像、视频、音频）\n* [reference\u002Frtstream.md](reference\u002Frtstream.md) - 直播流摄取工作流程（RTSP\u002FRTMP）\n* [reference\u002Frtstream-reference.md](reference\u002Frtstream-reference.md) - RTStream SDK 方法和 AI 管道\n* [reference\u002Fcapture.md](reference\u002Fcapture.md) - 桌面捕获工作流程\n* [reference\u002Fcapture-reference.md](reference\u002Fcapture-reference.md) - Capture SDK 和 WebSocket 事件\n* [reference\u002Fuse-cases.md](reference\u002Fuse-cases.md) - 常见的视频处理模式和示例\n\n**当 VideoDB 支持该操作时，不要使用 ffmpeg、moviepy 或本地编码工具。** 以下所有操作均由 VideoDB 在服务器端处理——修剪、合并片段、叠加音频或音乐、添加字幕、文本\u002F图像叠加层、转码、分辨率更改、宽高比转换、为平台要求调整大小、转录和媒体生成。仅当 reference\u002Feditor.md 中“限制”部分列出的操作（转场、速度变化、裁剪\u002F缩放、色彩分级、音量混合）时，才回退到本地工具。\n\n### 何时使用什么\n\n| 问题 | VideoDB 解决方案 |\n|---------|-----------------|\n| 平台拒绝视频宽高比或分辨率 | 使用 `VideoConfig` 的 `video.reframe()` 或 `conn.transcode()` |\n| 需要为 Twitter\u002FInstagram\u002FTikTok 调整视频大小 | `video.reframe(target=\"vertical\")` 或 `target=\"square\"` |\n| 需要更改分辨率（例如 1080p → 720p） | 使用 `VideoConfig(resolution=720)` 的 `conn.transcode()` |\n| 需要在视频上叠加音频\u002F音乐 | 在 `Timeline` 上使用 `AudioAsset` |\n| 需要添加字幕 | `video.add_subtitle()` 或 `CaptionAsset` |\n| 需要合并\u002F修剪片段 | 在 `Timeline` 上使用 `VideoAsset` |\n| 需要生成画外音、音乐或音效 | `coll.generate_voice()`、`generate_music()`、`generate_sound_effect()` |\n\n## 来源\n\n此技能的参考材料在 `skills\u002Fvideodb\u002Freference\u002F` 下本地提供。\n请使用上面的本地副本，而不是在运行时遵循外部存储库链接。\n\n**维护者：** [VideoDB](https:\u002F\u002Fwww.videodb.io\u002F)\n","# VideoDB 技能\n\n**针对视频、直播流和桌面会话的感知 + 记忆 + 操作。**\n\n## 使用场景\n\n### 桌面感知\n\n* 启动\u002F停止**桌面会话**，捕获**屏幕、麦克风和系统音频**\n* 流式传输**实时上下文**并存储**片段式会话记忆**\n* 对所说的内容和屏幕上发生的事情运行**实时警报\u002F触发器**\n* 生成**会话摘要**、可搜索的时间线和**可播放的证据链接**\n\n### 视频摄取 + 流\n\n* 摄取**文件或URL**并返回**可播放的网络流链接**\n* 转码\u002F标准化：**编解码器、比特率、帧率、分辨率、宽高比**\n\n### 索引 + 搜索（时间戳 + 证据）\n\n* 构建**视觉**、**语音**和**关键词**索引\n* 搜索并返回带有**时间戳**和**可播放证据**的精确时刻\n* 从搜索结果自动创建**片段**\n\n### 时间线编辑 + 生成\n\n* 字幕：**生成**、**翻译**、**烧录**\n* 叠加层：**文本\u002F图片\u002F品牌标识**，动态字幕\n* 音频：**背景音乐**、**画外音**、**配音**\n* 通过**时间线操作**进行程序化合成和导出\n\n### 直播流（RTSP）+ 监控\n\n* 连接**RTSP\u002F实时流**\n* 运行**实时视觉和语音理解**，并为监控工作流发出**事件\u002F警报**\n\n## 工作原理\n\n### 常见输入\n\n* 本地**文件路径**、公共**URL**或**RTSP URL**\n* 桌面捕获请求：**启动 \u002F 停止 \u002F 总结会话**\n* 期望的操作：获取理解上下文、转码规格、索引规格、搜索查询、片段范围、时间线编辑、警报规则\n\n### 常见输出\n\n* **流URL**\n* 带有**时间戳**和**证据链接**的搜索结果\n* 生成的资产：字幕、音频、图片、片段\n* 用于直播流的**事件\u002F警报负载**\n* 桌面**会话摘要**和记忆条目\n\n### 运行 Python 代码\n\n在运行任何 VideoDB 代码之前，请切换到项目目录并加载环境变量：\n\n```python\nfrom dotenv import load_dotenv\nload_dotenv(\".env\")\n\nimport videodb\nconn = videodb.connect()\n```\n\n这会从以下位置读取 `VIDEO_DB_API_KEY`：\n\n1. 环境变量（如果已导出）\n2. 项目当前目录中的 `.env` 文件\n\n如果密钥缺失，`videodb.connect()` 会自动引发 `AuthenticationError`。\n\n当简短的內联命令有效时，不要编写脚本文件。\n\n编写內联 Python (`python -c \"...\"`) 时，始终使用格式正确的代码——使用分号分隔语句并保持可读性。对于任何超过约3条语句的内容，请改用 heredoc：\n\n```bash\npython \u003C\u003C 'EOF'\nfrom dotenv import load_dotenv\nload_dotenv(\".env\")\n\nimport videodb\nconn = videodb.connect()\ncoll = conn.get_collection()\nprint(f\"Videos: {len(coll.get_videos())}\")\nEOF\n```\n\n### 设置\n\n当用户要求“设置 videodb”或类似操作时：\n\n### 1. 安装 SDK\n\n```bash\npip install \"videodb[capture]\" python-dotenv\n```\n\n如果在 Linux 上 `videodb[capture]` 失败，请安装不带捕获扩展的版本：\n\n```bash\npip install videodb python-dotenv\n```\n\n### 2. 配置 API 密钥\n\n用户必须使用**任一**方法设置 `VIDEO_DB_API_KEY`：\n\n* **在终端中导出**（在启动 Claude 之前）：`export VIDEO_DB_API_KEY=your-key`\n* **项目 `.env` 文件**：将 `VIDEO_DB_API_KEY=your-key` 保存在项目的 `.env` 文件中\n\n免费获取 API 密钥，请访问 [console.videodb.io](https:\u002F\u002Fconsole.videodb.io)（50 次免费上传，无需信用卡）。\n\n**请勿**自行读取、写入或处理 API 密钥。始终让用户设置。\n\n### 快速参考\n\n### 上传媒体\n\n```python\n# URL\nvideo = coll.upload(url=\"https:\u002F\u002Fexample.com\u002Fvideo.mp4\")\n\n# YouTube\nvideo = coll.upload(url=\"https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=VIDEO_ID\")\n\n# Local file\nvideo = coll.upload(file_path=\"\u002Fpath\u002Fto\u002Fvideo.mp4\")\n```\n\n### 转录 + 字幕\n\n```python\n# force=True skips the error if the video is already indexed\nvideo.index_spoken_words(force=True)\ntext = video.get_transcript_text()\nstream_url = video.add_subtitle()\n```\n\n### 在视频内搜索\n\n```python\nfrom videodb.exceptions import InvalidRequestError\n\nvideo.index_spoken_words(force=True)\n\n# search() raises InvalidRequestError when no results are found.\n# Always wrap in try\u002Fexcept and treat \"No results found\" as empty.\ntry:\n    results = video.search(\"product demo\")\n    shots = results.get_shots()\n    stream_url = results.compile()\nexcept InvalidRequestError as e:\n    if \"No results found\" in str(e):\n        shots = []\n    else:\n        raise\n```\n\n### 场景搜索\n\n```python\nimport re\nfrom videodb import SearchType, IndexType, SceneExtractionType\nfrom videodb.exceptions import InvalidRequestError\n\n# index_scenes() has no force parameter — it raises an error if a scene\n# index already exists. Extract the existing index ID from the error.\ntry:\n    scene_index_id = video.index_scenes(\n        extraction_type=SceneExtractionType.shot_based,\n        prompt=\"Describe the visual content in this scene.\",\n    )\nexcept Exception as e:\n    match = re.search(r\"id\\s+([a-f0-9]+)\", str(e))\n    if match:\n        scene_index_id = match.group(1)\n    else:\n        raise\n\n# Use score_threshold to filter low-relevance noise (recommended: 0.3+)\ntry:\n    results = video.search(\n        query=\"person writing on a whiteboard\",\n        search_type=SearchType.semantic,\n        index_type=IndexType.scene,\n        scene_index_id=scene_index_id,\n        score_threshold=0.3,\n    )\n    shots = results.get_shots()\n    stream_url = results.compile()\nexcept InvalidRequestError as e:\n    if \"No results found\" in str(e):\n        shots = []\n    else:\n        raise\n```\n\n### 时间线编辑\n\n**重要提示：** 在构建时间线之前，请务必验证时间戳：\n\n* `start` 必须 >= 0（负值会被静默接受，但会产生损坏的输出）\n* `start` 必须 \u003C `end`\n* `end` 必须 \u003C= `video.length`\n\n```python\nfrom videodb.timeline import Timeline\nfrom videodb.asset import VideoAsset, TextAsset, TextStyle\n\ntimeline = Timeline(conn)\ntimeline.add_inline(VideoAsset(asset_id=video.id, start=10, end=30))\ntimeline.add_overlay(0, TextAsset(text=\"The End\", duration=3, style=TextStyle(fontsize=36)))\nstream_url = timeline.generate_stream()\n```\n\n### 转码视频（分辨率 \u002F 质量更改）\n\n```python\nfrom videodb import TranscodeMode, VideoConfig, AudioConfig\n\n# Change resolution, quality, or aspect ratio server-side\njob_id = conn.transcode(\n    source=\"https:\u002F\u002Fexample.com\u002Fvideo.mp4\",\n    callback_url=\"https:\u002F\u002Fexample.com\u002Fwebhook\",\n    mode=TranscodeMode.economy,\n    video_config=VideoConfig(resolution=720, quality=23, aspect_ratio=\"16:9\"),\n    audio_config=AudioConfig(mute=False),\n)\n```\n\n### 调整宽高比（适用于社交平台）\n\n**警告：** `reframe()` 是一项缓慢的服务器端操作。对于长视频，可能需要几分钟，并可能超时。最佳实践：\n\n* 尽可能使用 `start`\u002F`end` 限制为短片段\n* 对于全长视频，使用 `callback_url` 进行异步处理\n* 先在 `Timeline` 上修剪视频，然后调整较短结果的宽高比\n\n```python\nfrom videodb import ReframeMode\n\n# Always prefer reframing a short segment:\nreframed = video.reframe(start=0, end=60, target=\"vertical\", mode=ReframeMode.smart)\n\n# Async reframe for full-length videos (returns None, result via webhook):\nvideo.reframe(target=\"vertical\", callback_url=\"https:\u002F\u002Fexample.com\u002Fwebhook\")\n\n# Presets: \"vertical\" (9:16), \"square\" (1:1), \"landscape\" (16:9)\nreframed = video.reframe(start=0, end=60, target=\"square\")\n\n# Custom dimensions\nreframed = video.reframe(start=0, end=60, target={\"width\": 1280, \"height\": 720})\n```\n\n### 生成式媒体\n\n```python\nimage = coll.generate_image(\n    prompt=\"a sunset over mountains\",\n    aspect_ratio=\"16:9\",\n)\n```\n\n## 错误处理\n\n```python\nfrom videodb.exceptions import AuthenticationError, InvalidRequestError\n\ntry:\n    conn = videodb.connect()\nexcept AuthenticationError:\n    print(\"Check your VIDEO_DB_API_KEY\")\n\ntry:\n    video = coll.upload(url=\"https:\u002F\u002Fexample.com\u002Fvideo.mp4\")\nexcept InvalidRequestError as e:\n    print(f\"Upload failed: {e}\")\n```\n\n### 常见问题\n\n| 场景 | 错误信息 | 解决方案 |\n|----------|--------------|----------|\n| 为已索引的视频建立索引 | `Spoken word index for video already exists` | 使用 `video.index_spoken_words(force=True)` 跳过已索引的情况 |\n| 场景索引已存在 | `Scene index with id XXXX already exists` | 使用 `re.search(r\"id\\s+([a-f0-9]+)\", str(e))` 从错误中提取现有的 `scene_index_id` |\n| 搜索无匹配项 | `InvalidRequestError: No results found` | 捕获异常并视为空结果 (`shots = []`) |\n| 调整宽高比超时 | 长视频上无限期阻塞 | 使用 `start`\u002F`end` 限制片段，或传递 `callback_url` 进行异步处理 |\n| Timeline 上的负时间戳 | 静默产生损坏的流 | 在创建 `VideoAsset` 之前，始终验证 `start >= 0` |\n| `generate_video()` \u002F `create_collection()` 失败 | `Operation not allowed` 或 `maximum limit` | 计划限制的功能——告知用户关于计划限制 |\n\n## 示例\n\n### 规范提示\n\n* \"开始桌面捕获，并在密码字段出现时发出警报。\"\n* \"记录我的会话并在结束时生成可操作的摘要。\"\n* \"摄取此文件并返回可播放的流链接。\"\n* \"为此文件夹建立索引，并找到每个有人的场景，返回时间戳。\"\n* \"生成字幕，将其烧录进去，并添加轻背景音乐。\"\n* \"连接此 RTSP URL，并在有人进入区域时发出警报。\"\n\n### 屏幕录制（桌面捕获）\n\n使用 `ws_listener.py` 在录制会话期间捕获 WebSocket 事件。桌面捕获仅支持 **macOS**。\n\n#### 快速开始\n\n1. **选择状态目录**：`STATE_DIR=\"${VIDEODB_EVENTS_DIR:-$HOME\u002F.local\u002Fstate\u002Fvideodb}\"`\n2. **启动监听器**：`VIDEODB_EVENTS_DIR=\"$STATE_DIR\" python scripts\u002Fws_listener.py --clear \"$STATE_DIR\" &`\n3. **获取 WebSocket ID**：`cat \"$STATE_DIR\u002Fvideodb_ws_id\"`\n4. **运行捕获代码**（完整工作流程请参阅 reference\u002Fcapture.md）\n5. **事件写入**：`$STATE_DIR\u002Fvideodb_events.jsonl`\n\n每当开始新的捕获运行时，请使用 `--clear`，以免过时的转录和视觉事件泄露到新会话中。\n\n#### 查询事件\n\n```python\nimport json\nimport os\nimport time\nfrom pathlib import Path\n\nevents_dir = Path(os.environ.get(\"VIDEODB_EVENTS_DIR\", Path.home() \u002F \".local\" \u002F \"state\" \u002F \"videodb\"))\nevents_file = events_dir \u002F \"videodb_events.jsonl\"\nevents = []\n\nif events_file.exists():\n    with events_file.open(encoding=\"utf-8\") as handle:\n        for line in handle:\n            try:\n                events.append(json.loads(line))\n            except json.JSONDecodeError:\n                continue\n\ntranscripts = [e[\"data\"][\"text\"] for e in events if e.get(\"channel\") == \"transcript\"]\ncutoff = time.time() - 300\nrecent_visual = [\n    e for e in events\n    if e.get(\"channel\") == \"visual_index\" and e[\"unix_ts\"] > cutoff\n]\n```\n\n## 附加文档\n\n参考文档位于与此 SKILL.md 文件相邻的 `reference\u002F` 目录中。如果需要，请使用 Glob 工具来定位。\n\n* [reference\u002Fapi-reference.md](reference\u002Fapi-reference.md) - 完整的 VideoDB Python SDK API 参考\n* [reference\u002Fsearch.md](reference\u002Fsearch.md) - 视频搜索深入指南（口语词和基于场景的）\n* [reference\u002Feditor.md](reference\u002Feditor.md) - 时间线编辑、资产和合成\n* [reference\u002Fstreaming.md](reference\u002Fstreaming.md) - HLS 流和即时播放\n* [reference\u002Fgenerative.md](reference\u002Fgenerative.md) - AI 驱动的媒体生成（图像、视频、音频）\n* [reference\u002Frtstream.md](reference\u002Frtstream.md) - 直播流摄取工作流程（RTSP\u002FRTMP）\n* [reference\u002Frtstream-reference.md](reference\u002Frtstream-reference.md) - RTStream SDK 方法和 AI 管道\n* [reference\u002Fcapture.md](reference\u002Fcapture.md) - 桌面捕获工作流程\n* [reference\u002Fcapture-reference.md](reference\u002Fcapture-reference.md) - Capture SDK 和 WebSocket 事件\n* [reference\u002Fuse-cases.md](reference\u002Fuse-cases.md) - 常见的视频处理模式和示例\n\n**当 VideoDB 支持该操作时，不要使用 ffmpeg、moviepy 或本地编码工具。** 以下所有操作均由 VideoDB 在服务器端处理——修剪、合并片段、叠加音频或音乐、添加字幕、文本\u002F图像叠加层、转码、分辨率更改、宽高比转换、为平台要求调整大小、转录和媒体生成。仅当 reference\u002Feditor.md 中“限制”部分列出的操作（转场、速度变化、裁剪\u002F缩放、色彩分级、音量混合）时，才回退到本地工具。\n\n### 何时使用什么\n\n| 问题 | VideoDB 解决方案 |\n|---------|-----------------|\n| 平台拒绝视频宽高比或分辨率 | 使用 `VideoConfig` 的 `video.reframe()` 或 `conn.transcode()` |\n| 需要为 Twitter\u002FInstagram\u002FTikTok 调整视频大小 | `video.reframe(target=\"vertical\")` 或 `target=\"square\"` |\n| 需要更改分辨率（例如 1080p → 720p） | 使用 `VideoConfig(resolution=720)` 的 `conn.transcode()` |\n| 需要在视频上叠加音频\u002F音乐 | 在 `Timeline` 上使用 `AudioAsset` |\n| 需要添加字幕 | `video.add_subtitle()` 或 `CaptionAsset` |\n| 需要合并\u002F修剪片段 | 在 `Timeline` 上使用 `VideoAsset` |\n| 需要生成画外音、音乐或音效 | `coll.generate_voice()`、`generate_music()`、`generate_sound_effect()` |\n\n## 来源\n\n此技能的参考材料在 `skills\u002Fvideodb\u002Freference\u002F` 下本地提供。\n请使用上面的本地副本，而不是在运行时遵循外部存储库链接。\n\n**维护者：** [VideoDB](https:\u002F\u002Fwww.videodb.io\u002F)\n",{"name":5,"origin":33,"description":7,"allowed-tools":34,"argument-hint":35},"ECC","Read Grep Glob Bash(python:*)","[task description]","main","a2e3284ed4488780397ee2f78217366e11470dfb","skills\u002Fvideodb","https:\u002F\u002Fgithub.com\u002F7dvq6yrkgs-stack\u002Fplaywright","https:\u002F\u002Fplaywright.dev","https:\u002F\u002Fgithub.com\u002F7dvq6yrkgs-stack","2026-04-25 06:04:45",{"source":8,"skillName":5,"commands":44,"prompt":54,"zipAvailable":55},[45,48,51],{"tool":46,"command":47},"npx","npx skills add 7dvq6yrkgs-stack\u002Fplaywright --skill videodb",{"tool":49,"command":50},"bunx","bunx skills add 7dvq6yrkgs-stack\u002Fplaywright --skill videodb",{"tool":52,"command":53},"pnpm","pnpm dlx skills add 7dvq6yrkgs-stack\u002Fplaywright --skill videodb","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002F7dvq6yrkgs-stack\u002Fplaywright\u002Fblob\u002Fmain\u002Fskills\u002Fvideodb\u002FSKILL.md",true,[57,63,67,71,75,79,83,87,91,95,99],{"path":58,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":61,"sourceHtmlUrl":62},".skillfish.json","REFERENCE","参考文档",232,"https:\u002F\u002Fgithub.com\u002F7dvq6yrkgs-stack\u002Fplaywright\u002Fblob\u002Fmain\u002Fskills\u002Fvideodb\u002F.skillfish.json",{"path":64,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":65,"sourceHtmlUrl":66},"reference\u002Fapi-reference.md",20253,"https:\u002F\u002Fgithub.com\u002F7dvq6yrkgs-stack\u002Fplaywright\u002Fblob\u002Fmain\u002Fskills\u002Fvideodb\u002Freference\u002Fapi-reference.md",{"path":68,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":69,"sourceHtmlUrl":70},"reference\u002Fcapture-reference.md",12017,"https:\u002F\u002Fgithub.com\u002F7dvq6yrkgs-stack\u002Fplaywright\u002Fblob\u002Fmain\u002Fskills\u002Fvideodb\u002Freference\u002Fcapture-reference.md",{"path":72,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":73,"sourceHtmlUrl":74},"reference\u002Fcapture.md",4799,"https:\u002F\u002Fgithub.com\u002F7dvq6yrkgs-stack\u002Fplaywright\u002Fblob\u002Fmain\u002Fskills\u002Fvideodb\u002Freference\u002Fcapture.md",{"path":76,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":77,"sourceHtmlUrl":78},"reference\u002Feditor.md",16469,"https:\u002F\u002Fgithub.com\u002F7dvq6yrkgs-stack\u002Fplaywright\u002Fblob\u002Fmain\u002Fskills\u002Fvideodb\u002Freference\u002Feditor.md",{"path":80,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":81,"sourceHtmlUrl":82},"reference\u002Fgenerative.md",10112,"https:\u002F\u002Fgithub.com\u002F7dvq6yrkgs-stack\u002Fplaywright\u002Fblob\u002Fmain\u002Fskills\u002Fvideodb\u002Freference\u002Fgenerative.md",{"path":84,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":85,"sourceHtmlUrl":86},"reference\u002Frtstream-reference.md",14934,"https:\u002F\u002Fgithub.com\u002F7dvq6yrkgs-stack\u002Fplaywright\u002Fblob\u002Fmain\u002Fskills\u002Fvideodb\u002Freference\u002Frtstream-reference.md",{"path":88,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":89,"sourceHtmlUrl":90},"reference\u002Frtstream.md",1809,"https:\u002F\u002Fgithub.com\u002F7dvq6yrkgs-stack\u002Fplaywright\u002Fblob\u002Fmain\u002Fskills\u002Fvideodb\u002Freference\u002Frtstream.md",{"path":92,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":93,"sourceHtmlUrl":94},"reference\u002Fsearch.md",7890,"https:\u002F\u002Fgithub.com\u002F7dvq6yrkgs-stack\u002Fplaywright\u002Fblob\u002Fmain\u002Fskills\u002Fvideodb\u002Freference\u002Fsearch.md",{"path":96,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":97,"sourceHtmlUrl":98},"reference\u002Fstreaming.md",11802,"https:\u002F\u002Fgithub.com\u002F7dvq6yrkgs-stack\u002Fplaywright\u002Fblob\u002Fmain\u002Fskills\u002Fvideodb\u002Freference\u002Fstreaming.md",{"path":100,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":101,"sourceHtmlUrl":102},"reference\u002Fuse-cases.md",4102,"https:\u002F\u002Fgithub.com\u002F7dvq6yrkgs-stack\u002Fplaywright\u002Fblob\u002Fmain\u002Fskills\u002Fvideodb\u002Freference\u002Fuse-cases.md",[104,122,130,138,151,161],{"skillNo":105,"name":106,"nameZh":6,"description":107,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":108,"categories":109,"keywords":110,"publishedAt":28},"01M6E3XK4PRPMQHM7Y98FQPTY1","zyte-api-automation","Automate Zyte API tasks via Rube MCP (Composio). Always search tools first for current schemas.","https:\u002F\u002Fgithub.com\u002F7dvq6yrkgs-stack\u002Fplaywright\u002Fblob\u002Fmain\u002Fskills\u002Fzyte-api-automation\u002FSKILL.md",[],[111,112,113,114,115,116,117,118,119,120,121],"zyte api automation","api","automation","MCP","tasks","search","Tools","first","automate","composio","via",{"skillNo":123,"name":124,"nameZh":6,"description":125,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":126,"categories":127,"keywords":128,"publishedAt":28},"01M6E3XFX6QSTR1QR59NFXJTMA","zylvie-automation","Automate Zylvie tasks via Rube MCP (Composio). Always search tools first for current schemas.","https:\u002F\u002Fgithub.com\u002F7dvq6yrkgs-stack\u002Fplaywright\u002Fblob\u002Fmain\u002Fskills\u002Fzylvie-automation\u002FSKILL.md",[],[129,113,119,114,115,116,117,118,120,121],"zylvie automation",{"skillNo":131,"name":132,"nameZh":6,"description":133,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":134,"categories":135,"keywords":136,"publishedAt":28},"01M6E3XCX2GDYYCHN58ZJHT37M","zoominfo-automation","Automate Zoominfo tasks via Rube MCP (Composio). Always search tools first for current schemas.","https:\u002F\u002Fgithub.com\u002F7dvq6yrkgs-stack\u002Fplaywright\u002Fblob\u002Fmain\u002Fskills\u002Fzoominfo-automation\u002FSKILL.md",[],[137,113,116,117,118,119,120,121,115,114],"zoominfo automation",{"skillNo":139,"name":140,"nameZh":6,"description":141,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":142,"categories":143,"keywords":144,"publishedAt":28},"01M6E3X9WJ2T73216WQHHTB9BD","zoho_mail-automation","Automate Zoho Mail tasks via Rube MCP (Composio): email sending, folders, labels, and mailbox management. Always search tools first for current schemas.","https:\u002F\u002Fgithub.com\u002F7dvq6yrkgs-stack\u002Fplaywright\u002Fblob\u002Fmain\u002Fskills\u002Fzoho_mail-automation\u002FSKILL.md",[],[145,146,147,113,114,115,116,148,117,118,119,149,120,150,121],"mail","zoho mail automation","zoho","email","management","mailbox",{"skillNo":152,"name":153,"nameZh":6,"description":154,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":155,"categories":156,"keywords":157,"publishedAt":28},"01M6E3X719W648XZBW1EC6JQ64","zoho_invoice-automation","Automate Zoho Invoice tasks via Rube MCP (Composio): invoices, estimates, expenses, clients, and payment tracking. Always search tools first for current schemas.","https:\u002F\u002Fgithub.com\u002F7dvq6yrkgs-stack\u002Fplaywright\u002Fblob\u002Fmain\u002Fskills\u002Fzoho_invoice-automation\u002FSKILL.md",[],[158,147,113,115,116,117,118,119,159,160,120,121,114],"zoho invoice automation","tracking","payment",{"skillNo":162,"name":163,"nameZh":6,"description":164,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":165,"categories":166,"keywords":167,"publishedAt":28},"01M6E3X28JYTC3QTK32AQF7BYB","zoho_inventory-automation","Automate Zoho Inventory tasks via Rube MCP (Composio): items, orders, warehouses, shipments, and stock management. Always search tools first for current schemas.","https:\u002F\u002Fgithub.com\u002F7dvq6yrkgs-stack\u002Fplaywright\u002Fblob\u002Fmain\u002Fskills\u002Fzoho_inventory-automation\u002FSKILL.md",[],[113,168,147,169,118,119,117,116,115,114,120,121,170,171,149],"inventory","zoho inventory automation","stock","orders"]