Transform raw footage into attention-grabbing trailers in seconds with AI-powered content analysis and automated music synchronization.
FRONT-END REPO: https://github.com/prestonty/Trailmixer-frontend#
In today's hyper-digital world filled with endless content, standing out as a creator means acting fast. With the rise of content creators and the boom in AI-powered automation, the need to generate impactful videos β quickly β is more urgent than ever. That's why we built TrailMixer: an AI-assisted video editor that helps creators transform raw footage into attention-grabbing trailers in seconds.
TrailMixer allows users to:
- Upload raw videos (single or multiple files)
- Choose a desired trailer duration (customizable length)
- Select a music style (Pop, Classical, Hip Hop, Electronic, Meme, Cinematic)
- AI-powered analysis that identifies the most meaningful clips
- Automated stitching of polished trailers with background music
- Sentiment-based music matching for perfect mood synchronization
Frontend:
- React, TypeScript, JavaScript
Backend:
- Python 3.8+
- FastAPI (REST API)
- FFmpeg (video/audio processing)
- TwelveLabs API (AI video analysis)
AI Tools:
- TwelveLabs: Multimodal video analysis via prompt engineering
- FFmpeg: Video/audio stitching and processing
- Custom Prompt Engineering: Structured JSON output generation
Architecture Overview (https://miro.com/app/board/uXjVJcA7HWY=/?share_link_id=973269980552)
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β Frontend β β FastAPI β β TwelveLabs β
β (React) βββββΊβ Backend βββββΊβ AI Analysis β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β
βΌ
ββββββββββββββββββββ
β FFmpeg β
β Processing β
ββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββ
β Final Trailer β
β (MP4) β
ββββββββββββββββββββ
- Upload multiple video files
- Automatic concatenation using FFmpeg
- Seamless transition handling
- TwelveLabs API integration for video understanding
- Sentiment analysis for mood detection
- Intelligent segment selection based on importance
- Dynamic music selection based on video mood
- Multiple music styles: Pop, Classical, Hip Hop, Electronic, Meme, Cinematic
- Automatic timing synchronization
- Configurable trailer duration
- Multiple audio tracks support
- Crossfade and transition effects
trailmixer/
βββ app/ # Main application
β βββ main.py # FastAPI server
β βββ models.py # Pydantic data models
β βββ pipeline.py # Video processing pipeline
β βββ video_processor.py # Video analysis logic
β βββ ffmpeg_stitch.py # FFmpeg integration
β βββ ffmpeg_builder.py # FFmpeg command builder
β βββ audio_picker.py # Music selection logic
β βββ twelvelabs_client.py # TwelveLabs API client
β βββ prompts/ # AI prompt engineering
β βββ extract_info.py # Video analysis prompts
βββ music/ # Music library
β βββ pop/ # Pop music tracks
β βββ classical/ # Classical music tracks
β βββ hiphop/ # Hip Hop music tracks
β βββ electronic/ # Electronic music tracks
β βββ meme/ # Meme music tracks
β βββ cinematic/ # Cinematic music tracks
βββ processed_videos/ # Output directory
βββ videos/ # Input video directory
βββ requirements.txt # Python dependencies
βββ README.md # This file
- Python 3.8+
- FFmpeg (must be installed and available in PATH)
- TwelveLabs API Key (sign up at twelvelabs.io)
-
Clone the repository
git clone https://github.com/yourusername/trailmixer.git cd trailmixer -
Create virtual environment
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Set up environment variables
# Create .env file echo "TWELVE_LABS_API_KEY=your_api_key_here" > .env
-
Install FFmpeg
- macOS:
brew install ffmpeg - Ubuntu/Debian:
sudo apt install ffmpeg - Windows: Download from ffmpeg.org
- macOS:
-
Start the FastAPI server
cd app uvicorn main:app --reload --host 0.0.0.0 --port 8000 -
Access the API
- API Documentation: http://localhost:8000/docs
- Health Check: http://localhost:8000/health
import requests
# Upload video and get music timestamps
files = {'video_files': open('your_video.mp4', 'rb')}
response = requests.post('http://localhost:8000/api/video/upload', files=files)
job_id = response.json()['job_id']
# Get music timestamps
timestamps = requests.get(f'http://localhost:8000/api/video/timestamps/{job_id}').json()
# Process video with timestamps
process_data = {
'timestamps': timestamps['videos'][0]['segments'],
'music_file_paths': timestamps['videos'][0]['music_file_paths']
}
result = requests.post(f'http://localhost:8000/api/video/process/{job_id}', json=process_data)| Endpoint | Method | Description |
|---|---|---|
/api/video/upload |
POST | Upload video(s) and get music timestamps |
/api/video/process/{job_id} |
POST | Process video with timestamps |
/api/video/timestamps/{job_id} |
GET | Get music timestamps for job |
/api/video/status/{job_id} |
GET | Get processing status |
/api/video/download/{job_id} |
GET | Download processed video |
/health |
GET | Health check |
Upload Video:
curl -X POST "http://localhost:8000/api/video/upload" \
-H "accept: application/json" \
-H "Content-Type: multipart/form-data" \
-F "video_files=@your_video.mp4"Response:
{
"job_id": "uuid-here",
"music_file_paths": {
"track1": {
"file_path": "music/pop/happy.mp3",
"start_time": 0,
"end_time": 30
}
}
}- Challenge: TwelveLabs doesn't support strict JSON output structures
- Solution: Embedded structured JSON schema within prompts and iteratively refined prompt rules
- Result: Reliable, structured output for video analysis
- Challenge: Stitching clips via Python wrappers had edge cases and limited documentation
- Solution: Extensive research and custom workarounds for cross-platform compatibility
- Result: Robust video processing pipeline
- Challenge: TwelveLabs enforces a 50-request rate limit per API key
- Solution: Generated multiple keys in advance and coordinated usage via shared Discord channel and collaborative Google Doc
- Result: Scalable API usage management
- Rapid Learning: Quickly learned and integrated new tools like TwelveLabs API and FFmpeg
- Full-Stack Development: Designed and implemented a complete product β frontend, backend, AI, media processing β in short timeframe
- Product Workflow: Created complete product workflow in Miro, from ideation to deployment
- AI Integration: Successfully integrated multimodal AI analysis for video content understanding
- Multimodal Media Processing: Gained hands-on experience working with video, audio, and sentiment analysis
- Prompt Engineering: Discovered that prompt engineering is more nuanced than expected β there's much more to explore: few-shot prompting, tool use enforcement, RAG, and even fine-tuning
- API Management: Learned effective strategies for managing API rate limits and coordinating team usage
- Sound Effects: Layer dramatic audio cues over key trailer moments
- External Music Integration: Currently uses static library β next step is to dynamically pull music from external APIs based on style, emotion, and tempo
- Custom Transitions: Add more sophisticated video transitions between segments
- Video Effects: Implement filters, overlays, and visual enhancements
- Batch Processing: Support for processing multiple videos simultaneously
- Fine-tuned Models: Custom training for better video understanding
- RAG Integration: Retrieval-augmented generation for better context
- Real-time Processing: Stream processing for live video feeds
- User Management: Multi-user support with authentication
- Cloud Storage: Integration with cloud storage providers
- Mobile App: Native mobile application for on-the-go editing
We welcome contributions! Please see our Contributing Guidelines for details.
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- TwelveLabs for providing the AI video analysis capabilities
- FFmpeg for the robust video processing tools
- FastAPI for the excellent web framework
- Our Team for the collaborative effort in building this project
- Project Link: https://github.com/yourusername/trailmixer
- Issues: https://github.com/yourusername/trailmixer/issues
Made with β€οΈ by the TrailMixer Team
Transform your content creation workflow with AI-powered video editing.