视频AI助手

一款本地优先的AI桌面应用程序,可上传视频并智能分析内容,支持生成摘要、PDF报告和PPT演示。

  • by JosephLauYiZhe
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 JosephLauYiZhe/local-ai-video-assistant

使用说明

🎬 视频AI助手

A. 本地首个AI桌面应用程序 它允许您上传视频,并就其内容进行智能对话。使用Tauri、React、Python LangGraph和MCP构建——一切都在你的机器上运行,不需要云AI。

你可以做以下事情:

  • Please summarise this video → 分析所有块的视觉+音频,返回结构化摘要
  • What happens at the 50 seconds mark? → 基于时间戳感知的视频上下文查询
  • Generate a PDF report of this video → 自动导出样式化的PDF报告
  • Can you create a PowerPoint of the key points? → 生成一个黑暗主题的演示文稿

演示

上传视频→ 提出问题→ 获取答案→ 导出PDF或PPTX


特性

所有核心要求均已实施,且功能正常:

  • 视频摄取和预处理 --视频被分割成10秒的块,以便通过MCP服务器使用ffmpeg进行高效处理
  • 平行视觉和转录 --moondream(视觉)和更快的耳语(音频)同时分析每个块
  • 对话式AI --llama3.2通过Ollama生成基于视频分析结果的上下文感知响应
  • 多圈记忆 --LangGraph MemorySaver维护每个会话的会话状态,并触发会话摘要以管理上下文窗口
  • 会话持续 --SQLite根据聊天窗口存储所有消息和会话,在应用程序重启时恢复为LangGraph状态
  • PDF生成 --通过reportlab创建带有标题、章节和要点的样式化PDF报告
  • PowerPoint生成 --深色主题演示文稿,每节一张幻灯片,通过python pptx
  • 文件交付 --生成的文件在聊天中显示为可点击的卡片,使用系统默认应用程序打开
  • 请求取消 --运行中的LangGraph运行可以通过gRPC取消,并进行优雅的清理
  • Tauri台式机外壳 --React前端通过Rust桥上的gRPC流与Python后端通信,Python进程自动生成和管理
  • 本地MCP服务器 --作为llm代理工具的视频预处理、视觉、音频和文件生成

建筑

系统概述

graph TD
    User["👤 User"]

    subgraph Desktop["🖥️ Desktop App - Tauri"]
        UI["⚛️ React UI"]
        Rust["⚙️ Rust Core"]
    end

    subgraph Backend["🐍 Python Backend"]
        gRPC["📡 gRPC Server\n:50051"]
        Agent["🧠 LangGraph\nAgent"]
    end

    subgraph AI["🤖 Local AI - Ollama"]
        LLM["💬 llama3.2"]
        Vision["👁️ moondream"]
        Audio["🎤 whisper"]
    end

    subgraph Out["📁 Outputs"]
        PDF["📄 PDF"]
        PPTX["📊 PPTX"]
        DB["🗃️ SQLite"]
    end

    User -->|"chat + video"| UI
    UI <-->|"invoke / events"| Rust
    Rust <-->|"gRPC stream"| gRPC
    gRPC <--> Agent
    Agent <--> LLM
    Agent --> Vision
    Agent --> Audio
    Agent --> PDF
    Agent --> PPTX
    Rust --> DB

    classDef userStyle fill:#4A90D9,stroke:#2171B5,color:#fff
    classDef frontendStyle fill:#61DAFB,stroke:#21A1C4,color:#000
    classDef rustStyle fill:#CE422B,stroke:#9E2A1B,color:#fff
    classDef grpcStyle fill:#7B61FF,stroke:#5A45CC,color:#fff
    classDef agentStyle fill:#FF6B35,stroke:#CC4A1A,color:#fff
    classDef aiStyle fill:#2ECC71,stroke:#1A9E52,color:#fff
    classDef outputStyle fill:#F39C12,stroke:#C47D0E,color:#fff
    classDef dbStyle fill:#8E44AD,stroke:#6C3483,color:#fff

    class User userStyle
    class UI frontendStyle
    class Rust rustStyle
    class gRPC grpcStyle
    class Agent agentStyle
    class LLM,Vision,Audio aiStyle
    class PDF,PPTX outputStyle
    class DB dbStyle

视频处理流水线

graph TD
    Video["🎬 Video File"]
    Split["✂️ Split into 10s Chunks"]

    subgraph Parallel["⚡ Parallel Processing"]
        V["👁️ Vision\nmoondream"]
        A["🎤 Audio\nfaster-whisper"]
    end

    Context["📝 Build Video Context"]
    LLM["🧠 llama3.2"]

    subgraph FileGen["📁 File Generation"]
        PDF["📄 PDF\nreportlab"]
        PPTX["📊 PowerPoint\npython-pptx"]
    end

    Chat["💬 Chat Response"]

    Video --> Split
    Split --> V
    Split --> A
    V --> Context
    A --> Context
    Context --> LLM
    LLM -->|"PDF requested"| PDF
    LLM -->|"Slides requested"| PPTX
    LLM -->|"Normal query"| Chat

    classDef inputStyle fill:#4A90D9,stroke:#2171B5,color:#fff
    classDef processStyle fill:#7B61FF,stroke:#5A45CC,color:#fff
    classDef parallelStyle fill:#2ECC71,stroke:#1A9E52,color:#fff
    classDef llmStyle fill:#FF6B35,stroke:#CC4A1A,color:#fff
    classDef fileStyle fill:#F39C12,stroke:#C47D0E,color:#fff
    classDef chatStyle fill:#2ECC71,stroke:#1A9E52,color:#fff

    class Video inputStyle
    class Split,Context processStyle
    class V,A parallelStyle
    class LLM llmStyle
    class PDF,PPTX fileStyle
    class Chat chatStyle

技术栈

层 技术
桌面框架 Tauri 2(Rust)
前端 React 18,Vite
后端通信 gRPC(tonic/grpcio)
AI编排 LangGraph、LangChain
工具协议 MCP(模型上下文协议)
LLM 通过Ollama拨打3.2
愿景 通过Ollama实现月球梦
转录 更快的耳语
视频处理 ffmpeg、OpenCV
PDF生成 reportlab
PPTX一代 python PPTX
数据库 SQLite(tauri插件sql)

设置

先决条件

安装

# 1. Clone
git clone https://github.com/yourusername/local-video-ai-assistant.git
cd local-video-ai-assistant

# 2. Pull AI models
ollama pull llama3.2
ollama pull moondreamV
python -c "from transformers import WhisperProcessor, WhisperForConditionalGeneration; WhisperProcessor.from_pretrained('openai/whisper-tiny', cache_dir='./whisper_tiny'); WhisperForConditionalGeneration.from_pretrained('openai/whisper-tiny', cache_dir='./whisper_tiny')"
# Place the whisper_tiny folder at backend root

# 3. Python backend dependencies
cd backend
python -m venv venv
venv\Scripts\activate        # Windows
# source venv/bin/activate   # Mac/Linux
pip install -r requirements.txt

# 4. Frontend dependencies
cd ../app
npm install

# 5. Run
cd ..
npm run tauri dev

项目结构

video-ai-assistant/
├── app/src/
│   ├── components/          # React UI components
│   ├── hooks/useChat.js     # Chat state management
│   └── db.js                # SQLite operations
├── backend/
│   ├── api/grpc_server.py   # gRPC server
│   ├── mcp_servers/         # 4 MCP tool servers
│   └── agent.py             # LangGraph orchestrator
├── src-tauri/src/lib.rs     # Rust Tauri commands
└── schema.proto             # gRPC protocol definition

局限性

  • 模型能力 -由于设备限制,演示中使用的型号是最小的Moondream型号(1.5B)和LLama3.2。切换到更强大的模型可能会改善用户体验。
  • 输出质量 -这也取决于提示。更好的快速工程和少镜头学习可以在主代理和视觉服务器中的某些边缘情况下实现更好的响应。然而,该项目已经过测试,即使在当前提示下,在作业中的示例查询上也取得了合理的性能。
  • 速度 -虽然可以通过更好的设备和模型技巧来提高推理速度,但长视频的处理管道仍有进一步改进的空间。

未来可能的改进

  • 灵活的切换UI -允许用户从设置面板中选择首选的LLM、视觉模型、转录模型。此外,视频分析的细节级别。更高级别的定制和控制。
  • 通过MCP支持Youtube URL -一个额外的MCP工具,接受Youtube URL,下载并直接传递给管道,使用户无需在上传前手动下载视频。
  • 尝试其他LangGraph结构 -将其更改为10个块的10条并行处理路径可以提高效率。

许可证

麻省理工学院©2026[刘益哲]