Effects
Effects modify video frames without changing their count or dimensions.
Usage
from videopython.base import Video, Blur, Zoom, ColorGrading, Vignette, KenBurns, BoundingBox
video = Video.from_path("input.mp4")
# Apply blur effect
blur = Blur(mode="constant", iterations=50)
video = blur.apply(video, start=0, stop=2.0)
# Apply zoom effect
zoom = Zoom(zoom_factor=1.5, mode="in")
video = zoom.apply(video)
# Color grading
grading = ColorGrading(brightness=1.1, contrast=1.2, saturation=1.1, temperature=0.1)
video = grading.apply(video)
# Vignette effect
vignette = Vignette(strength=0.5, radius=0.8)
video = vignette.apply(video)
# Ken Burns pan-and-zoom (fluent API)
start_region = BoundingBox(x=0.0, y=0.0, width=0.5, height=0.5) # Top-left quarter
end_region = BoundingBox(x=0.5, y=0.5, width=0.5, height=0.5) # Bottom-right quarter
video = video.ken_burns(start_region, end_region, easing="ease_in_out")
Effect (Base Class)
Effect
Bases: ABC
Abstract class for effect on frames of video.
The effect must not change the number of frames and the shape of the frames.
Source code in src/videopython/base/effects.py
Blur
Blur
Bases: Effect
Applies Gaussian blur with constant, ascending, or descending intensity.
Source code in src/videopython/base/effects.py
__init__
__init__(
mode: Literal["constant", "ascending", "descending"],
iterations: int,
kernel_size: tuple[int, int] = (5, 5),
)
Initialize blur effect.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
Literal['constant', 'ascending', 'descending']
|
Blur mode - "constant" (same blur), "ascending" (increasing blur), or "descending" (decreasing blur). |
required |
iterations
|
int
|
Number of blur iterations to apply. |
required |
kernel_size
|
tuple[int, int]
|
Gaussian kernel size for blur operation. |
(5, 5)
|
Source code in src/videopython/base/effects.py
Zoom
Zoom
Bases: Effect
Applies zoom in or out effect by cropping and scaling frames progressively.
Source code in src/videopython/base/effects.py
__init__
Initialize zoom effect.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
zoom_factor
|
float
|
Maximum zoom level, must be greater than 1. |
required |
mode
|
Literal['in', 'out']
|
Zoom direction - "in" for zoom in effect, "out" for zoom out effect. |
required |
Source code in src/videopython/base/effects.py
FullImageOverlay
FullImageOverlay
Bases: Effect
Overlays an image on top of video frames with optional transparency and fade.
Source code in src/videopython/base/effects.py
__init__
Initialize image overlay effect.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
overlay_image
|
ndarray
|
RGB or RGBA image to overlay, must match video dimensions. |
required |
alpha
|
float | None
|
Overall opacity from 0 (transparent) to 1 (opaque), defaults to 1.0. |
None
|
fade_time
|
float
|
Duration in seconds for fade in/out at start and end. |
0.0
|
Source code in src/videopython/base/effects.py
ColorGrading
ColorGrading
Bases: Effect
Adjusts color properties: brightness, contrast, saturation, and temperature.
Source code in src/videopython/base/effects.py
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 331 | |
__init__
__init__(
brightness: float = 0.0,
contrast: float = 1.0,
saturation: float = 1.0,
temperature: float = 0.0,
)
Initialize color grading effect.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
brightness
|
float
|
Brightness adjustment (-1.0 to 1.0, default 0). |
0.0
|
contrast
|
float
|
Contrast multiplier (0.5 to 2.0, default 1.0). |
1.0
|
saturation
|
float
|
Saturation multiplier (0.0 to 2.0, default 1.0). |
1.0
|
temperature
|
float
|
Color temperature shift (-1.0=cooler/blue to 1.0=warmer/orange, default 0). |
0.0
|
Source code in src/videopython/base/effects.py
Vignette
Vignette
Bases: Effect
Applies a vignette effect (darkening at edges).
Source code in src/videopython/base/effects.py
__init__
Initialize vignette effect.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
strength
|
float
|
How dark the edges become (0.0 to 1.0, default 0.5). |
0.5
|
radius
|
float
|
How far the vignette extends from center (0.5 to 2.0, default 1.0). |
1.0
|
Source code in src/videopython/base/effects.py
KenBurns
KenBurns
Bases: Effect
Cinematic pan-and-zoom effect that animates between two regions.
Named after documentarian Ken Burns who popularized the technique. The effect smoothly transitions from a start region to an end region over the duration of the video, creating dynamic movement from static content.
Source code in src/videopython/base/effects.py
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 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 | |
__init__
__init__(
start_region: "BoundingBox",
end_region: "BoundingBox",
easing: Literal[
"linear", "ease_in", "ease_out", "ease_in_out"
] = "linear",
)
Initialize Ken Burns effect.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_region
|
'BoundingBox'
|
Starting crop region (normalized 0-1 coordinates). |
required |
end_region
|
'BoundingBox'
|
Ending crop region (normalized 0-1 coordinates). |
required |
easing
|
Literal['linear', 'ease_in', 'ease_out', 'ease_in_out']
|
Animation easing function - "linear", "ease_in", "ease_out", or "ease_in_out". |
'linear'
|