Skip to content

fade

Classes:

FadeEffect

FadeEffect(**kwargs: Any)

Bases: BaseEffect

kwargs: Effect-specific keyword arguments

Methods:

Source code in src/movfx/effects/base.py
36
37
38
39
40
41
def __init__(self, **kwargs: Any) -> None:
    """
    title: Initialize the effect with optional keyword arguments
    parameters:
        kwargs: Effect-specific keyword arguments
    """

build_clip

build_clip(
    img_from: ndarray,
    img_to: ndarray,
    duration: float,
    fps: int = 30,
) -> VideoClip
Source code in src/movfx/effects/base.py
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
def build_clip(
    self,
    img_from: np.ndarray,
    img_to: np.ndarray,
    duration: float,
    fps: int = 30,
) -> VideoClip:
    """
    title: Build a moviepy VideoClip from the effect
    parameters:
        img_from: Source image as a NumPy RGB array
        img_to: Destination image as a NumPy RGB array
        duration: Duration of the clip in seconds
        fps: Frames per second
    returns: A moviepy VideoClip with the transition
    """

    def make_frame(t: float) -> np.ndarray:
        progress = t / duration if duration > 0 else 1.0
        progress = max(0.0, min(1.0, progress))
        return self.render_frame(img_from, img_to, progress)

    clip = VideoClip(make_frame, duration=duration)
    clip = clip.with_fps(fps)
    return clip

render_frame

render_frame(
    img_from: ndarray, img_to: ndarray, progress: float
) -> ndarray
Source code in src/movfx/effects/fade.py
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
def render_frame(
    self,
    img_from: np.ndarray,
    img_to: np.ndarray,
    progress: float,
) -> np.ndarray:
    """
    title: Render a fade frame
    parameters:
        img_from: Source image array
        img_to: Destination image array
        progress: Blend factor from 0.0 to 1.0
    returns: Blended frame as uint8 array
    """
    blended = (1.0 - progress) * img_from + progress * img_to
    return blended.astype(np.uint8)