video-analyzer
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseVideo Analyzer
Video Analyzer
通过视觉/视频大模型分析视频内容,支持本地视频文件和互联网视频。
Analyze video content using visual/video large models, supporting local video files and online videos.
使用场景
Use Cases
- 用户要求分析、理解或描述一段视频
- 用户提供视频文件路径或 URL,希望了解视频内容
- 用户需要对视频进行问答
- Users request to analyze, understand, or describe a video
- Users provide a video file path or URL and want to know the video content
- Users need to ask questions about the video
配置
Configuration
环境变量
Environment Variables
根据使用的模型设置对应的 API Key 环境变量:
bash
undefinedSet the corresponding API Key environment variables based on the model used:
bash
undefined火山引擎(豆包)
VolcEngine (Doubao)
export ARK_API_KEY="your-api-key"
export ARK_API_KEY="your-api-key"
OpenAI
OpenAI
export OPENAI_API_KEY="your-api-key"
undefinedexport OPENAI_API_KEY="your-api-key"
undefined模型配置
Model Configuration
编辑 添加或修改模型配置。每个模型需要:
scripts/models.json- — API 地址
base_url - — 读取 API Key 的环境变量名
api_key_env - — 模型 ID
model - —
api_type或responseschat_completions - — 是否支持原生视频输入
supports_video
Edit to add or modify model configurations. Each model requires:
scripts/models.json- — API endpoint
base_url - — Name of the environment variable for reading the API Key
api_key_env - — Model ID
model - —
api_typeorresponseschat_completions - — Whether native video input is supported
supports_video
工作流程
Workflow
- 确认视频来源:获取用户提供的视频路径或 URL。
- 确认分析需求:明确用户想了解什么(如概括内容、回答问题、描述场景等)。如果 非空,将其作为分析提示词。
$ARGUMENTS - 选择模型:默认使用 中的
models.json,用户也可指定。default_model - 执行分析:运行脚本(在 目录下执行):
scripts/可选参数:bashuv run analyze.py --video <视频路径或URL> --prompt "<分析提示词>"- — 指定模型(对应 models.json 中的 key)
--model <名称> - — 抽帧数量(默认 10)
--frames <数量> - — 帧最大边长(默认 720)
--max-size <像素>
- 展示结果:将模型返回的分析结果展示给用户。
- Confirm Video Source: Obtain the video path or URL provided by the user.
- Confirm Analysis Requirements: Clarify what the user wants to know (e.g., content summary, question answering, scene description, etc.). If is not empty, use it as the analysis prompt.
$ARGUMENTS - Select Model: By default, use the in
default_model; users can also specify a model.models.json - Execute Analysis: Run the script (execute in the directory):
scripts/Optional parameters:bashuv run analyze.py --video <video path or URL> --prompt "<analysis prompt>"- — Specify a model (corresponds to the key in models.json)
--model <name> - — Number of frames to extract (default: 10)
--frames <number> - — Maximum side length of frames (default: 720)
--max-size <pixels>
- Display Results: Present the analysis results returned by the model to the user.
CLI 参考
CLI Reference
bash
undefinedbash
undefined本地视频
Local video
uv run analyze.py --video /path/to/video.mp4 --prompt "描述视频内容"
uv run analyze.py --video /path/to/video.mp4 --prompt "Describe the video content"
互联网直接视频 URL
Direct online video URL
uv run analyze.py --video https://example.com/video.mp4 --prompt "分析视频"
uv run analyze.py --video https://example.com/video.mp4 --prompt "Analyze the video"
视频站点 URL(YouTube、Bilibili 等)
Video website URL (YouTube, Bilibili, etc.)
uv run analyze.py --video https://www.youtube.com/watch?v=xxxxx --prompt "总结视频"
uv run analyze.py --video https://www.youtube.com/watch?v=xxxxx --prompt "Summarize the video"
指定模型和抽帧数
Specify model and number of frames
uv run analyze.py --video video.mp4 --model doubao-vision --frames 20 --prompt "分析"
undefineduv run analyze.py --video video.mp4 --model doubao-vision --frames 20 --prompt "Analyze"
undefined注意事项
Notes
- 视频站点 URL 下载依赖 ,已作为 Python 依赖自动安装
yt-dlp - 抽帧模式下,帧数越多分析越详细,但 API 调用成本也越高
- 大视频文件下载可能需要较长时间,请耐心等待
- Downloading video from website URLs depends on , which is automatically installed as a Python dependency
yt-dlp - In frame extraction mode, more frames lead to more detailed analysis but higher API call costs
- Downloading large video files may take a long time, please be patient