A comprehensive video analysis tool using Google's Generative AI (Gemini) API. This guide assumes you're starting from scratch on macOS.
# Check if Homebrew is installed
which brew
# If not installed, install it:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"# Check Python version
python3 --version
# If not installed or version < 3.9, install via Homebrew:
brew install python@3.11# Install UV using the official installer
curl -LsSf https://astral.sh/uv/install.sh | sh
# Or install via Homebrew:
brew install uv- Go to Google AI Studio
- Click "Create API Key"
- Copy your API key (keep it safe!)
# Create and navigate to project directory
mkdir ~/video-ai-analyzer
cd ~/video-ai-analyzergit clone <repository-url> .Create these files manually:
1. Create requirements.txt:
cat > requirements.txt << 'EOF'
python-dotenv
google-genai
tqdm
rich
click
EOF2. Create .env.example:
cat > .env.example << 'EOF'
# Google AI API Configuration
GOOGLE_API_KEY=your-api-key-here
# Optional: Custom model selection (default: gemini-2.0-flash)
# GEMINI_MODEL=gemini-2.0-flash-exp
# Optional: Custom reports directory (default: reports)
# REPORTS_DIR=analysis_reports
EOF3. Create .gitignore:
cat > .gitignore << 'EOF'
# Environment variables
.env
# Session data
video_sessions.json
# Video files
*.mp4
*.mov
*.avi
*.mkk
*.webm
# Reports directory
reports/
analysis_reports/
# Python
__pycache__/
*.py[cod]
.venv/
# OS
.DS_Store
EOF4. Copy the main script files:
- Save
video_ai_analyzer.pyfrom the previous artifact - Save
batch_processor.py(optional) - Save
session_viewer.py(optional)
# Initialize UV in the project directory
uv init
# This creates:
# - pyproject.toml
# - .python-version
# - README.md (you can overwrite this)# Install all required packages
uv pip install python-dotenv google-genai tqdm rich click
# Or using requirements.txt:
uv pip install -r requirements.txt# Copy the example environment file
cp .env.example .env
# Open .env in your text editor
nano .env
# OR
open -e .env
# Replace 'your-api-key-here' with your actual Google AI API key
# Save and close the file# If using the full project structure
mkdir utils
touch utils/__init__.py
# Add report_generator.py to utils/ if needed# List installed packages
uv pip list
# You should see:
# - python-dotenv
# - google-genai
# - tqdm
# - rich
# - click# Quick test to ensure packages work
uv run python -c "
from dotenv import load_dotenv
from google import genai
from rich.console import Console
print('✅ All imports successful!')
"# Test if .env is properly configured
uv run python -c "
from dotenv import load_dotenv
import os
load_dotenv()
api_key = os.getenv('GOOGLE_API_KEY')
if api_key and api_key != 'your-api-key-here':
print('✅ API key is configured!')
else:
print('❌ Please set your API key in .env file')
"# Analyze a video interactively
uv run python video_ai_analyzer.py /path/to/your/video.mp4
# Example with a video in Downloads
uv run python video_ai_analyzer.py ~/Downloads/sample.mp4# Generate report and exit
uv run python video_ai_analyzer.py ~/Downloads/sample.mp4 --report-only# Start without specifying a video
uv run python video_ai_analyzer.py# Solution: Ensure you're using uv run
uv run python video_ai_analyzer.py video.mp4
# NOT just:
python video_ai_analyzer.py video.mp4# Check if .env exists and contains your key
cat .env
# Ensure the key is set correctly:
GOOGLE_API_KEY=your-actual-api-key-here# Add UV to your PATH
echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
# Or reinstall UV:
curl -LsSf https://astral.sh/uv/install.sh | sh# Make scripts executable
chmod +x video_ai_analyzer.pyvideo-ai-analyzer/
├── .env # Your API key (DO NOT COMMIT)
├── .env.example # Example configuration
├── .gitignore # Git ignore rules
├── requirements.txt # Python dependencies
├── pyproject.toml # UV project config
├── video_ai_analyzer.py # Main application
├── reports/ # Generated reports (created automatically)
│ └── [timestamp]_[video_name]/
│ ├── video.mp4
│ ├── deep_research_report.md
│ └── chat_history.json
└── video_sessions.json # Upload cache (created automatically)
# 1. Set up everything in one go (copy and paste):
mkdir ~/video-ai-analyzer && cd ~/video-ai-analyzer
curl -LsSf https://astral.sh/uv/install.sh | sh
source ~/.zshrc # or source ~/.bash_profile
uv init
uv pip install python-dotenv google-genai tqdm rich click
# 2. Create .env file and add your API key:
echo "GOOGLE_API_KEY=your-actual-api-key-here" > .env
# 3. Create the main script file (video_ai_analyzer.py)
# Copy the content from the previous artifact
# 4. Run your first analysis:
uv run python video_ai_analyzer.py ~/Downloads/your-video.mp4# Analyze a lecture video
uv run python video_ai_analyzer.py ~/Downloads/lecture.mp4
# Example questions to ask:
# - "Summarize the main concepts covered in this lecture"
# - "Create a study guide with key points"
# - "Generate 10 quiz questions based on this content"
# - "What are the prerequisites needed to understand this material?"# Analyze a Zoom/Teams recording
uv run python video_ai_analyzer.py ~/Documents/team-meeting-2025-01-15.mp4
# Example questions:
# - "List all action items mentioned in this meeting"
# - "Who were the participants and what did each person contribute?"
# - "What decisions were made?"
# - "Create meeting minutes with timestamps"# Analyze a cooking or DIY tutorial
uv run python video_ai_analyzer.py ~/Videos/pasta-recipe.mp4
# Example questions:
# - "List all ingredients with quantities"
# - "Break down the steps with timing"
# - "What equipment is needed?"
# - "What are common mistakes to avoid mentioned in the video?"# Quick report generation for product videos
uv run python video_ai_analyzer.py ~/Downloads/iphone-review.mp4 --report-only
# The report will include:
# - Product features highlighted
# - Pros and cons mentioned
# - Price and availability info
# - Comparison with competitors# Analyze a conference presentation
uv run python video_ai_analyzer.py "~/Videos/AI Conference 2025.mp4"
# Example questions:
# - "What are the key innovations presented?"
# - "Extract all statistics and data points mentioned"
# - "Who are the speakers and their affiliations?"
# - "What future predictions were made?"# Analyze interview videos
uv run python video_ai_analyzer.py ~/Desktop/job-interview.mp4
# Example questions:
# - "Summarize each question asked and the candidate's response"
# - "What are the candidate's main strengths based on their answers?"
# - "Were there any red flags or concerns?"
# - "Rate the candidate's communication skills"# Analyze news segments or documentaries
uv run python video_ai_analyzer.py ~/Movies/climate-documentary.mp4
# Example questions:
# - "What are the main arguments presented?"
# - "List all experts interviewed and their credentials"
# - "What evidence or studies were cited?"
# - "Identify any potential biases in the presentation"# Analyze sports footage
uv run python video_ai_analyzer.py ~/Videos/basketball-game.mp4
# Example questions:
# - "Describe the key plays and turning points"
# - "Which players had standout performances?"
# - "What strategies did each team employ?"
# - "Identify areas for improvement"# List all your previous analyses
uv run python video_ai_analyzer.py
# You'll see:
# Previously Uploaded Videos:
# 1. lecture.mp4 (uploaded: 2025-01-15 14:30)
# 2. team-meeting.mp4 (uploaded: 2025-01-14 09:15)
# 3. product-demo.mp4 (uploaded: 2025-01-13 16:45)
# Select a number to continue analysis without re-uploading# Create a questions file for batch processing
cat > questions.json << 'EOF'
{
"questions": [
"Provide a 3-paragraph summary",
"List the main topics discussed",
"Who is the target audience?",
"What are the key takeaways?",
"Rate the content quality from 1-10 with explanation"
]
}
EOF
# Process multiple videos with same questions
uv run python batch_processor.py \
-v ~/Videos/tutorial1.mp4 \
-v ~/Videos/tutorial2.mp4 \
-v ~/Videos/tutorial3.mp4 \
-q questions.json# Start analysis with a complex video
uv run python video_ai_analyzer.py ~/Downloads/technical-presentation.mp4
# Session flow example:
Your question: Explain the architecture diagram shown at 15:30
# [AI provides detailed explanation]
Your question: How does this compare to traditional approaches?
# [AI compares and contrasts]
Your question: Create implementation steps for a small prototype
# [AI generates step-by-step guide]
Your question: What potential challenges might I face?
# [AI lists challenges and solutions]
Your question: save
# ✓ Session saved to: reports/20250115_143022_technical-presentation/
Your question: exit
# Goodbye!For Technical Content:
# Ask specific technical questions
"Explain the code shown between timestamps 10:00 and 12:00"
"What programming languages and frameworks were mentioned?"
"Create a technical specification based on this demo"For Business Content:
# Focus on actionable insights
"Extract all KPIs and metrics mentioned"
"What is the business model described?"
"Identify competitive advantages discussed"For Educational Content:
# Create learning materials
"Generate flashcards for key concepts"
"Create a glossary of technical terms used"
"Design a homework assignment based on this lecture"-
Explore Features:
- Try interactive Q&A mode
- Use
--report-onlyfor quick analysis - Check generated reports in the
reports/directory
-
Advanced Usage:
- Set up batch processing with
batch_processor.py - Browse previous sessions with
session_viewer.py - Customize report formats in
utils/report_generator.py
- Set up batch processing with
-
Optimization:
- Adjust the Gemini model in
.env - Customize report templates
- Add your own analysis questions
- Adjust the Gemini model in
- UV Documentation: https://github.com/astral-sh/uv
- Google AI Studio: https://makersuite.google.com/
- Rich Documentation: https://rich.readthedocs.io/