claude-video

命令行工具

bradautomates/claude-video

让 Claude 能够观看并分析任何视频。

项目简介

一款与 Claude 集成的命令行工具,可下载视频、提取帧并转录音频。支持 YouTube 等多种来源,提供完整的视频分析流程。用户可以询问视频内容相关问题,并获得基于视觉和听觉信息的答案。

README 预览

# /watch\n\n**Give Claude the ability to watch any video.**\n\nClaude Code (recommended — auto-updates via marketplace):\n```\n/plugin marketplace add bradautomates/claude-video\n/plugin install watch@claude-video\n```\n\nCodex, Cursor, Copilot, Gemini CLI, or any of 50+ [Agent Skills](https://agentskills.io) hosts:\n```bash\nnpx skills add bradautomates/claude-video -g\n```\n(`-g` installs globally for your user, available across all projects. Drop it to scope per-project.)\n\nMore install options (claude.ai web, manual) in the [Install](#install) section below.\n\nZero config to start — `yt-dlp` and `ffmpeg` install on first run via `brew` on macOS (Linux/Windows print exact commands). Captions cover most public videos for free. Whisper API key is only needed when a video has no captions.\n\n---\n\nClaude can read a webpage, run a script, browse a repo. What it can't do, out of the box, is *watch a video*. You paste a YouTube link and it has to either guess from the title or pull a transcript that's missing 90% of what's on screen.\n\nWith Claude Video `/watch` you can paste a URL or a local path, ask a question, and Claude fetches captions first, downloads only what it needs, extracts frames (scene-aware, or fast keyframes at `efficient` detail), pulls a timestamped transcript (free captions when available, Whisper API as fallback), and `Read`s every frame as an image. By the time it answers, it has *seen* the video and *heard* the audio.\n\n```\n/watch https://youtu.be/dQw4w9WgXcQ what happens at the 30 second mark?\n```\n\n## What people actually use it for\n\n**Analyze someone else's content.** `/watch https://youtu.be/ what hook did they open with?` Claude looks at the first frames, reads the opening transcript, breaks down the structure. Same for ad creative, competitor launches, podcast intros, anything where the *how* matters as much as the *what*.\n\n**Diagnose a bug from a video.** Someone sends you a screen recording of something broken. `/watch bug-rep

常见问题 (5)

故障排除
在 Windows 上运行 Python CLI 时,如何修复 "UnicodeEncodeError: 'charmap' codec can't encode character '→'" 错误?

出现这种情况是因为 Windows 控制台通常使用 cp1252 而不是 UTF-8,而报告中会打印诸如 →、… 或 — 之类的字符。

临时用户解决方案:

setx PYTHONUTF8 1

运行后关闭并重新打开终端。如果仅对当前 PowerShell 会话生效,请使用:

$env:PYTHONUTF8 = "1"

永久性应用修复:在程序启动时、任何报告输出之前,将 stdout 和 stderr 重新配置为 UTF-8:

import sys

for stream in (sys.stdout, sys.stderr):
    try:
        stream.reconfigure(encoding="utf-8")
    except (AttributeError, ValueError):
        pass

在每个入口点调用此辅助函数,例如 watch.py、frames.py、whisper.py、transcribe.py、setup.py 和 download.py。TextIOWrapper.reconfigure() 在 Python 3.7+ 中可用;受影响的项目要求 Python 3.10+。不要仅仅删除非 ASCII 字符,因为其他报告输出也可能触发同样的 cp1252 错误。

来源 Issue #61
故障排除
在 Claude Code 中安装 watch@claude-video 后,如何修复 "Unknown command: /watch" 错误?

斜杠命令失败,因为 Claude Code 2.1.126 无法解析 allowed-tools 的 YAML 内联列表格式。编辑 ~/.claude/plugins/cache/claude-video/watch/0.1.2/commands/watch.md,将:

allowed-tools: [Bash, Read, AskUserQuestion]

替换为:

allowed-tools: Bash, Read, AskUserQuestion

你可以直接使用以下命令应用此修改:

sed -i '' 's/^allowed-tools: \[Bash, Read, AskUserQuestion\]$/allowed-tools: Bash, Read, AskUserQuestion/' ~/.claude/plugins/cache/claude-video/watch/0.1.2/commands/watch.md

完全退出并重新打开 Claude Code,然后运行 /watch 或从自动补全中选择 /watch:watch。永久修复方案是由插件维护者在 main 分支的 commands/watch.md 中进行这一行修改;添加 frontmatter 校验可以防止回归。

来源 Issue #6
故障排除
为什么在 Windows 上 /watch 报告中缺少视频标题和上传者信息?

升级到 watch v0.1.3 或更高版本。该 bug 产生的原因是 scripts/download.py 在调用 Path.read_text() 时未指定 encoding="utf-8";在 Windows 上 Python 会使用 cp1252,因此 yt-dlp 的 video.info.json 中的非 ASCII 字符会导致 UnicodeDecodeError。随后,宽泛的 except 会静默地只保留 URL,导致 title 和 uploader 被省略。要为旧版本打补丁,请将:

raw = json.loads(info_path.read_text())

改为:

raw = json.loads(info_path.read_text(encoding="utf-8"))

此外,还应记录解析失败的情况,而不是静默忽略,例如:

except Exception as exc:
    print(f"[watch] info.json parse failed: {exc}", file=sys.stderr)
    info = {"url": url}

作为临时解决方案,可以从输出目录中以 UTF-8 显式重新读取 video.info.json。如果 Windows 控制台在输出表情符号或其他非 ASCII 标题字符时失败,请在运行命令前设置 PYTHONUTF8=1 或 PYTHONIOENCODING=utf-8。

来源 Issue #4
故障排除
如何在通过 Python subprocess 传递用户提供的 URL 时防止 yt-dlp 选项注入?

在 yt-dlp 的 argv 数组中,紧跟在 URL 之前插入 "--",使其解析器停止处理选项。同时校验 URL,拒绝以 - 开头的输入。

cmd = [
    "yt-dlp",
    "-N", "8",
    "-o", output_template,
    "--",
    url,
]
subprocess.run(cmd, check=True)

强化 URL 校验,作为纵深防御:

from urllib.parse import urlparse

def is_url(source: str) -> bool:
    if source.startswith("-"):
        return False
    parsed = urlparse(source)
    return parsed.scheme in ("http", "https") and bool(parsed.netloc)

对于 ffmpeg/ffprobe,不要依赖 --,因为这些工具不会将其视为选项结束标记;应使用 Path.resolve() 将用户控制的路径解析为绝对路径。该问题已在 claude-video v0.1.3/commit c333c22 中修复。

来源 Issue #2
故障排除
如何使用 claude-video 修复自动生成的视频转录文本中听错的词语?

目前没有一键写入修正后 VTT/SRT 文件的选项,但可以通过两步工作流程实现:

1. 运行 /watch <url> --detail transcript,并让 Claude 提供带时间戳的原始转录文本以及可疑片段,例如专有名词、同音词和上下文突变处。对于已有字幕的 URL,该工具会使用 yt-dlp 抓取的 VTT,并跳过下载视频。
2. 下载视频,仅重新检查存疑的时间戳:

/watch <local-video> --detail transcript --timestamps 1:23,4:56,7:08 --no-whisper

Claude 仅在这些时间戳处提取帧,将其与转录文本进行比对,并可给出结合上下文的修正建议。请手动将这些修正应用到 VTT/SRT 文件中。

来源 Issue #66