agentic-video-intelligence

mcp
Guvenlik Denetimi
Uyari
Health Uyari
  • License — License: MIT
  • Description — Repository has a description
  • Active repo — Last push 0 days ago
  • Low visibility — Only 5 GitHub stars
Code Uyari
  • network request — Outbound network request in postprocess/ui/src/App.tsx
Permissions Gecti
  • Permissions — No dangerous permissions requested

Bu listing icin henuz AI raporu yok.

SUMMARY

An AI-powered video understanding and retrieval system that combines timestamped transcripts and visual analysis to support semantic search and evidence-grounded answers about video content.

README.md

fcse_logo

Agentic Video Intelligence

An AI platform for long-video understanding and timestamped question answering. It analyzes a video once into structured scene evidence and answers natural-language questions through read-only MCP tools—without embeddings or a vector database.

Walkthrough demo

Features

  • Local preprocessing — scene cut detection (PySceneDetect), speech transcription (faster-whisper INT8 + Silero VAD), and anonymous face clustering (InsightFace).
  • One-time visual analysis — sends one frame per scene to gpt-6-luna for structured JSON notes (Standard, Flex 50% off, or Batch).
  • Grounded MCP agent — answers questions using 5 read-only Model Context Protocol tools (list_videos, search_video_segments, search_dialogue, get_video_scenes, get_segment_context). Citations not returned by a tool call are rejected automatically.
  • Interactive web player — live Dynamic Context Island, stage-aware processing bar, inline scene citation pills, and a timeline that filters to cited moments.

UI elements showcase

Benchmarks

Evaluated on a 136-minute film (The Matrix, 2,427 scenes) across 100 pre-written questions: 62% strict accuracy (70.5% counting partial answers as half), $0.00125 per query, 5.54 s median latency, and €0.023 total billed for one-time visual analysis.

Cost and latency benchmark comparison

How It Works

Instead of feeding hours of raw video frames into a multimodal model on every question, the system splits work into two decoupled phases: a one-time Ingestion pipeline that builds a local JSON evidence store, and an interactive Agentic Retrieval loop that searches only those structured notes through read-only MCP tools.

flowchart LR
    V[Video File] --> S[Scene Cuts & Frames<br/>PySceneDetect]
    V --> A[Audio & Speech<br/>faster-whisper INT8 + VAD]
    S --> F[Anonymous Face Bank<br/>InsightFace SCRFD + ArcFace]
    S --> M[One-Time Visual Notes<br/>gpt-6-luna · 768px JPEG]
    A --> M
    F --> M
    M --> J[(Local JSON Store<br/>data/&lt;sha256&gt;/)]
    J --> MCP[5 Read-Only MCP Tools<br/>Snowball + IDF · Privacy Projection]
    MCP <--> AG[Bounded Agent Loop<br/>≤ 8 rounds · Grounding Check]
    AG --> UI[Timestamped Answer<br/>+ Filtered Timeline]

Phase 1 — Ingestion (Analyze Once)

Every video is hashed (SHA-256) into an isolated folder (data/<sha256>/) with per-stage checkpoints, so interrupted runs resume cleanly without redoing completed work:

  1. Scene detection & representative frames — PySceneDetect splits the video at editorial cuts (threshold=27.0, min_scene_len=0.6s) and extracts one midpoint frame per scene.
  2. Local speech transcription — audio is extracted to 16 kHz mono WAV and transcribed locally with faster-whisper (small, INT8, beam 5) using Silero VAD (0.35) to filter out music and sound effects. Spoken lines are aligned to the scene holding the majority of their words.
  3. Local anonymous face clustering — InsightFace (buffalo_m: SCRFD + ArcFace) detects faces on scene frames and groups embeddings into anonymous IDs (character_1, character_2, …) with no external identity lookup.
  4. One-time structured visual analysis — the only paid API step. One resized frame (768px JPEG, quality 80) with labeled character boxes and nearby dialogue is sent once to gpt-6-luna (via Standard, Flex 50% off, or Batch), returning strict JSON notes (visual_summary, setting, subjects, objects, visible_actions, dialogue_summary).

Phase 2 — Interactive Retrieval (Bounded MCP Agent)

When you ask a question, the agent never sees video frames again. It operates strictly over the saved JSON notes through a local read-only Model Context Protocol (MCP) bridge (JSON-RPC 2.0), also exposed to external MCP clients at POST /api/videos/<id>/mcp.

MCP Tool What it does
list_videos Returns project metadata, duration, and analysis coverage
search_video_segments Lexical OR search with English Snowball stemming, IDF weighting, and optional time_min/max_seconds window
search_dialogue Searches spoken transcript lines directly for quotes and dialogue clues
get_video_scenes Browses chronological paginated scene summaries
get_segment_context Inspects a candidate scene alongside up to neighbors=6 surrounding scenes on each side

Why no vector database or embeddings?
An in-memory Snowball + IDF index over 3,000 scenes builds in < 0.1 s with zero extra infrastructure. Because lexical search misses synonyms on its own, the agent compensates dynamically: on round 1 (tool_choice=required) it fires up to 3 parallel queries with synonym/visual rewrites, then expands promising anchors using get_segment_context and time windows.

Two server-enforced guarantees:

  • Citation grounding — the agent must return a strict JSON schema (kind, text, scene_ids, found). The server rejects any scene_id that was not actually returned by a tool call in the same session (giving the model one automatic retry), and found=false lets it explicitly reject trap questions when no evidence exists. Hard caps (≤ 8 rounds, ≤ 24 tool calls, tools disabled on rounds 7–8) keep latency predictable and guarantee termination.
  • Privacy by projection — before evidence reaches the agent, a projection layer strips character identities, appearance notes, inferred emotions, and raw on-screen text, forwarding only objective scene descriptions, actions, objects, setting, and dialogue.

How It Works

The system splits long-video understanding into two decoupled phases so expensive visual analysis runs once and every question searches lightweight local JSON notes instead of raw video:

flowchart TD
    V["Video File"] --> S["Scene Cuts & Frames · PySceneDetect"]
    V --> A["Audio & Speech · faster-whisper INT8 + VAD"]
    S --> F["Anonymous Face Bank · InsightFace"]
    S --> M["One-Time Visual Notes · gpt-6-luna 768px"]
    A --> M
    F --> M
    M --> J[("Local JSON Store · data/sha256")]
    J --> MCP["5 Read-Only MCP Tools · Snowball + IDF"]
    MCP <--> AG["Bounded Agent · max 8 rounds + Grounding"]
    AG --> UI["Timestamped Answer + Filtered Timeline"]
  • Phase 1 — Ingestion (Analyze Once): Each video is hashed into data/<sha256>/ with resumable checkpoints. Scene cuts (PySceneDetect), speech (faster-whisper INT8 + Silero VAD), and anonymous character clusters (InsightFace) all run locally. Only one resized frame (768px JPEG) per scene is sent once to gpt-6-luna (Standard, Flex 50% off, or Batch) to generate structured JSON scene notes.
  • Phase 2 — Interactive Retrieval (MCP Agent): On each query, the agent never touches video frames again. It queries 5 read-only MCP tools (list_videos, search_video_segments, search_dialogue, get_video_scenes, get_segment_context with neighbors=0..6) over an in-memory Snowball + IDF lexical index—no embeddings or vector database—also exposed at POST /api/videos/<id>/mcp.
  • Grounding & Privacy: Every response follows a strict JSON schema (kind, text, scene_ids, found). The server rejects any scene citation not returned by a tool call in that session (with 1 retry), caps execution at 8 rounds, and strips character identities, emotions, and on-screen text before evidence reaches the agent.

Quick Start

Requires Python 3.11/3.12 and Node.js 22+.

# 1. Python environment
python -m venv .venv
.\.venv\Scripts\pip install -r requirements.txt

# 2. Build the frontend
npm --prefix postprocess/ui ci
npm --prefix postprocess/ui run build

# 3. Run the local server
.\.venv\Scripts\python.exe -m postprocess.serve

Open http://127.0.0.1:8000. Set OPENAI_API_KEY in .env for scene analysis and agentic search (browsing saved results works offline without a key).

Tests

.\.venv\Scripts\python.exe -m pytest tests

Project Layout

  • preprocessing/ — scene detection, frame/audio extraction, transcription, and face clustering
  • process/ — multimodal scene analysis via OpenAI Responses / Flex / Batch
  • postprocess/ — local HTTP server, MCP bridge, grounded agent loop, and React UI (postprocess/README.md)
  • tests/ — Python test suite
  • assets/ — README demos and benchmark chart
  • Agentic Intelligence Video.pdf — diploma thesis paper

License

This project's source code is licensed under the MIT License. Third-party dependencies and downloaded model weights (such as InsightFace buffalo_m and faster-whisper) remain subject to their respective licenses.

Yorumlar (0)

Sonuc bulunamadi