Skip to content

Zoom

BaseZoomEffect

Bases: BaseModel

Base class for zoom effects.

start_zoom instance-attribute

start_zoom: Annotated[float, Field(ge=0.1, le=2)]

Starting zoom scale (1.0 is original size).

end_zoom instance-attribute

end_zoom: Annotated[float, Field(ge=0.1, le=2.0)]

Ending zoom scale.

apply

apply(clip: VideoClip) -> VideoClip

Apply zoom effect to clip.

Parameters:

Name Type Description Default
clip VideoClip

The clip to apply the effect to.

required

Returns:

Type Description
VideoClip

The clip with the effect applied.

Source code in src/mosaico/effects/zoom.py
def apply(self, clip: VideoClip) -> VideoClip:
    """
    Apply zoom effect to clip.

    :param clip: The clip to apply the effect to.
    :return: The clip with the effect applied.
    """

    def zoom(t):
        """Calculate zoom factor at time t."""
        progress = t / clip.duration
        return self.start_zoom + (self.end_zoom - self.start_zoom) * progress

    return clip.fx(resize, zoom)

ZoomInEffect

Bases: BaseZoomEffect

Zoom-in effect for video clips.

type class-attribute instance-attribute

type: Literal['zoom_in'] = 'zoom_in'

Effect type. Must be "zoom_in".

start_zoom class-attribute instance-attribute

start_zoom: Annotated[float, Field(ge=0.1, le=2)] = 1.0

Starting zoom scale (1.0 is original size).

end_zoom class-attribute instance-attribute

end_zoom: Annotated[float, Field(ge=0.1, le=2)] = 1.1

Ending zoom scale.

ZoomOutEffect

Bases: BaseZoomEffect

Zoom-out effect for video clips.

type class-attribute instance-attribute

type: Literal['zoom_out'] = 'zoom_out'

Effect type. Must be "zoom_out".

start_zoom class-attribute instance-attribute

start_zoom: Annotated[float, Field(ge=0.1, le=2)] = 1.5

Starting zoom scale (1.5 times the original size).

end_zoom class-attribute instance-attribute

end_zoom: Annotated[float, Field(ge=0.1, le=2)] = 1.4

Ending zoom scale.