Skip to content

motion

Classes:

  • MotionVectors

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

MotionVectors

MotionVectors()

Bases: defaultdict[MVDirection, dict[int, ConstantFormatVideoNode]], vs_object

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

Contains both backward and forward motion vectors.

Methods:

  • clear

    Clear all stored motion vectors.

  • set_vector

    Store a motion vector.

Attributes:

Source code in vsdenoise/mvtools/motion.py
37
38
39
40
41
def __init__(self) -> None:
    super().__init__(None, {w: {} for w in MVDirection})
    self.tr = 0
    self.analysis_data = {}
    self.scaled = False

analysis_data instance-attribute

analysis_data: dict[str, Any] = {}

Dictionary containing motion vector analysis data.

has_vectors property

has_vectors: bool

Check if motion vectors are available.

motion_vectors property writable

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.

Source code in vsdenoise/mvtools/motion.py
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
def clear(self) -> None:
    """
    Clear all stored motion vectors.
    """

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

    super().clear()

    with suppress(AttributeError):
        del self.mv_multi

    self.tr = 0
    self.analysis_data.clear()
    self.scaled = False

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 in vsdenoise/mvtools/motion.py
83
84
85
86
87
88
89
90
91
92
93
94
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[direction][delta] = vector