Skip to content

motion

Classes:

  • MotionVectors

    Class for storing and managing motion vectors for a video clip.

MotionVectors

MotionVectors()

Bases: vs_object

Class for storing and managing motion vectors for a video clip.

Methods:

  • clear

    Clear all stored motion vectors and reset the instance.

  • set_vector

    Store a motion vector.

Attributes:

Source code
34
35
36
37
38
def __init__(self) -> None:
    self._init_vects()
    self.tr = 0
    self.analysis_data = dict[str, Any]()
    self.scaled = False

analysis_data instance-attribute

analysis_data: dict[str, Any] = dict[str, Any]()

Dictionary containing motion vector analysis data.

has_vectors property

has_vectors: bool

Check if motion vectors are available.

motion_vectors instance-attribute

motion_vectors: dict[MVDirection, dict[int, ConstantFormatVideoNode]]

Dictionary containing both backward and forward motion vectors.

mv_multi instance-attribute

mv_multi: ConstantFormatVideoNode

Multi-vector clip.

scaled instance-attribute

scaled: bool = False

Whether motion vectors have been scaled.

tr instance-attribute

tr: int = 0

Temporal radius of the motion vectors.

clear

clear() -> None

Clear all stored motion vectors and reset the instance.

Source code
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
def clear(self) -> None:
    """
    Clear all stored motion vectors and reset the instance.
    """

    for v in self.motion_vectors.values():
        v.clear()

    self.motion_vectors.clear()
    if hasattr(self, "mv_multi"):
        del self.mv_multi
    self.tr = 0
    self.analysis_data.clear()
    self.scaled = False
    self._init_vects()

set_vector

set_vector(vector: VideoNode, direction: MVDirection, delta: int) -> None

Store a motion vector.

Parameters:

  • vector

    (VideoNode) –

    Motion vector clip to store.

  • direction

    (MVDirection) –

    Direction of the motion vector (forward or backward).

  • delta

    (int) –

    Frame distance for the motion vector.

Source code
70
71
72
73
74
75
76
77
78
79
80
81
def set_vector(self, vector: vs.VideoNode, direction: MVDirection, delta: int) -> None:
    """
    Store a motion vector.

    Args:
        vector: Motion vector clip to store.
        direction: Direction of the motion vector (forward or backward).
        delta: Frame distance for the motion vector.
    """
    assert check_variable_format(vector, self.set_vector)

    self.motion_vectors[direction][delta] = vector