#!/usr/bin/env python3
"""
Basic test script for Veo 3 video generation
This script demonstrates basic text-to-video generation using the MCP Veo 3 server.
"""
import asyncio
import os
import sys
from pathlib import Path
# Add parent directory to path to import the MCP server
sys.path.insert(0, str(Path(__file__).parent.parent))
from mcp_veo3 import generate_video_with_progress, gemini_client
async def test_basic_generation():
"""Test basic video generation"""
print("π¬ Testing Basic Veo 3 Video Generation")
print("=" * 50)
# Check API key
api_key = os.getenv("GEMINI_API_KEY")
if not api_key:
print("β Error: GEMINI_API_KEY environment variable not set")
print("Please set your Gemini API key:")
print("export GEMINI_API_KEY='your_api_key_here'")
return
try:
# Initialize client
print("π§ Initializing Veo 3 client...")
client = Veo3Client(api_key)
# Configure generation
config = VideoGenerationConfig(
model="veo-3.0-fast-generate-preview", # Use fast model for testing
aspect_ratio="16:9",
output_dir="test_videos"
)
# Test prompt
prompt = "A peaceful mountain lake reflecting the sunset, with gentle ripples on the water surface"
print(f"π Prompt: {prompt}")
print(f"π¬ Model: {config.model}")
print(f"π Aspect Ratio: {config.aspect_ratio}")
print("\nπ Starting video generation...")
print("β±οΈ This may take 1-6 minutes depending on server load...")
# Generate video
result = await client.generate_video(prompt, config)
# Display results
if result["success"]:
print("\nβ
Video generation completed successfully!")
print(f"π File: {result['video_path']}")
print(f"β±οΈ Generation time: {result['generation_time']:.1f} seconds")
print(f"π File size: {result['file_size'] / 1024 / 1024:.1f} MB")
else:
print(f"\nβ Video generation failed: {result['error']}")
except Exception as e:
print(f"β Test failed with error: {str(e)}")
async def test_with_negative_prompt():
"""Test video generation with negative prompt"""
print("\nπ« Testing Video Generation with Negative Prompt")
print("=" * 50)
api_key = os.getenv("GEMINI_API_KEY")
if not api_key:
print("β Error: GEMINI_API_KEY environment variable not set")
return
try:
client = Veo3Client(api_key)
config = VideoGenerationConfig(
model="veo-3.0-fast-generate-preview",
aspect_ratio="16:9",
output_dir="test_videos"
)
prompt = "A serene forest clearing with tall trees and dappled sunlight"
negative_prompt = "people, animals, buildings, vehicles, noise"
print(f"π Prompt: {prompt}")
print(f"π« Negative Prompt: {negative_prompt}")
print("\nπ Starting video generation with negative prompt...")
result = await client.generate_video(prompt, config, negative_prompt)
if result["success"]:
print("\nβ
Video with negative prompt completed!")
print(f"π File: {result['video_path']}")
print(f"β±οΈ Generation time: {result['generation_time']:.1f} seconds")
else:
print(f"\nβ Generation failed: {result['error']}")
except Exception as e:
print(f"β Test failed with error: {str(e)}")
async def main():
"""Run all tests"""
print("π― Veo 3 MCP Server Test Suite")
print("=" * 50)
await test_basic_generation()
await test_with_negative_prompt()
print("\nπ Test suite completed!")
print("\nπ‘ Tips:")
print("- Check the 'test_videos' directory for generated videos")
print("- Videos are also stored on Google's servers for 2 days")
print("- Use different models for different speed/quality tradeoffs")
if __name__ == "__main__":
asyncio.run(main())