Connect two shots¶
A transition presents two overlapping layers as one change of scene. Its placement belongs to the composition that owns both layers; its reusable definition describes how their opacity, transforms or effects change.
Start with an overlap¶
Save this standalone project as crossfade.py. It produces a three-second
change between two procedural shape layers and needs no input files:
The render calls below use overwrite=True; rerunning a script replaces its
named output files.
from vestra import Crossfade, Project, Rectangle
project = Project(
size=(640, 360),
fps=30,
duration=3,
background="#101c24",
)
outgoing = project.root.add(
Rectangle(width=640, height=360, fill="#193b43"),
start=0,
duration=2,
)
incoming = project.root.add(
Rectangle(width=640, height=360, fill="#34324f"),
start=1,
duration=2,
z=1,
)
project.root.transitions.add(
outgoing,
incoming,
Crossfade(),
start=1,
duration=1,
)
project.render("crossfade.mp4", backend="cpu", overwrite=True)
This writes crossfade.mp4 in the current directory and replaces it on a rerun.
Both endpoint layers exist throughout the transition. The transition API does not extend their durations or move the
incoming layer to create an overlap.
The one-second overlap is a period in the owning composition's local time.
For a transition starting at s with duration d, normalized progress is
p = (local_time - s) / d. At 1.5 seconds in this example, p=0.5.
Easing determines the channel values at that progress. Built-ins default to
Interpolation.EASE_IN_OUT; the comparisons below explicitly use linear easing
so geometry is easier to compare.
Compare four families¶
Each video uses the same two original scene compositions, the same layers and z order, and the same overlap from 1–2 s. The persistent title is outside both endpoints so it does not move or blur with them.
Crossfade: change opacity¶
Crossfade fades outgoing opacity from 1 to 0 and incoming opacity from 0 to
1. These values multiply the layers' own opacity. This is ordinary alpha
compositing in layer order; the midpoint is not necessarily a 50/50 RGB average
of two opaque frames.
Directional push: move both scenes¶
A push changes position offsets rather than opacity. The normalized distance uses composition dimensions: a horizontal distance of 1 spans the width, and a vertical distance of 1 spans the height. Partial distance leaves a different seam and may reveal the root background when the inputs do not cover the frame.
Zoom crossfade: combine scale and opacity¶
ZoomCrossfade(outgoing_zoom=1.3, incoming_start_zoom=0.7) multiplies the
endpoints' authored scales. Keep their anchors deliberate: scaling around a
corner has a different path from scaling around the centre.
Blur crossfade: soften the changing image¶
This uses BlurCrossfade(radius=16), a pixel-radius Gaussian blur with opacity
channels. ZoomBlurTransition uses zoom-directed samples rather than a Gaussian kernel.
Both radius controls use output pixels; equal values need not look equally soft. Use the
transition reference for the full constructor
catalog rather than transferring radius values between blur families.
Choose the owner, then the clock¶
If a nested composition is an endpoint, its parent owns the transition between
that whole scene and its sibling. To transition two children inside the scene,
add the placement to scene.child.transitions using those two child layers.
A child layer and its parent placement are not sibling endpoints.
When a parent places that scene later in the project, transitions inside it remain on its child-local clock. Changing a transition's duration stretches its normalized behavior into the new interval. For more on those clocks, see timeline and time.
Transitions versus property animation¶
Use a transition when the intent is to connect two endpoints with reusable normalized behavior. The transition overlays presentation on both layers during its interval; it does not rewrite their authored tracks. Position and rotation contribute offsets, scale contributes a multiplier, and opacity multiplies the authored opacity. Transition effects join the endpoint's effect processing.
Use ordinary keyframes for one layer's independent
motion on its own clock. You can manually animate two layers to form a cut,
but you then own both sets of seconds, lifetimes and synchronization. A reusable
CustomTransition instead expresses endpoint channels with Animate(...)
progress from 0 to 1; see the reference.
Resolve common validation failures¶
| Failure | What to check |
|---|---|
| Wrong owner or removed endpoint | Add both sibling layers to the composition that owns .transitions. Use two different live layer handles. |
| Interval does not fit | Both endpoints must be visible and alive for the entire transition; make their overlap at least as long as the transition. |
| Conflicting placements | A layer cannot participate in two transitions whose intervals overlap in the same composition. Touching intervals are allowed. |
| Unsupported canonical source | Image, video, shape, text and group clips are direct endpoints. Python adapts procedural Color, Spectrum2D and particle layers; raw canonical procedural clips are not direct endpoints. |
| Invalid custom progress | Normalized keys must be strictly increasing, start at 0 and end at 1. Positive duration and finite values are required. |
transitions.add(...) checks Python ownership and constructor values. Use
project.validate() to detect semantic failures such as interval fit or
conflicting placements before rendering. Validation of file-independent
structure is separate from media preflight.
Complete example¶
transition_comparisons.py
builds both scenes and runs the four definitions. Run
uv run python transition_comparisons.py to replace transition-{crossfade,push,zoom,blur}.mp4
in the current directory. The graphics are original and use the bundled font.
Flashes and image presets¶
A flash is a separate project-wide color overlay; a preset adds a motion treatment to one image layer. Neither needs transition endpoints or changes transition ownership. Use add flashes and photo motion for those tasks, or presets and flashes for their exact constraints.