Skip to content

beroca11/AI-Video-Generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI Video Generator

A full-stack autonomous AI app that generates short narrated videos from text prompts using MetaGPT, ElevenLabs, DALL·E, and FFmpeg.

Features

  • Story Generation: Uses MetaGPT to create engaging stories from text prompts
  • Voice Synthesis: ElevenLabs API for high-quality narration
  • Image Generation: OpenAI DALL·E for scene visualization
  • Video Assembly: FFmpeg for professional video creation
  • Web Interface: React frontend with real-time progress tracking
  • Persistent Storage: Supabase for job management and video storage

Project Structure

AI Project/
├── agents/                 # MetaGPT agents
│   ├── storywriter.py     # Story generation
│   ├── narrator.py        # Voice synthesis
│   ├── visual.py          # Image generation
│   └── editor.py          # Video assembly
├── tools/                  # API wrappers
│   ├── elevenlabs_client.py
│   ├── openai_client.py
│   ├── ffmpeg_utils.py
│   └── supabase_client.py
├── backend/
│   └── api/
│       └── app.py         # FastAPI backend
├── frontend/              # React frontend
│   ├── src/
│   │   ├── App.jsx
│   │   ├── main.jsx
│   │   └── index.css
│   ├── package.json
│   └── vite.config.js
├── main.py                # Standalone pipeline
├── requirements.txt       # Python dependencies
└── .gitignore            # Git ignore rules

Prerequisites

Before you begin, ensure you have the following installed:

  • Python 3.9+ (but less than 3.12)
  • Node.js 16+ and npm
  • FFmpeg (for video processing)
  • Git (for cloning the repository)

Quick Start

1. Clone the Repository

git clone <your-repository-url>
cd AI-Project

2. Install MetaGPT

Option A: Install via pip (Recommended)

pip install metagpt

Option B: Install from source (if you need the latest version)

git clone https://github.com/geekan/MetaGPT.git
cd MetaGPT
pip install -e .
cd ..

3. Install Python Dependencies

pip install -r requirements.txt

4. Install Frontend Dependencies

cd frontend
npm install
cd ..

5. Set Up Environment Variables (Optional)

Create a .env file in the root directory:

# API Keys (optional - mock mode available)
OPENAI_API_KEY=your_openai_key
ELEVENLABS_API_KEY=your_elevenlabs_key
SUPABASE_URL=your_supabase_url
SUPABASE_ANON_KEY=your_supabase_key

6. Install FFmpeg

Windows:

# Download from https://ffmpeg.org/download.html
# Add to PATH

macOS:

brew install ffmpeg

Linux:

sudo apt update
sudo apt install ffmpeg

Verify FFmpeg installation:

ffmpeg -version

Running the Application

Option 1: Standalone Pipeline

Test the core pipeline with a hardcoded prompt:

python main.py

Option 2: Full Web Application

Start the Backend

cd backend/api
uvicorn app:app --reload --host 0.0.0.0 --port 8000

Start the Frontend

cd frontend
npm run dev

The application will be available at:

API Endpoints

  • POST /generate - Start video generation
  • GET /status/{job_id} - Get job status
  • GET /result/{job_id} - Get video result
  • GET /download/{job_id} - Download video file

Development

Mock Mode

All API clients support mock mode for development:

  • ElevenLabs: Generates silent audio files
  • OpenAI DALL·E: Creates placeholder images with text
  • Supabase: Uses local file storage
  • FFmpeg: Requires actual FFmpeg installation

Adding Real APIs

  1. Set your API keys in environment variables
  2. The clients will automatically switch from mock to real mode
  3. For Supabase, create a videos table with the schema from VideoMetadata

Customization

  • Story Style: Modify prompts in agents/storywriter.py
  • Voice: Change voice settings in tools/elevenlabs_client.py
  • Image Style: Adjust DALL·E parameters in tools/openai_client.py
  • Video Effects: Add FFmpeg filters in tools/ffmpeg_utils.py

Troubleshooting

Common Issues

  1. FFmpeg not found: Install FFmpeg and ensure it's in your PATH
  2. Import errors: Make sure you're in the project root directory
  3. API rate limits: Add delays or use mock mode for development
  4. CORS errors: The frontend proxy should handle this automatically
  5. MetaGPT import errors: Ensure MetaGPT is properly installed

Debug Mode

Enable debug logging by setting environment variables:

export PYTHONPATH=.
export DEBUG=1

MetaGPT Configuration

If you encounter MetaGPT configuration issues:

# Initialize MetaGPT config
metagpt --init-config

# This creates ~/.metagpt/config2.yaml
# Edit the file with your API keys:
# llm:
#   api_type: "openai"
#   model: "gpt-4-turbo"
#   api_key: "YOUR_OPENAI_API_KEY"

Production Deployment

Backend (FastAPI)

# Using Gunicorn
pip install gunicorn
gunicorn app:app -w 4 -k uvicorn.workers.UvicornWorker

Frontend (React)

cd frontend
npm run build
# Serve the dist/ directory

Environment Setup

  1. Set up a Supabase project for production storage
  2. Configure API keys for all services
  3. Set up proper CORS and security headers
  4. Use a reverse proxy (nginx) for production

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

License

MIT License - see LICENSE file for details

Acknowledgments

About

A full-stack autonomous AI app that generates short narrated videos from text prompts using MetaGPT, ElevenLabs, DALL·E, and FFmpeg.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors