A streamlined, AI-powered video analysis platform with FastAPI backend and Next.js frontend, featuring RAG chat, visual search, and intelligent section generation.
This platform enables users to upload YouTube videos and perform advanced analysis including:
- AI-powered section generation with meaningful titles and timestamps
- RAG (Retrieval-Augmented Generation) chat for content-based Q&A
- Visual search across video frames using natural language queries
- Frame extraction and embeddings for multi-modal search capabilities
Size Reduction Achieved:
- Total project size: 1.4GB β 993MB (407MB saved, 29% reduction)
- Frontend directory: 356KB β 132KB (63% reduction)
- Storage directory: 418MB β 13.5MB (97% reduction)
Key Improvements:
- β Fixed visual search with proper similarity scores and frame display
- β Enhanced section generation with meaningful AI-generated titles
- β Streamlined backend with clean imports and working SQLite database
- β Removed 404MB of deprecated storage (temp files, old vector databases)
- β Eliminated redundant services and dependencies
- Framework: FastAPI with Uvicorn
- Database: SQLite with SQLAlchemy ORM
- AI/ML: OpenAI GPT, LangChain, CLIP embeddings
- Video Processing: yt-dlp, FFmpeg
- Dependencies: Python 3.12+
- Framework: Next.js 15 with App Router
- Language: TypeScript
- Styling: Tailwind CSS
- State Management: React Context
- UI Components: Custom React components
multi-video-analysis/
βββ src/ # Backend source code (152KB)
β βββ app/
β β βββ api/routes.py # API endpoints
β β βββ main.py # FastAPI application
β β βββ db/ # Database models and connection
β β βββ services/ # Core business logic
β β βββ langchain_service.py # RAG chat and sections
β β βββ video_service.py # Video management
β β βββ frame_service.py # Frame processing
β β βββ visual_search_service.py # Visual search
βββ frontend/ # Frontend application (132KB)
β βββ src/
β β βββ app/ # Next.js app directory
β β βββ components/ # React components
β β βββ context/ # State management
β β βββ lib/ # API client and types
β βββ package.json # Dependencies
β βββ *.config.* # Configuration files
βββ storage/ # Application data (13.5MB)
β βββ frames/ # Extracted video frames
β βββ embeddings/ # CLIP visual embeddings
βββ requirements.txt # Python dependencies
βββ start_backend.sh # Backend startup script
βββ README.md # This file
- Python 3.12+
- Node.js 18+
- FFmpeg (for video processing)
- OpenAI API key (for AI features)
- Create virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Set environment variables:
export DATABASE_URL="sqlite:///./video_analysis.db"
export OPENAI_API_KEY="your-openai-api-key"- Start backend server:
./start_backend.sh
# Or manually: python -m uvicorn src.app.main:app --host 0.0.0.0 --port 8000- Navigate to frontend directory:
cd frontend- Install dependencies:
npm install # Regenerates package-lock.json automatically- Start development server:
npm run dev- Access application:
- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
- API docs: http://localhost:8000/docs
- YouTube URL input with validation
- Automatic transcript extraction (when available)
- Fallback to dummy transcripts for testing
- Intelligent breakdown of video content
- Meaningful section titles with timestamps
- Enhanced prompting for better AI responses
- Regeneration capability for improved results
- Content-aware Q&A using video transcripts
- OpenAI GPT integration with LangChain
- Citation support with timestamp links
- Conversation history tracking
- Frame Extraction: Extract frames at regular intervals
- CLIP Embeddings: Generate visual embeddings for frames
- Multi-modal Search: Text, visual, or hybrid search modes
- Accurate Results: Proper similarity scoring and frame display
- Embedded YouTube player with react-player
- Section-based navigation
- Timestamp synchronization
- Current section highlighting
POST /api/upload- Upload and process YouTube videoGET /api/sections/{video_id}- Get video sectionsPOST /api/sections/{video_id}/regenerate- Regenerate sections
POST /api/videos/{video_id}/extract-frames- Extract video framesPOST /api/videos/{video_id}/generate-embeddings- Generate CLIP embeddingsGET /api/visual-search/{video_id}- Search frames by query
POST /api/chat/{video_id}- RAG chat with video contentGET /api/frames/{video_id}- Get extracted frames
- VideoUpload.tsx - YouTube URL input and processing
- VideoPlayer.tsx - Video playback with sections
- ChatInterface.tsx - RAG chat functionality
- VisualSearch.tsx - Frame search interface
- VideoContext - Global state with React Context
- API Integration - Centralized API client with TypeScript types
- Real-time Updates - Loading states and error handling
- Video: YouTube metadata, processing status
- Section: AI-generated content segments
- Frame: Extracted video frames with timestamps
- Visual embeddings: CLIP vectors stored locally
- Model: OpenAI CLIP for multi-modal embeddings
- Storage: Local file system (no external vector DB)
- Search Types:
- Text: Query against frame context
- Visual: CLIP similarity search
- Hybrid: Combined text + visual scoring
- Database: SQLite suitable for development; consider PostgreSQL for production
- Storage: Local frame storage; consider cloud storage for scale
- API Keys: Secure OpenAI API key management
- Video Processing: FFmpeg dependency for frame extraction
DATABASE_URL=sqlite:///./video_analysis.db
OPENAI_API_KEY=your-api-key-here
NEXT_PUBLIC_API_URL=http://localhost:8000- Deprecated Services: embeddings.py, visual_search.py, rag_chat.py
- Failed Storage: 404MB of temp files and broken vector databases
- Redundant Files: Documentation, lock files, deployment configs
- Unused Dependencies: qdrant-client, psycopg2
- Backend: 152KB essential Python services
- Frontend: 132KB optimized React application
- Storage: 13.5MB working frames and embeddings only
- Frontend Turbopack Error: Run
npm installto regenerate dependencies - Backend Import Errors: Ensure all deprecated services are removed
- Database Connection: Verify DATABASE_URL environment variable
- Visual Search: Check CLIP model loading and frame extraction
- Use
./start_backend.shfor consistent backend startup - Frontend hot-reload available with
npm run dev - Check API docs at
/docsfor endpoint testing - Monitor console for visual search debugging
- Startup Time: ~2 seconds for backend, ~5 seconds for frontend
- Frame Processing: ~1-2 seconds per video minute
- Visual Search: ~100ms for CLIP similarity search
- Memory Usage: ~500MB for full application stack
- Fork the repository
- Create feature branch:
git checkout -b feature-name - Commit changes:
git commit -m 'Add feature' - Push to branch:
git push origin feature-name - Submit pull request
This project is available under the MIT License.
Last Updated: December 2024
Version: 2.0 (Optimized)
Status: Production Ready