FastAPI application for processing videos and images with LLM integration using OpenRouter.
aidit/
├── app/ # Main application package
│ ├── __init__.py
│ ├── main.py # FastAPI application
│ ├── database.py # SQLAlchemy models
│ ├── video_index.py # VideoIndex class (LLM API calls)
│ ├── video_processor.py # VideoProcessor class (video splitting)
│ └── video_index_processor.py # Queue management
├── docs/ # Documentation
│ ├── README_API.md # Original API documentation
│ └── README_VIDEO_API.md # Video API documentation
├── examples/ # Example scripts and old code
│ ├── wow.py # Original example script
│ ├── api.py # Original API implementation
│ └── chat_interface.html # HTML interface
├── run.py # Application entry point
├── requirements.txt # Python dependencies
├── .gitignore # Git ignore rules
└── README.md # This file
- Install dependencies:
pip install -r requirements.txt- Set environment variables:
Create a
.envfile:
OPENROUTER_KEY=your-api-key-here
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_KEY=your-supabase-service-role-key
VIDEODB_API_KEY=your-videodb-api-key # Optional, for scene indexing
-
Initialize database tables:
- Option 1: Run the SQL in
schema.sqlin your Supabase SQL Editor - Option 2: Use the init script to check table status:
uv run python init_db.py check
- Option 1: Run the SQL in
-
Run the application:
python run.pyOr with uvicorn directly:
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000POST /process/image- Process a single image from URL
POST /process/video- Process a video (downloads, splits, processes frames)GET /status/{video_id}- Get processing statusGET /status/{video_id}/frames- Get all frames with results
GET /detect/errors/{video_id}- Detect and analyze errorsGET /detect/conflicts/{video_id}- Detect conflicts and provide resolution
- ✅ Background processing with queue system
- ✅ Video splitting by granularity (seconds) using OpenCV
- ✅ Base64 conversion for efficient image transmission
- ✅ SQLAlchemy database tracking
- ✅ Configurable prompts per request
- ✅ Comprehensive logging
- ✅ Error detection and conflict resolution
See docs/README_VIDEO_API.md for detailed API documentation.
The application uses a modular architecture:
- VideoIndex: Handles LLM API calls (OpenRouter)
- VideoProcessor: Downloads and splits videos using OpenCV
- VideoIndexProcessor: Manages background queue and processing pipeline
- Database: SQLAlchemy models for tracking videos, frames, and logs
The application is organized as a Python package in the app/ directory. All core functionality is modular and can be imported:
from app.video_index import VideoIndex
from app.video_processor import VideoProcessor
from app.video_index_processor import VideoIndexProcessor