Transitions
Transitions combine two videos with visual effects at the boundary.
Usage
from videopython.base import Video, FadeTransition, BlurTransition
video1 = Video.from_path("clip1.mp4")
video2 = Video.from_path("clip2.mp4")
# Fluent API (recommended)
combined = video1.transition_to(video2, FadeTransition(effect_time_seconds=1.5))
# With blur transition
combined = video1.transition_to(video2, BlurTransition(effect_time_seconds=1.0))
# Direct apply (alternative)
fade = FadeTransition(effect_time_seconds=1.5)
combined = fade.apply((video1, video2))
Requirements
Both videos must have the same dimensions and frame rate to be combined. Use .resize() and .resample_fps() first if needed.
Transition (Base Class)
Transition
Bases: ABC
Abstract class for Transitions on Videos.
To build a new transition, you need to implement the _apply
abstractmethod.
Source code in src/videopython/base/transitions.py
FadeTransition
FadeTransition
Bases: Transition
Cross-dissolve between two videos by blending overlapping frames.
Each video must be at least as long as the overlap duration.
Source code in src/videopython/base/transitions.py
__init__
Initialize fade transition.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
effect_time_seconds
|
float
|
Seconds of overlap where the first video fades out while the second fades in. |
required |
Source code in src/videopython/base/transitions.py
BlurTransition
BlurTransition
Bases: Transition
Transitions between two videos by blurring the first out and the second in.
Source code in src/videopython/base/transitions.py
__init__
__init__(
effect_time_seconds: float = 1.5,
blur_iterations: int = 400,
blur_kernel_size: tuple[int, int] = (11, 11),
)
Initialize blur transition.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
effect_time_seconds
|
float
|
Duration of the blur transition in seconds. |
1.5
|
blur_iterations
|
int
|
Blur strength at the peak of the transition. Higher values make the mid-point more heavily blurred. |
400
|
blur_kernel_size
|
tuple[int, int]
|
Gaussian kernel [width, height] in pixels. Must be odd numbers. Larger values spread the blur wider. |
(11, 11)
|
Source code in src/videopython/base/transitions.py
InstantTransition
InstantTransition
Bases: Transition
Hard cut between two videos with no transition effect.