Skip to content

nittygritty-zzy/video-ai-analyzer

Repository files navigation

Video AI Analyzer - Mac Installation Guide

A comprehensive video analysis tool using Google's Generative AI (Gemini) API. This guide assumes you're starting from scratch on macOS.

Prerequisites

1. Install Homebrew (if not already installed)

# 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)"

2. Install Python (if not already installed)

# Check Python version
python3 --version

# If not installed or version < 3.9, install via Homebrew:
brew install python@3.11

3. Install UV (Python Package Manager)

# Install UV using the official installer
curl -LsSf https://astral.sh/uv/install.sh | sh

# Or install via Homebrew:
brew install uv

4. Get a Google AI API Key

  1. Go to Google AI Studio
  2. Click "Create API Key"
  3. Copy your API key (keep it safe!)

Installation Steps

Step 1: Create Project Directory

# Create and navigate to project directory
mkdir ~/video-ai-analyzer
cd ~/video-ai-analyzer

Step 2: Download Project Files

Option A: Clone from GitHub (if available)

git clone <repository-url> .

Option B: Manual Setup

Create these files manually:

1. Create requirements.txt:

cat > requirements.txt << 'EOF'
python-dotenv
google-genai
tqdm
rich
click
EOF

2. 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
EOF

3. 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
EOF

4. Copy the main script files:

  • Save video_ai_analyzer.py from the previous artifact
  • Save batch_processor.py (optional)
  • Save session_viewer.py (optional)

Step 3: Initialize UV Environment

# Initialize UV in the project directory
uv init

# This creates:
# - pyproject.toml
# - .python-version
# - README.md (you can overwrite this)

Step 4: Install Dependencies

# Install all required packages
uv pip install python-dotenv google-genai tqdm rich click

# Or using requirements.txt:
uv pip install -r requirements.txt

Step 5: Configure Your API Key

# 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

Step 6: Create Utils Directory (Optional)

# If using the full project structure
mkdir utils
touch utils/__init__.py
# Add report_generator.py to utils/ if needed

Verify Installation

Test 1: Check UV Environment

# List installed packages
uv pip list

# You should see:
# - python-dotenv
# - google-genai
# - tqdm
# - rich
# - click

Test 2: Test Import

# 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 3: Check API Key

# 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')
"

Usage

Basic Video Analysis

# 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

Report-Only Mode

# Generate report and exit
uv run python video_ai_analyzer.py ~/Downloads/sample.mp4 --report-only

Use Previous Uploads

# Start without specifying a video
uv run python video_ai_analyzer.py

Common Issues & Solutions

Issue 1: "ModuleNotFoundError"

# 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

Issue 2: "GOOGLE_API_KEY not found"

# Check if .env exists and contains your key
cat .env

# Ensure the key is set correctly:
GOOGLE_API_KEY=your-actual-api-key-here

Issue 3: UV Command Not Found

# 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

Issue 4: Permission Denied

# Make scripts executable
chmod +x video_ai_analyzer.py

Project Structure

video-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)

Quick Start Commands

# 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

Example Usage Scenarios

1. Educational Content Analysis

# 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?"

2. Meeting Recording Analysis

# 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"

3. Tutorial/How-To Video Analysis

# 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?"

4. Product Demo/Review Analysis

# 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

5. Presentation/Webinar Analysis

# 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?"

6. Interview Analysis

# 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"

7. Documentary/News Analysis

# 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"

8. Sports/Performance Analysis

# 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"

9. Using Previous Sessions

# 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

10. Batch Analysis Example

# 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

11. Advanced Interactive Session

# 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!

12. Quick Tips for Better Results

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"

Next Steps

  1. Explore Features:

    • Try interactive Q&A mode
    • Use --report-only for quick analysis
    • Check generated reports in the reports/ directory
  2. 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
  3. Optimization:

    • Adjust the Gemini model in .env
    • Customize report templates
    • Add your own analysis questions

Support

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages