Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Kamal-Nayan-Kumar/AI-Video-Gen/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The Visual Media system provides two distinct ways to add visuals to your presentation:- Manim Animations: AI-generated Python code that creates mathematical and educational animations using the Manim Community Edition library
- Unsplash Images: High-quality, royalty-free photographs fetched from Unsplash’s API based on keywords
Manim Animations
What is Manim?
Manim (Mathematical Animation Engine) is a Python library for creating precise programmatic animations, originally developed by 3Blue1Brown. This project uses Manim Community Edition to generate educational visualizations.When Animations Are Generated
Animations are only created whenneeds_animation=true in the content structure. The system:
- Generates Python Code: Uses Gemini AI to write Manim code based on
animation_description - Validates Structure: Ensures code contains required elements (
class SlideAnimation,def construct(self)) - Saves Script: Writes Python file to
workspace/source/data/manim_code/ - Renders Video: Executes Manim to produce MP4 animation
- Composites onto Slide: Places animation in the designated placeholder area
Animation Code Generation
TheManimGenerator uses Gemini AI with strict guidelines:
Code Structure
All generated animations follow this template:Validation & Fallback
If code generation fails or produces invalid syntax, the system uses a fallback:Animation Rendering
After code generation, Manim CLI renders the animation:- Quality: High (
-qh) for production - Format: MP4 (H.264 codec)
- FPS: 30 frames per second
- Resolution: 1920x1080 (Full HD)
File Naming
Animation files use sanitized filenames:Unsplash Images
When Images Are Fetched
Images are downloaded whenneeds_image=true in the content structure. The system:
- Searches Unsplash: Uses the
image_keywordto query their API - Selects Top Result: Takes the first (most relevant) image
- Downloads Regular Size: Fetches the “regular” resolution variant (~1080px width)
- Saves as JPG: Stores locally for slide rendering
Image Fetcher Implementation
API Configuration
Unsplash requires an access key configured in your environment:Unsplash has a 50 requests per hour rate limit on the free tier. For larger presentations, consider upgrading to a paid plan or caching images.
Image Selection Best Practices
Good keywords:- “Albert Einstein portrait” (specific person)
- “DNA double helix structure” (specific object)
- “solar system planets” (concrete concept)
- “Taj Mahal architecture” (specific place)
- “science” (too broad)
- “learning” (abstract concept)
- “information” (non-visual)
Error Handling
If image fetch fails:- No results found: Slide will render as text-only
- Network error: Exception is caught, empty string returned
- Invalid API key: Error printed to console
Visual Media Directories
File Organization
File Paths
Paths are managed inconfig.py:
Animation vs Image Decision Flow
Here’s how the system decides which visual to use:Customization Options
Manim Render Quality
Adjust quality inconfig.py:
Unsplash Image Size
Modify the URL variant inimage_fetcher.py:27:
Troubleshooting
Manim Animations Not Rendering
Symptom: Animation code generates but MP4 file is missing Solutions:- Verify Manim is installed:
manim --version - Check
MANIM_CODE_GUIDE.mdfor restricted objects - Review Manim logs in console output
- Test animation manually:
manim -pql <script.py> SlideAnimation
Unsplash Images Not Downloading
Symptom: Empty image path returned Solutions:- Verify
UNSPLASH_ACCESS_KEYenvironment variable - Check rate limit (max 50 requests/hour)
- Test keyword in Unsplash web search
- Inspect console for API error messages
Animation Quality Issues
Symptom: Animations look pixelated or blurry Solutions:- Increase render quality:
MANIM_QUALITY = "-qk"(4K) - Ensure source resolution matches output (1920x1080)
- Check font sizes in generated code (should be 24-48pt)
Performance Considerations
- Animation Rendering: Can take 10-60 seconds per animation depending on complexity
- Image Download: Typically less than 2 seconds per image
- Disk Usage: Animations are 1-5 MB each, images are 200-800 KB each
Related Features
- Content Generation - Decides when to use animations vs images
- Video Composition - Integrates visual media into final video timeline