
Veo Use
- 181 installs
- 124 repo stars
- Updated February 6, 2026
- cnemri/google-genai-skills
Helps with ai & agent building tasks.
About
veo-use is a Claude Code skill for ai & agent building. It helps solo builders move faster with AI-assisted coding.
- veo-use
- AI & Agent Building
- AI-coding skill
Veo Use by the numbers
- 181 all-time installs (skills.sh)
- Ranked #3,045 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
- Data as of Jul 29, 2026 (Skillselion catalog sync)
npx skills add https://github.com/cnemri/google-genai-skills --skill veo-useAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 181 |
|---|---|
| repo stars | ★ 124 |
| Last updated | February 6, 2026 |
| Repository | cnemri/google-genai-skills ↗ |
What it does
Helps with ai & agent building tasks.
Files
Veo Use
Use this skill to generate and edit videos using Google's Veo models (veo-3.1 and veo-2.0).
This skill uses portable Python scripts managed by uv.
Prerequisites
Ensure you have one of the following authentication methods configured in your environment:
1. API Key:
-
GOOGLE_API_KEYorGEMINI_API_KEY
2. Vertex AI:
-
GOOGLE_CLOUD_PROJECT -
GOOGLE_CLOUD_LOCATION -
GOOGLE_GENAI_USE_VERTEXAI=1
Usage
1. Text to Video
Generate a video purely from a text description.
uv run skills/veo-use/scripts/text_to_video.py "A cinematic drone shot of a futuristic city" --output city.mp42. Image to Video
Generate a video starting from a static image context.
uv run skills/veo-use/scripts/image_to_video.py "Zoom out from the flower" --image start.png --output flower.mp43. Reference to Video
Use specific asset images (subjects, products) to guide generation.
uv run skills/veo-use/scripts/reference_to_video.py "A man walking on the moon" --reference-image man.png --output moon_walk.mp44. Edit Video (Inpainting)
Modify existing videos using masks.
Modes:
-
REMOVE: Remove dynamic object. -
REMOVE_STATIC: Remove static object (watermark). -
INSERT: Insert new object (requires--prompt).
uv run skills/veo-use/scripts/edit_video.py --video input.mp4 --mask mask.png --mode INSERT --prompt "A flying car" --output edited.mp45. Extend Video
Extend the duration of an existing video clip.
uv run skills/veo-use/scripts/extend_video.py --video clip.mp4 --prompt "The car flies away into the sunset" --duration 6 --output extended.mp4Common Options
-
--model: Defaultveo-3.1-generate-001. -
--resolution:1080p(default),720p,4k. -
--aspect-ratio:16:9(default),9:16. -
--duration:6(default),4,8.
References
Before running scripts, review the reference guides for prompting tips and best practices.
- Prompting Guide - Camera angles, movements, lens effects, and visual styles
Vertex AI Veo Prompting Guide
This guide provides a comprehensive overview of how to write effective prompts for Veo, Google's text-to-video and image-to-video generation model.
Core Components
A well-structured prompt typically includes: 1. Subject: The main character, object, or focus. 2. Action: What the subject is doing. 3. Scene/Context: The environment, setting, and background. 4. Cinematography: Camera angles, movements, and lens effects. 5. Visual Style: The overall aesthetic, lighting, and mood. 6. Ambiance: Sensory details. 7. Audio: Sound effects or speech.
Detailed Options
Cinematography (Camera & Lens)
Camera Angles
- Eye-Level Shot: Neutral perspective.
- Low-Angle Shot: Subject appears powerful.
- High-Angle Shot: Subject appears small/vulnerable.
- Bird's-Eye View / Top-Down: Directly from above.
- Dutch Angle / Canted Angle: Tilted to convey unease.
- Close-Up / Extreme Close-Up: Emphasizes emotions/details.
- Wide Shot / Establishing Shot: Shows context.
- Over-the-Shoulder: Behind one person looking at another.
- Point-of-View (POV): Character's visual perspective.
Camera Movements
- Static/Fixed: No movement.
- Pan (Left/Right): Horizontal rotation.
- Tilt (Up/Down): Vertical rotation.
- Dolly (In/Out): Camera moves closer/further.
- Zoom (In/Out): Lens focal length change.
- Truck (Left/Right): Camera moves laterally.
- Pedestal (Up/Down): Camera moves vertically.
- Crane / Aerial / Drone Shot: High altitude, sweeping.
- Handheld / Shaky Cam: Realism or unease.
- Whip Pan: Fast blur pan.
Lens & Optical Effects
- Wide-Angle (e.g., 24mm): Broader view, exaggerated perspective.
- Telephoto (e.g., 85mm): Compressed perspective, isolation.
- Shallow Depth of Field / Bokeh: Blurred background.
- Deep Depth of Field: Everything in focus.
- Lens Flare: Bright light source effect.
- Rack Focus: Shifting focus between subjects.
- Vertigo Effect (Dolly Zoom): Disorienting distortion.
Visual Style & Aesthetics
- Photorealistic / Cinematic: High fidelity.
- Vintage / Film Noir: Sepia, grainy, high contrast black & white.
- Animation Styles: 3D cartoon, Claymation, Stop-motion, Anime.
- Artistic: Impressionist (Van Gogh), Surrealist.
- Lighting: High-key (bright), Low-key (dark/moody), Golden hour, Volumetric (God rays), Backlighting (silhouette).
Temporal Elements
- Pacing: Slow-motion, Fast-paced action.
- Evolution: Time-lapse, Hyperlapse.
- Rhythm: Pulsating light, Rhythmic movement.
Best Practices
- Be Specific: Avoid "A man walking." Use "Eye-level medium shot of a young man in a soaked trench coat..."
- Negative Prompts: Define what to exclude (e.g., "Negative prompt: blurry, distorted, text, watermark").
- Iterate: Use Gemini to rewrite prompts for better detail.
Audio (Preview)
Specify sound effects or speech clearly.
- "The audio features water splashing."
- "The man says, 'Where is the rabbit?'"
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "google-genai",
# "python-dotenv",
# "pillow",
# ]
# ///
import os
from dotenv import load_dotenv
import argparse
import sys
import time
from google import genai
from google.genai import types
load_dotenv()
def get_client():
api_key = os.environ.get("GOOGLE_API_KEY") or os.environ.get("GEMINI_API_KEY")
if api_key:
return genai.Client(api_key=api_key)
project = os.environ.get("GOOGLE_CLOUD_PROJECT")
location = os.environ.get("GOOGLE_CLOUD_LOCATION")
use_vertex = os.environ.get("GOOGLE_GENAI_USE_VERTEXAI", "").lower()
if project and location and use_vertex in ("1", "true"):
return genai.Client(vertexai=True, project=project, location=location)
print("=" * 60)
print("AGENT ERROR: Missing required environment variables!")
print("=" * 60)
print()
print("To use Veo video editing, the user must configure their")
print(".env file with the following environment variables:")
print()
print("Option 1 - Using Gemini API Key:")
print(" GOOGLE_API_KEY=<api-key>")
print()
print("Option 2 - Using Vertex AI (recommended for Veo):")
print(" GOOGLE_CLOUD_PROJECT=<project-id>")
print(" GOOGLE_CLOUD_LOCATION=us-central1")
print(" GOOGLE_GENAI_USE_VERTEXAI=1")
print()
print("IMPORTANT: For Veo APIs, location MUST be 'us-central1'.")
print()
print("Please ask the user to create or update their .env file")
print("with the required credentials before retrying.")
print("=" * 60)
sys.exit(1)
def main():
parser = argparse.ArgumentParser(description="Edit videos using Veo 2 models.")
parser.add_argument("--video", required=True, help="URI or Path to input video")
parser.add_argument("--mask", required=True, help="Path to mask image")
parser.add_argument("--mode", required=True, choices=["REMOVE", "REMOVE_STATIC", "INSERT"], help="Edit mode")
parser.add_argument("--prompt", help="Text prompt (required for INSERT mode)")
parser.add_argument("--model", default="veo-2.0-generate-preview", help="Model to use (default: veo-2.0-generate-preview)")
parser.add_argument("--output", default="edited_video.mp4", help="Output filename")
args = parser.parse_args()
if args.mode == "INSERT" and not args.prompt:
print("Error: --prompt is required for INSERT mode.")
sys.exit(1)
client = get_client()
try:
# Determine Mask Mode
mask_mode_map = {
"REMOVE": types.VideoGenerationMaskMode.REMOVE,
"REMOVE_STATIC": types.VideoGenerationMaskMode.REMOVE_STATIC,
"INSERT": types.VideoGenerationMaskMode.INSERT
}
# Configure Mask
if not os.path.exists(args.mask):
print(f"Error: Mask image '{args.mask}' not found.")
sys.exit(1)
mask = types.VideoGenerationMask(
image=types.Image.from_file(location=args.mask),
mask_mode=mask_mode_map[args.mode]
)
# Configure Source Video
# Check if local or GCS URI
video_source = None
if args.video.startswith("gs://"):
video_source = types.Video(uri=args.video, mime_type="video/mp4")
elif os.path.exists(args.video):
# For local files, we might need to upload or read bytes.
# The SDK usually expects a URI for videos, or we can try from_file if supported for Video?
# `types.Video` supports `uri`.
# Let's assume for editing we prefer GCS URIs, but if local, we try to pass it?
# Usually `types.Video` takes URI. Uploading might be needed.
# For now, let's warn if it's local but try to pass path?
print("Note: Local video files might need to be uploaded to GCS for best performance.")
# We can't easily upload here without google-cloud-storage lib.
# We'll try passing the path as uri (some SDKs handle local paths by uploading temporarily).
# If not, we'll fail.
video_source = types.Video(uri=args.video, mime_type="video/mp4")
else:
print(f"Error: Video '{args.video}' not found.")
sys.exit(1)
source_args = {
"video": video_source
}
if args.mode == "INSERT":
source_args["prompt"] = args.prompt
source = types.GenerateVideosSource(**source_args)
config = types.GenerateVideosConfig(
mask=mask,
enhance_prompt=True
)
print(f"Submitting video editing job to {args.model}...")
operation = client.models.generate_videos(
model=args.model,
source=source,
config=config
)
print(f"Operation name: {operation.name}")
print("Waiting for operation to complete...")
while True:
op_status = client.operations.get(operation)
if op_status.done:
break
time.sleep(10)
print(".", end="", flush=True)
print("")
print("Operation complete.")
if op_status.error:
print(f"Operation failed with error: {op_status.error}")
sys.exit(1)
result = op_status.result
if result and result.generated_videos:
vid = result.generated_videos[0]
try:
if hasattr(vid, 'video'):
vid.video.save(args.output)
print(f"Video saved to {args.output}")
else:
print("Error: GeneratedVideo object has no 'video' attribute.")
except Exception as e:
print(f"Failed to save video using .save(): {e}")
if hasattr(vid, 'video') and hasattr(vid.video, 'uri'):
print(f"Video generated at URI: {vid.video.uri}")
else:
print("Video generated, but could not save locally.")
except Exception as e:
print(f"Error editing video: {e}")
sys.exit(1)
if __name__ == "__main__":
main()
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "google-genai",
# "python-dotenv",
# "pillow",
# ]
# ///
import os
from dotenv import load_dotenv
import argparse
import sys
import time
from google import genai
from google.genai import types
load_dotenv()
def get_client():
api_key = os.environ.get("GOOGLE_API_KEY") or os.environ.get("GEMINI_API_KEY")
if api_key:
return genai.Client(api_key=api_key)
project = os.environ.get("GOOGLE_CLOUD_PROJECT")
location = os.environ.get("GOOGLE_CLOUD_LOCATION")
use_vertex = os.environ.get("GOOGLE_GENAI_USE_VERTEXAI", "").lower()
if project and location and use_vertex in ("1", "true"):
return genai.Client(vertexai=True, project=project, location=location)
print("=" * 60)
print("AGENT ERROR: Missing required environment variables!")
print("=" * 60)
print()
print("To use Veo video extension, the user must configure their")
print(".env file with the following environment variables:")
print()
print("Option 1 - Using Gemini API Key:")
print(" GOOGLE_API_KEY=<api-key>")
print()
print("Option 2 - Using Vertex AI (recommended for Veo):")
print(" GOOGLE_CLOUD_PROJECT=<project-id>")
print(" GOOGLE_CLOUD_LOCATION=us-central1")
print(" GOOGLE_GENAI_USE_VERTEXAI=1")
print()
print("IMPORTANT: For Veo APIs, location MUST be 'us-central1'.")
print()
print("Please ask the user to create or update their .env file")
print("with the required credentials before retrying.")
print("=" * 60)
sys.exit(1)
def main():
parser = argparse.ArgumentParser(description="Extend videos using Veo 3 models.")
parser.add_argument("--video", required=True, help="URI or Path to input video")
parser.add_argument("--prompt", required=True, help="Description of the extended content")
parser.add_argument("--duration", type=int, default=6, help="Duration to add in seconds")
parser.add_argument("--model", default="veo-3.1-generate-preview", help="Model to use (default: veo-3.1-generate-preview)")
parser.add_argument("--output", default="extended_video.mp4", help="Output filename")
args = parser.parse_args()
client = get_client()
try:
# Configure Source Video
video_source = None
if args.video.startswith("gs://"):
video_source = types.Video(uri=args.video, mime_type="video/mp4")
elif os.path.exists(args.video):
print("Note: Local video files might need to be uploaded to GCS for best performance.")
video_source = types.Video(uri=args.video, mime_type="video/mp4")
else:
print(f"Error: Video '{args.video}' not found.")
sys.exit(1)
config = types.GenerateVideosConfig(
duration_seconds=args.duration,
generate_audio=True,
)
print(f"Submitting video extension job to {args.model}...")
operation = client.models.generate_videos(
model=args.model,
prompt=args.prompt,
video=video_source,
config=config
)
print(f"Operation name: {operation.name}")
print("Waiting for operation to complete...")
while True:
op_status = client.operations.get(operation)
if op_status.done:
break
time.sleep(10)
print(".", end="", flush=True)
print("")
print("Operation complete.")
if op_status.error:
print(f"Operation failed with error: {op_status.error}")
sys.exit(1)
result = op_status.result
if result and result.generated_videos:
vid = result.generated_videos[0]
try:
if hasattr(vid, 'video'):
vid.video.save(args.output)
print(f"Video saved to {args.output}")
else:
print("Error: GeneratedVideo object has no 'video' attribute.")
except Exception as e:
print(f"Failed to save video using .save(): {e}")
if hasattr(vid, 'video') and hasattr(vid.video, 'uri'):
print(f"Video generated at URI: {vid.video.uri}")
else:
print("Video generated, but could not save locally.")
except Exception as e:
print(f"Error extending video: {e}")
sys.exit(1)
if __name__ == "__main__":
main()
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "google-genai",
# "python-dotenv",
# "pillow",
# ]
# ///
import os
from dotenv import load_dotenv
import argparse
import sys
import time
from google import genai
from google.genai import types
load_dotenv()
def get_client():
api_key = os.environ.get("GOOGLE_API_KEY") or os.environ.get("GEMINI_API_KEY")
if api_key:
return genai.Client(api_key=api_key)
project = os.environ.get("GOOGLE_CLOUD_PROJECT")
location = os.environ.get("GOOGLE_CLOUD_LOCATION")
use_vertex = os.environ.get("GOOGLE_GENAI_USE_VERTEXAI", "").lower()
if project and location and use_vertex in ("1", "true"):
return genai.Client(vertexai=True, project=project, location=location)
print("=" * 60)
print("AGENT ERROR: Missing required environment variables!")
print("=" * 60)
print()
print("To use Veo video generation, the user must configure their")
print(".env file with the following environment variables:")
print()
print("Option 1 - Using Gemini API Key:")
print(" GOOGLE_API_KEY=<api-key>")
print()
print("Option 2 - Using Vertex AI (recommended for Veo):")
print(" GOOGLE_CLOUD_PROJECT=<project-id>")
print(" GOOGLE_CLOUD_LOCATION=us-central1")
print(" GOOGLE_GENAI_USE_VERTEXAI=1")
print()
print("IMPORTANT: For Veo APIs, location MUST be 'us-central1'.")
print()
print("Please ask the user to create or update their .env file")
print("with the required credentials before retrying.")
print("=" * 60)
sys.exit(1)
def main():
parser = argparse.ArgumentParser(description="Generate videos from image using Veo 3.")
parser.add_argument("prompt", help="The text prompt for video generation")
parser.add_argument("--image", required=True, help="Path to input image")
parser.add_argument("--model", default="veo-3.1-generate-001", help="Model to use (default: veo-3.1-generate-001)")
parser.add_argument("--output", default="generated_video.mp4", help="Output filename")
parser.add_argument("--aspect-ratio", default="16:9", help="Aspect ratio (16:9 or 9:16)")
parser.add_argument("--resolution", default="1080p", help="Resolution (720p, 1080p, 4k)")
parser.add_argument("--duration", type=int, default=6, help="Duration in seconds (4, 6, 8)")
args = parser.parse_args()
client = get_client()
try:
if not os.path.exists(args.image):
print(f"Error: Input image '{args.image}' not found.")
sys.exit(1)
config = types.GenerateVideosConfig(
aspect_ratio=args.aspect_ratio,
resolution=args.resolution,
duration_seconds=args.duration,
generate_audio=True,
person_generation="allow_adult",
)
print(f"Submitting Image-to-Video job to {args.model}...")
operation = client.models.generate_videos(
model=args.model,
prompt=args.prompt,
image=types.Image.from_file(location=args.image),
config=config
)
print(f"Operation name: {operation.name}")
print("Waiting for operation to complete...")
while True:
op_status = client.operations.get(operation)
if op_status.done:
break
time.sleep(10)
print(".", end="", flush=True)
print("")
print("Operation complete.")
if op_status.error:
print(f"Operation failed with error: {op_status.error}")
sys.exit(1)
result = op_status.result
if result and result.generated_videos:
vid = result.generated_videos[0]
try:
if hasattr(vid, 'video'):
vid.video.save(args.output)
print(f"Video saved to {args.output}")
else:
print("Error: GeneratedVideo object has no 'video' attribute.")
except Exception as save_err:
print(f"Failed to save video using .save(): {save_err}")
if hasattr(vid, 'video') and hasattr(vid.video, 'uri'):
print(f"Video generated at URI: {vid.video.uri}")
else:
print("Video generated, but could not save locally.")
else:
print("No video generated in result.")
except Exception as e:
import traceback
traceback.print_exc()
print(f"Error generating video: {e}")
sys.exit(1)
if __name__ == "__main__":
main()
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "google-genai",
# "python-dotenv",
# "pillow",
# ]
# ///
import os
from dotenv import load_dotenv
import argparse
import sys
import time
from google import genai
from google.genai import types
load_dotenv()
def get_client():
api_key = os.environ.get("GOOGLE_API_KEY") or os.environ.get("GEMINI_API_KEY")
if api_key:
return genai.Client(api_key=api_key)
project = os.environ.get("GOOGLE_CLOUD_PROJECT")
location = os.environ.get("GOOGLE_CLOUD_LOCATION")
use_vertex = os.environ.get("GOOGLE_GENAI_USE_VERTEXAI", "").lower()
if project and location and use_vertex in ("1", "true"):
return genai.Client(vertexai=True, project=project, location=location)
print("=" * 60)
print("AGENT ERROR: Missing required environment variables!")
print("=" * 60)
print()
print("To use Veo video generation with references, the user must")
print("configure their .env file with the following variables:")
print()
print("Option 1 - Using Gemini API Key:")
print(" GOOGLE_API_KEY=<api-key>")
print()
print("Option 2 - Using Vertex AI (recommended for Veo):")
print(" GOOGLE_CLOUD_PROJECT=<project-id>")
print(" GOOGLE_CLOUD_LOCATION=us-central1")
print(" GOOGLE_GENAI_USE_VERTEXAI=1")
print()
print("IMPORTANT: For Veo APIs, location MUST be 'us-central1'.")
print()
print("Please ask the user to create or update their .env file")
print("with the required credentials before retrying.")
print("=" * 60)
sys.exit(1)
def main():
parser = argparse.ArgumentParser(description="Generate videos with reference assets using Veo 3.")
parser.add_argument("prompt", help="The text prompt for video generation")
parser.add_argument("--reference-image", action='append', required=True, help="Path to reference asset image(s)")
parser.add_argument("--model", default="veo-3.1-generate-001", help="Model to use (default: veo-3.1-generate-001)")
parser.add_argument("--output", default="generated_video.mp4", help="Output filename")
parser.add_argument("--aspect-ratio", default="16:9", help="Aspect ratio (16:9 or 9:16)")
parser.add_argument("--resolution", default="1080p", help="Resolution (720p, 1080p, 4k)")
parser.add_argument("--duration", type=int, default=6, help="Duration in seconds (4, 6, 8)")
args = parser.parse_args()
client = get_client()
try:
ref_images = []
for ref_path in args.reference_image:
if not os.path.exists(ref_path):
print(f"Error: Reference image '{ref_path}' not found.")
sys.exit(1)
ref_images.append(
types.VideoGenerationReferenceImage(
image=types.Image.from_file(location=ref_path),
reference_type="asset"
)
)
config = types.GenerateVideosConfig(
aspect_ratio=args.aspect_ratio,
resolution=args.resolution,
duration_seconds=args.duration,
generate_audio=True,
person_generation="allow_adult",
reference_images=ref_images
)
print(f"Submitting Reference-to-Video job to {args.model}...")
operation = client.models.generate_videos(
model=args.model,
prompt=args.prompt,
config=config
)
print(f"Operation name: {operation.name}")
print("Waiting for operation to complete...")
while True:
op_status = client.operations.get(operation)
if op_status.done:
break
time.sleep(10)
print(".", end="", flush=True)
print("")
print("Operation complete.")
if op_status.error:
print(f"Operation failed with error: {op_status.error}")
sys.exit(1)
result = op_status.result
if result and result.generated_videos:
vid = result.generated_videos[0]
try:
if hasattr(vid, 'video'):
vid.video.save(args.output)
print(f"Video saved to {args.output}")
else:
print("Error: GeneratedVideo object has no 'video' attribute.")
except Exception as e:
print(f"Failed to save video using .save(): {e}")
if hasattr(vid, 'video') and hasattr(vid.video, 'uri'):
print(f"Video generated at URI: {vid.video.uri}")
else:
print("Video generated, but could not save locally.")
except Exception as e:
print(f"Error generating video: {e}")
sys.exit(1)
if __name__ == "__main__":
main()
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "google-genai",
# "python-dotenv",
# "pillow",
# ]
# ///
import os
from dotenv import load_dotenv
import argparse
import sys
import time
from google import genai
from google.genai import types
load_dotenv()
def get_client():
api_key = os.environ.get("GOOGLE_API_KEY") or os.environ.get("GEMINI_API_KEY")
if api_key:
return genai.Client(api_key=api_key)
project = os.environ.get("GOOGLE_CLOUD_PROJECT")
location = os.environ.get("GOOGLE_CLOUD_LOCATION")
use_vertex = os.environ.get("GOOGLE_GENAI_USE_VERTEXAI", "").lower()
if project and location and use_vertex in ("1", "true"):
return genai.Client(vertexai=True, project=project, location=location)
print("=" * 60)
print("AGENT ERROR: Missing required environment variables!")
print("=" * 60)
print()
print("To use Veo video generation, the user must configure their")
print(".env file with the following environment variables:")
print()
print("Option 1 - Using Gemini API Key:")
print(" GOOGLE_API_KEY=<api-key>")
print()
print("Option 2 - Using Vertex AI (recommended for Veo):")
print(" GOOGLE_CLOUD_PROJECT=<project-id>")
print(" GOOGLE_CLOUD_LOCATION=us-central1")
print(" GOOGLE_GENAI_USE_VERTEXAI=1")
print()
print("IMPORTANT: For Veo APIs, location MUST be 'us-central1'.")
print()
print("Please ask the user to create or update their .env file")
print("with the required credentials before retrying.")
print("=" * 60)
sys.exit(1)
def main():
parser = argparse.ArgumentParser(description="Generate videos from text using Veo 3.")
parser.add_argument("prompt", help="The text prompt for video generation")
parser.add_argument("--model", default="veo-3.1-generate-001", help="Model to use (default: veo-3.1-generate-001)")
parser.add_argument("--output", default="generated_video.mp4", help="Output filename")
parser.add_argument("--aspect-ratio", default="16:9", help="Aspect ratio (16:9 or 9:16)")
parser.add_argument("--resolution", default="1080p", help="Resolution (720p, 1080p, 4k)")
parser.add_argument("--duration", type=int, default=6, help="Duration in seconds (4, 6, 8)")
args = parser.parse_args()
client = get_client()
try:
config = types.GenerateVideosConfig(
aspect_ratio=args.aspect_ratio,
resolution=args.resolution,
duration_seconds=args.duration,
generate_audio=True,
person_generation="allow_adult",
)
print(f"Submitting Text-to-Video job to {args.model}...")
operation = client.models.generate_videos(
model=args.model,
prompt=args.prompt,
config=config
)
print(f"Operation name: {operation.name}")
print("Waiting for operation to complete...")
while True:
op_status = client.operations.get(operation)
if op_status.done:
break
time.sleep(10)
print(".", end="", flush=True)
print("")
print("Operation complete.")
if op_status.error:
print(f"Operation failed with error: {op_status.error}")
sys.exit(1)
result = op_status.result
if result and result.generated_videos:
vid = result.generated_videos[0]
try:
if hasattr(vid, 'video'):
vid.video.save(args.output)
print(f"Video saved to {args.output}")
else:
print("Error: GeneratedVideo object has no 'video' attribute.")
except Exception as e:
print(f"Failed to save video using .save(): {e}")
if hasattr(vid, 'video') and hasattr(vid.video, 'uri'):
print(f"Video generated at URI: {vid.video.uri}")
else:
print("Video generated, but could not save locally.")
except Exception as e:
print(f"Error generating video: {e}")
sys.exit(1)
if __name__ == "__main__":
main()