This file provides guidance to WARP (warp.dev) when working with code in this repository.
mmmeld is a multimedia video generator that creates videos from audio and visual inputs. The primary purpose is to "video-ize" audio content for platforms like YouTube. The tool supports text-to-speech generation, AI-powered image creation, YouTube downloads, and complex video composition with background music and fade effects.
# Install dependencies (after installing ffmpeg system-wide)
pip install openai pillow requests tqdm pytube elevenlabs yt-dlp deepgram-sdk aiohttp
# Set up command-line access (Mac/Linux)
chmod +x setup_mmmeld.sh
./setup_mmmeld.sh
# After setup, restart terminal or source shell config
source ~/.bashrc # or ~/.zshrc# Interactive mode (recommended for first-time users)
python mmmeld.py
# or after setup:
mmmeld
# Generate video from local audio and images
mmmeld --audio path/to/audio.mp3 --image path/to/image1.png,path/to/video1.mp4
# Text-to-speech with AI-generated image
mmmeld --audio generate --text "Hello, world!" --image generate --image-description "A futuristic cityscape"
# Use YouTube sources
mmmeld --audio https://www.youtube.com/watch?v=example --image generate --bg-music path/to/music.mp3
# Multiple TTS providers
mmmeld --audio generate --text "Hello" --tts-provider elevenlabs # or openai, deepgram
# Standalone TTS utility
python tts.py --text "Hello world" --provider elevenlabs --voiceid WWr4C8ld745zI3BiA8n7# Run validation tests (Jupyter notebook)
jupyter notebook validation_tests.ipynb
# Quick validation test with test media
mmmeld --audio test_media/5_minutes.mp3 --image test_media/16_9.png --output test_output.mp4# Run with verbose logging
python mmmeld.py --audio generate --text "test" --image generate --nocleanup
# Check ffmpeg installation
ffmpeg -version
# Test individual components
python tts.py --text "test speech" --provider openai --voiceid alloy --output test.mp3Main Entry Point: mmmeld.py
- Orchestrates the entire video generation pipeline
- Handles argument parsing and interactive prompts
- Manages temporary file cleanup
Modular Utilities:
config.py: Argument parsing, API key management, constantsaudio_utils.py: Audio processing, YouTube downloads, TTS integrationvideo_utils.py: Video composition, ffmpeg operations, duration calculationsimage_utils.py: Image generation via DALL-E, image processingfile_utils.py: File I/O, downloads, cleanup, path handlingtts_utils.py: Text-to-speech integration (ElevenLabs, OpenAI, DeepGram)tts.py: Standalone TTS command-line utility
- Input Processing: Parse audio (file/URL/TTS), images/videos (files/URLs/generated), background music
- Duration Calculation: Main audio + margins OR sum of visual durations
- Visual Sequence Creation: Images (5s each), videos (original duration), sequential composition
- Audio Composition: Main audio + margins, background music looping/fading
- Final Render: Combine visuals and audio with proper fade-outs and margins
Duration Rules: With main audio, visuals are cut/looped to fit audio + margins. Without main audio, visual duration determines total length.
Margin System: Configurable lead-in (default 0.5s) and fade-out (default 2s) margins only apply when main audio exists.
File Management: Temporary assets stored in temp_assets/ folder, cleaned up unless --nocleanup specified.
ffmpeg Integration: All video/audio processing uses ffmpeg with hardware acceleration, real-time output logging, and lossless intermediate files.
- ffmpeg: Must be installed and in system PATH
- Python 3.x: Core runtime
- API Keys: Set as environment variables:
OPENAI_API_KEY(for DALL-E image generation and TTS)ELEVENLABS_API_KEY(for premium TTS)DEEPGRAM_API_KEY(for alternative TTS)
openai: DALL-E image generation, GPT text processing, TTSelevenlabs: High-quality text-to-speechdeepgram-sdk: Alternative TTS provideryt-dlp: YouTube media downloadspillow: Image processingrequests,aiohttp: HTTP operationstqdm: Progress bars
├── mmmeld.py # Main application entry point
├── config.py # Configuration and argument parsing
├── audio_utils.py # Audio processing and downloads
├── video_utils.py # Video composition and ffmpeg ops
├── image_utils.py # Image generation and processing
├── file_utils.py # File operations and utilities
├── tts_utils.py # Text-to-speech implementations
├── tts.py # Standalone TTS utility
├── setup_mmmeld.sh # Unix setup script
├── Setup-Mmmeld.ps1 # Windows setup script
└── validation_tests.ipynb # Test scenarios and validation
├── test_media/ # Sample media files for testing
├── temp_assets/ # Temporary files (auto-created, gitignored)
└── .gitignore # Excludes media files and temp assets
Complex logic in video_utils.py handles various input combinations:
- Single/multiple images with/without main audio
- Single/multiple videos with different duration relationships
- Mixed image+video sequences with proper timing distribution
- Background music looping and fade-out synchronization
- ffmpeg operations include comprehensive error logging
- API failures gracefully degrade (e.g., fallback to default images)
- File validation prevents runtime crashes
- Interactive prompts validate user input
- Hardware-accelerated video processing when available
- Lossless intermediate files for quality preservation
- Real-time ffmpeg output for progress monitoring
- Efficient temporary file management
Use validation_tests.ipynb for comprehensive scenario testing. The notebook covers edge cases like single images, multiple videos, margin effects, and various audio/visual combinations.