A complete Python system for generating AI videos using Google's Vertex AI Veo 2.0 model. Features segment-based story generation, automatic concatenation, and the "Ece & Jonas - Simit Surprise!" cultural friendship story.
- 50-Second Story Generation: Complete "Simit Surprise" cultural story
- Segment-Based Pipeline: 7 individual segments with smooth transitions
- Content Filter Compliant: Safe, child-friendly content generation
- FFmpeg Integration: Professional video concatenation with crossfade transitions
- Cultural Education: Teaches diversity and friendship through food sharing
- Google Cloud Project with billing enabled
- Vertex AI API enabled in
us-central1region - Python 3.7+
- gcloud CLI installed and configured
# Clone or download this project
cd MovieProject
# Install dependencies
pip install -r requirements.txt
# Authenticate with Google Cloud
gcloud auth application-default loginCreate your config/config.yaml:
google_project_id: "your-project-id"
google_region: "us-central1"python example.pyMovieProject/
βββ video_generator.py # Main video generation engine
βββ example.py # Usage examples
βββ config/config.yaml # Project configuration
βββ service-account-key.json # Google Cloud credentials (optional)
βββ requirements.txt # Python dependencies
βββ requirements.md # Detailed system requirements
βββ generated_videos/ # Output directory (auto-created)
βββ README.md # This file
from video_generator import VideoGenerator
# Initialize
generator = VideoGenerator()
# Generate a video
video_path = generator.generate(
prompt="A majestic elephant walking through a forest, cinematic lighting",
duration=8 # seconds
)
print(f"Video saved: {video_path}")# Custom parameters
video_path = generator.generate(
prompt="Your detailed video description here",
duration=5, # 5-8 seconds supported
model_id="veo-2.0-generate-001" # Veo 2.0 model
)- Duration: 5-8 seconds
- Aspect Ratio: 16:9 (fixed)
- Resolution: 720p
- Format: MP4
- Frame Rate: 24 FPS
- Model:
veo-2.0-generate-001(Generally Available) - Region:
us-central1(REQUIRED - only working region) - Prompt Enhancement: Automatically enabled
- Watermark: Enabled by default
- Create Project & Enable APIs:
# Set your project
gcloud config set project your-project-id
# Enable Vertex AI API
gcloud services enable aiplatform.googleapis.com- Authentication (Choose one method):
Option A: Application Default Credentials (Recommended)
gcloud auth application-default loginOption B: Service Account
# Create service account
gcloud iam service-accounts create veo-generator
# Add required roles
gcloud projects add-iam-policy-binding your-project-id \
--member="serviceAccount:veo-generator@your-project-id.iam.gserviceaccount.com" \
--role="roles/aiplatform.user"
# Download key
gcloud iam service-accounts keys create service-account-key.json \
--iam-account=veo-generator@your-project-id.iam.gserviceaccount.com# Test authentication
gcloud auth list
# Test API access
python -c "from video_generator import VideoGenerator; print('β
Setup successful!')"- Typical Generation Time: 45-90 seconds
- Success Rate: >95% with proper configuration
- File Size: ~1-2 MB per second of video
- Timeout: 15 minutes maximum
- Resolution: 1280x720 (720p)
- Encoding: H.264/MP4
- Quality: High-definition, cinematic
- Audio: Not supported (Veo 2.0 is video-only)
Good Prompts Include:
- Specific subject and action
- Visual style and mood
- Camera angle/movement
- Lighting conditions
- Quality descriptors
Example Good Prompts:
"A majestic African elephant walking slowly through a lush green forest, dappled sunlight filtering through trees, cinematic wide shot, 4K quality, natural movement"
"Ocean waves gently crashing on a pristine beach at golden hour, warm sunset lighting, peaceful atmosphere, slow motion, cinematic"
"A red sports car driving on a winding mountain road, dramatic lighting, aerial view, high-speed cinematography"
Avoid:
- Vague descriptions
- Multiple unrelated subjects
- Complex scene changes
- Text or logos in videos
Authentication Error:
gcloud auth application-default login404 Model Not Found:
- Ensure you're using
us-central1region - Verify Vertex AI API is enabled
- Check project ID in config
Long Generation Times:
- Normal: 45-90 seconds
- If >5 minutes, check logs for errors
- Timeout after 15 minutes
Permission Denied:
- Verify IAM roles:
Vertex AI User - Check project billing is enabled
- Ensure API is enabled in correct region
Enable detailed logging:
import logging
logging.basicConfig(level=logging.DEBUG)
generator = VideoGenerator()For detailed technical requirements, see requirements.md.
- Python: 3.7+
- Memory: 1GB RAM
- Storage: 100MB for dependencies + video storage
- Network: Stable internet connection
- Google Cloud: Project with billing enabled
requests- HTTP clientpyyaml- Configuration parsinggoogle-auth- Authenticationgoogle-cloud-aiplatform- Vertex AI SDK
This implementation follows the Google Cloud Vertex AI Video Generation API.
- Uses
predictLongRunningfor video generation requests - Uses
fetchPredictOperationfor status polling (not standard operation polling) - Follows Google Console parameter format exactly
- Implements automatic token refresh via gcloud CLI
For Issues:
- Check troubleshooting section above
- Verify Google Cloud setup
- Review
requirements.mdfor detailed specs - Check Google Cloud Console for API quotas/billing
For Questions:
- Review the example code in
example.py - Check the detailed requirements in
requirements.md - Consult Google Cloud documentation
β
Proven Working: Based on successful reverse-engineering of Google Console guidance
β
Optimized Performance: 45-90 second generation times vs. previous timeout issues
β
Correct Region: Uses us-central1 (the only working region despite documentation)
β
Proper Parameters: String format for durationSeconds and other critical settings
β
Reliable Polling: Uses fetchPredictOperation endpoint for consistent results
β
Simple & Clean: Minimal dependencies, clear code structure
Happy video generating! π¬β¨