Video Generation API¶
The video generation module provides functions for creating videos from various inputs using Google's Veo models.
Functions¶
generate_from_text¶
veotools.generate.video.generate_from_text
¶
generate_from_text(prompt: str, model: str = 'veo-3.0-fast-generate-preview', duration_seconds: Optional[int] = None, on_progress: Optional[Callable] = None, **kwargs) -> VideoResult
Generate a video from a text prompt using Google's Veo models.
Creates a video from a text description using the specified Veo model. The function handles the entire generation pipeline including job submission, progress tracking, video download, and metadata extraction.
PARAMETER | DESCRIPTION |
---|---|
prompt
|
Text description of the video to generate.
TYPE:
|
model
|
Veo model to use for generation. Defaults to "veo-3.0-fast-generate-preview".
TYPE:
|
duration_seconds
|
Desired video duration in seconds. If None, uses model default.
TYPE:
|
on_progress
|
Optional callback function called with progress updates (message, percent).
TYPE:
|
**kwargs
|
Additional generation parameters including: - person_generation: Person generation policy ("allow_all", "allow_adult", "dont_allow") - enhance: Whether to enhance the prompt - fps: Target frames per second - audio: Whether to generate audio
DEFAULT:
|
RETURNS | DESCRIPTION |
---|---|
VideoResult
|
Object containing the generated video path, metadata, and operation details.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
ValueError
|
If person_generation parameter is invalid for the model/mode combination. |
RuntimeError
|
If video generation fails or no video is returned. |
FileNotFoundError
|
If required files are not accessible. |
Examples:
Generate a simple video:
>>> result = generate_from_text("A cat playing in a garden")
>>> print(f"Video saved to: {result.path}")
Generate with custom duration and progress tracking:
>>> def progress_handler(message, percent):
... print(f"{message}: {percent}%")
>>> result = generate_from_text(
... "A sunset over the ocean",
... duration_seconds=10,
... on_progress=progress_handler
... )
Source code in src/veotools/generate/video.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
|
generate_from_image¶
veotools.generate.video.generate_from_image
¶
generate_from_image(image_path: Path, prompt: str, model: str = 'veo-3.0-fast-generate-preview', on_progress: Optional[Callable] = None, **kwargs) -> VideoResult
Generate a video from an image and text prompt using Google's Veo models.
Creates a video animation starting from a static image, guided by a text prompt. The function loads the image, submits the generation job, tracks progress, and downloads the resulting video with metadata extraction.
PARAMETER | DESCRIPTION |
---|---|
image_path
|
Path to the input image file (jpg, png, etc.).
TYPE:
|
prompt
|
Text description of how the image should be animated.
TYPE:
|
model
|
Veo model to use for generation. Defaults to "veo-3.0-fast-generate-preview".
TYPE:
|
on_progress
|
Optional callback function called with progress updates (message, percent).
TYPE:
|
**kwargs
|
Additional generation parameters including: - person_generation: Person generation policy ("allow_adult", "dont_allow") - duration_seconds: Video duration in seconds - enhance: Whether to enhance the prompt - fps: Target frames per second
DEFAULT:
|
RETURNS | DESCRIPTION |
---|---|
VideoResult
|
Object containing the generated video path, metadata, and operation details.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
ValueError
|
If person_generation parameter is invalid for image mode. |
RuntimeError
|
If video generation fails or the API returns an error. |
FileNotFoundError
|
If the input image file is not found. |
Examples:
Animate a static image:
>>> from pathlib import Path
>>> result = generate_from_image(
... Path("photo.jpg"),
... "The person starts walking forward"
... )
>>> print(f"Animation saved to: {result.path}")
Generate with progress tracking:
>>> def show_progress(msg, pct):
... print(f"{msg}: {pct}%")
>>> result = generate_from_image(
... Path("landscape.png"),
... "Clouds moving across the sky",
... on_progress=show_progress
... )
Source code in src/veotools/generate/video.py
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 |
|
generate_from_video¶
veotools.generate.video.generate_from_video
¶
generate_from_video(video_path: Path, prompt: str, extract_at: float = -1.0, model: str = 'veo-3.0-fast-generate-preview', on_progress: Optional[Callable] = None, **kwargs) -> VideoResult
Generate a video continuation from an existing video using Google's Veo models.
Creates a new video that continues from a frame extracted from an existing video. The function extracts a frame at the specified time offset, then uses it as the starting point for generating a continuation guided by the text prompt.
PARAMETER | DESCRIPTION |
---|---|
video_path
|
Path to the input video file.
TYPE:
|
prompt
|
Text description of how the video should continue.
TYPE:
|
extract_at
|
Time offset in seconds for frame extraction. Negative values count from the end (e.g., -1.0 extracts 1 second before the end). Defaults to -1.0.
TYPE:
|
model
|
Veo model to use for generation. Defaults to "veo-3.0-fast-generate-preview".
TYPE:
|
on_progress
|
Optional callback function called with progress updates (message, percent).
TYPE:
|
**kwargs
|
Additional generation parameters including: - person_generation: Person generation policy ("allow_adult", "dont_allow") - duration_seconds: Video duration in seconds - enhance: Whether to enhance the prompt - fps: Target frames per second
DEFAULT:
|
RETURNS | DESCRIPTION |
---|---|
VideoResult
|
Object containing the generated video path, metadata, and operation details.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
ValueError
|
If person_generation parameter is invalid for video continuation mode. |
RuntimeError
|
If frame extraction fails or video generation fails. |
FileNotFoundError
|
If the input video file is not found. |
Examples:
Continue a video from the end:
>>> result = generate_from_video(
... Path("scene1.mp4"),
... "The character turns around and walks away"
... )
Continue from a specific timestamp:
>>> result = generate_from_video(
... Path("action.mp4"),
... "The explosion gets bigger",
... extract_at=5.5 # Extract at 5.5 seconds
... )
Continue with progress tracking:
>>> def track_progress(msg, pct):
... print(f"Progress: {msg} ({pct}%)")
>>> result = generate_from_video(
... Path("dance.mp4"),
... "The dancer spins faster",
... extract_at=-2.0,
... on_progress=track_progress
... )
Source code in src/veotools/generate/video.py
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 |
|
Examples¶
Text to Video¶
import veotools as veo
veo.init()
# Basic generation
result = veo.generate_from_text(
prompt="A cat playing piano",
model="veo-3.0-fast-generate-preview"
)
# With progress tracking
def on_progress(message: str, percent: int):
print(f"{message}: {percent}%")
result = veo.generate_from_text(
prompt="Sunset over mountains",
model="veo-3.0-fast-generate-preview",
on_progress=on_progress
)
Image to Video¶
# Generate video from an image
result = veo.generate_from_image(
image_path="landscape.jpg",
prompt="The landscape comes to life with moving clouds",
model="veo-3.0-fast-generate-preview"
)
Video Continuation¶
# Continue from existing video
result = veo.generate_from_video(
video_path="intro.mp4",
prompt="The scene transitions to a forest",
extract_at=-1.0, # Use last frame
model="veo-3.0-fast-generate-preview"
)
Model Support¶
Different Veo models support different features:
Model | Duration Control | Aspect Ratio | Audio | Generation Time |
---|---|---|---|---|
veo-3.0-fast-generate-preview | ❌ | ✅ (16:9) | ✅ | ~1 min |
veo-3.0-generate-preview | ❌ | ✅ (16:9) | ✅ | ~2 min |
veo-2.0-generate-001 | ✅ | ✅ (16:9, 9:16) | ❌ | ~3 min |
Safety Settings¶
You can pass safety settings to control content generation: