Skip to content

motion

MotionVectors

MotionVectors()

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

Source code
29
30
31
32
33
def __init__(self) -> None:
    self._init_vects()
    self.analysis_data = dict()
    self.scaled = False
    self.kwargs = dict[str, Any]()

analysis_data instance-attribute

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

Dictionary containing motion vector analysis data.

has_vectors property

has_vectors: bool

Check if motion vectors are available.

kwargs instance-attribute

kwargs = dict[str, Any]()

scaled instance-attribute

scaled: bool = False

Whether motion vectors have been scaled.

temporal_vectors instance-attribute

temporal_vectors: dict[MVDirection, dict[int, VideoNode]]

Dictionary containing both backward and forward motion vectors.

vmulti instance-attribute

vmulti: VideoNode

Super-sampled clip used for motion vector analysis.

clear

clear() -> None

Clear all stored motion vectors and reset the instance.

Source code
69
70
71
72
73
74
75
76
77
def clear(self) -> None:
    """Clear all stored motion vectors and reset the instance."""

    del self.vmulti
    self.analysis_data.clear()
    self.scaled = False
    self.kwargs.clear()
    self.temporal_vectors.clear()
    self._init_vects()

get_mv

get_mv(direction: MVDirection, delta: int) -> VideoNode

Retrieve a specific motion vector.

Parameters:

  • direction

    (MVDirection) –

    Direction of the motion vector (forward or backward).

  • delta

    (int) –

    Frame distance for the motion vector.

Returns:

  • VideoNode

    The requested motion vector clip.

Source code
46
47
48
49
50
51
52
53
54
55
56
def get_mv(self, direction: MVDirection, delta: int) -> vs.VideoNode:
    """
    Retrieve a specific motion vector.

    :param direction:    Direction of the motion vector (forward or backward).
    :param delta:        Frame distance for the motion vector.

    :return:             The requested motion vector clip.
    """

    return self.temporal_vectors[direction][delta]

set_mv

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

Store a motion vector.

Parameters:

  • direction

    (MVDirection) –

    Direction of the motion vector (forward or backward).

  • delta

    (int) –

    Frame distance for the motion vector.

  • vect

    Motion vector clip to store.

Source code
58
59
60
61
62
63
64
65
66
67
def set_mv(self, direction: MVDirection, delta: int, vector: vs.VideoNode) -> None:
    """
    Store a motion vector.

    :param direction:    Direction of the motion vector (forward or backward).
    :param delta:        Frame distance for the motion vector.
    :param vect:         Motion vector clip to store.
    """

    self.temporal_vectors[direction][delta] = vector