video-analyzer

byjlwApache-2.0更新放缓

用大模型、计算机视觉和语音识别自动分析视频内容,把画面、语音转成结构化信息,省去人工逐帧观看和整理。

Analyze videos using LLMs, Computer Vision and Automatic Speech Recognition

v0.1.2发布于 2026-03-20 06:16 UTC1,614star225fork同步于 2026-11-07 07:33 UTC

怎么上手

由 README 提炼,执行前请确认
git clone https://github.com/byjlw/video-analyzer.git
cd video-analyzer
pip install .
ollama pull llama3.2-vision
video-analyzer video.mp4
硬件要求按 README 说明

本地跑 LLM 需至少 16GB 内存(推荐 32GB),GPU 至少 12GB 显存,或 Apple M 系列 32GB 以上;用 OpenRouter 等云端 API 时无此要求。

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

用视觉大模型和 Whisper 把视频转成自然语言描述,可全本地跑

用大模型、计算机视觉和语音识别自动分析视频内容,把画面、语音转成结构化信息,省去人工逐帧观看和整理。

核心能力

  • 用 OpenCV 抽取关键帧并逐帧送入视觉模型分析
  • 用 OpenAI Whisper 转录音频并做置信度检查
  • 按时间顺序串联帧分析与转录生成整体描述
  • 支持 Ollama 本地模型或任意 OpenAI 兼容 API
  • 输出含元数据、转录和逐帧分析的 JSON 结果

容易踩的坑

需另装 FFmpeg 处理音频;本地模式要先装 Ollama 并拉取 llama3.2-vision 模型;需 Python 3.11 及以上。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

3 个版本v0.1.2
  1. tune-v0.1.0video-analyzer-tune v0.1.02026-03-20 · 2026-03-20 06:16 UTC
    查看更新说明

    Initial release

    DSPy-based prompt optimizer for video-analyzer. Automatically rewrites the frame analysis and video reconstruction prompts to match your preferences, based on examples you provide.

    Features

    • End-to-end optimization of both frame_analysis.txt and describe.txt prompts using DSPy MIPROv2
    • LLM-as-judge scoring with configurable description/frame note weighting
    • Supports Ollama and any OpenAI-compatible API (same flags as video-analyzer)
    • Accepts training data as a directory, analysis.json path, or a training_data.json wrapper
    • Writes tuned prompts as drop-in replacement files — main package is unaffected

    Install

    pip install video-analyzer-tune==0.1.0
    

    Requires video-analyzer >= 0.1.2.

    See video-analyzer-tune/README.md for full usage instructions.

  2. v0.1.2video-analyzer v0.1.2最新正式版2026-03-20 · 2026-03-20 06:16 UTC

    What's changed

    • Fix: Frames on disk and in analysis.json are now always in chronological order. A cleanup pass in a previous PR had accidentally dropped the final sort step — keyframes were being selected by visual significance score but never re-sorted by timestamp before writing. (#59)

    Install

    pip install video-analyzer==0.1.2
    
  3. releaseminor release to 0.1.12025-03-16 · 2025-03-16 00:23 UTC
    查看更新说明

    bug fixes, code refactoring, better documentation and more configuration options

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    Video Analysis using vision models like Llama3.2 Vision and OpenAI's Whisper Models

    A video analysis tool that combines vision models like Llama's 11B vision model and Whisper to create a description by taking key frames, feeding them to the vision model to get details. It uses the details from each frame and the transcript, if available, to describe what's happening in the video.

    Table of Contents

    Features

    • 💻 Can run completely locally - no cloud services or API keys needed
    • ☁️ Or, leverage any OpenAI API compatible LLM service (openrouter, openai, etc) for speed and scale
    • 🎬 Intelligent key frame extraction from videos
    • 🔊 High-quality audio transcription using OpenAI's Whisper
    • 👁️ Frame analysis using Ollama and Llama3.2 11B Vision Model
    • 📝 Natural language descriptions of video content
    • 🔄 Automatic handling of poor quality audio
    • 📊 Detailed JSON output of analysis results
    • ⚙️ Highly configurable through command line arguments or config file

    Design

    The system operates in three stages:

    1. Frame Extraction & Audio Processing

      • Uses OpenCV to extract key frames
      • Processes audio using Whisper for transcription
      • Handles poor quality audio with confidence checks
    2. Frame Analysis

      • Analyzes each frame using vision LLM
      • Each analysis includes context from previous frames
      • Maintains chronological progression
      • Uses frame_analysis.txt prompt template
    3. Video Reconstruction

      • Combines frame analyses chronologically
      • Integrates audio transcript
      • Uses first frame to set the scene
      • Creates comprehensive video description

    Design

    Requirements

    System Requirements

    • Python 3.11 or higher
    • FFmpeg (required for audio processing)
    • When running LLMs locally (not necessary when using openrouter)
      • At least 16GB RAM (32GB recommended)
      • GPU at least 12GB of VRAM or Apple M Series with at least 32GB

    Installation

    1. Clone the repository:
    git clone https://github.com/byjlw/video-analyzer.git
    cd video-analyzer
    
    1. Create and activate a virtual environment:
    python3 -m venv .venv
    source .venv/bin/activate  # On Windows: .venv\Scripts\activate
    
    1. Install the package:
    pip install .  # For regular installation
    # OR
    pip install -e .  # For development installation
    
    1. Install FFmpeg:
    • Ubuntu/Debian:
      sudo apt-get update && sudo apt-get install -y ffmpeg
      
    • macOS:
      brew install ffmpeg
      
    • Windows:
      choco install ffmpeg
      

    Ollama Setup

    1. Install Ollama following the instructions at ollama.ai

    2. Pull the default vision model:

    ollama pull llama3.2-vision
    
    1. Start the Ollama service:
    ollama serve
    

    OpenAI-compatible API Setup (Optional)

    If you want to use OpenAI-compatible APIs (like OpenRouter or OpenAI) instead of Ollama:

    1. Get an API key from your provider:

    2. Configure via command line:

      # For OpenRouter
      video-analyzer video.mp4 --client openai_api --api-key your-key --api-url https://openrouter.ai/api/v1 --model gpt-4o
      
      # For OpenAI
      video-analyzer video.mp4 --client openai_api --api-key your-key --api-url https://api.openai.com/v1 --model gpt-4o
      

      Or add to config/config.json:

      {
        "clients": {
          "default": "openai_api",
          "openai_api": {
            "api_key": "your-api-key",
            "api_url": "https://openrouter.ai/api/v1"  # or https://api.openai.com/v1
          }
        }
      }
      

    Note: With OpenRouter, you can use llama 3.2 11b vision for free by adding :free to the model name

    Design

    For detailed information about the project's design and implementation, including how to make changes, see docs/DESIGN.md.

    Usage

    For detailed usage instructions and all available options, see docs/USAGES.md.

    Quick Start

    # Local analysis with Ollama (default)
    video-analyzer video.mp4
    
    # Cloud analysis with OpenRouter
    video-analyzer video.mp4 \
        --client openai_api \
        --api-key your-key \
        --api-url https://openrouter.ai/api/v1 \
        --model meta-llama/llama-3.2-11b-vision-instruct:free
    
    # Analysis with custom prompt
    video-analyzer video.mp4 \
        --prompt "What activities are happening in this video?" \
        --whisper-model large
    

    Output

    The tool generates a JSON file (output\analysis.json) containing:

    • Metadata about the analysis
    • Audio transcript (if available)
    • Frame-by-frame analysis
    • Final video description

    Sample Output

    The video begins with a person with long blonde hair, wearing a pink t-shirt and yellow shorts, standing in front of a black plastic tub or container on wheels. The ground appears to be covered in wood chips.\n\nAs the video progresses, the person remains facing away from the camera, looking down at something inside the tub. ........
    

    full sample output in docs/sample_analysis.json

    Configuration

    The tool uses a cascading configuration system with command line arguments taking highest priority, followed by user config (config/config.json), and finally the default config. See docs/USAGES.md for detailed configuration options.

    Prompt Tuning

    The prompts that drive frame analysis and video reconstruction can be automatically optimized for your specific content and use case using video-analyzer-tune.

    pip install video-analyzer-tune
    

    Run video-analyzer on a few representative videos, edit the outputs to show what ideal results look like, then let DSPy MIPROv2 find better prompt instructions automatically. The tuned prompts are written as new files you point to via your config — the main package is unaffected.

    See video-analyzer-tune/README.md for full instructions.

    Uninstallation

    To uninstall the package:

    pip uninstall video-analyzer
    

    License

    Apache License

    Contributing

    We welcome contributions! Please see docs/CONTRIBUTING.md for detailed guidelines on how to:

    • Review the project design
    • Propose changes through GitHub Discussions
    • Submit pull requests