Skip to content

mvtools

Classes:

  • MVTools

    MVTools wrapper for motion analysis, degraining, compensation, interpolation, etc.

MVTools

MVTools(
    clip: VideoNode,
    search_clip: VideoNode | VSFunctionNoArgs | None = None,
    vectors: MotionVectors | None = None,
    pad: int | tuple[int | None, int | None] | None = None,
    pel: int | None = None,
    chroma: bool | None = None,
    field: FieldLike | None = None,
    *,
    super_args: Mapping[str, Any] | None = None,
    analyze_args: Mapping[str, Any] | None = None,
    recalculate_args: Mapping[str, Any] | None = None,
    compensate_args: Mapping[str, Any] | None = None,
    flow_args: Mapping[str, Any] | None = None,
    degrain_args: Mapping[str, Any] | None = None,
    flow_interpolate_args: Mapping[str, Any] | None = None,
    flow_fps_args: Mapping[str, Any] | None = None,
    block_fps_args: Mapping[str, Any] | None = None,
    flow_blur_args: Mapping[str, Any] | None = None,
    mask_args: Mapping[str, Any] | None = None,
    sc_detection_args: Mapping[str, Any] | None = None,
)

Bases: VSObject

MVTools wrapper for motion analysis, degraining, compensation, interpolation, etc.

MVTools is a collection of functions for motion estimation and compensation in video.

Motion compensation may be used for strong temporal denoising, advanced framerate conversions, image restoration, and other similar tasks.

The plugin uses a block-matching method of motion estimation (similar methods as used in MPEG2, MPEG4, etc.). During the analysis stage the plugin divides frames into smaller blocks and tries to find the most similar matching block for every block in current frame in the second frame (which is either the previous or next frame). The relative shift of these blocks is the motion vector.

The main method of measuring block similarity is by calculating the sum of absolute differences (SAD) of all pixels of these two blocks, which indicates how correct the motion estimation was.

More information

Parameters:

Methods:

  • analyze

    Analyze motion vectors in a clip using block matching.

  • block_fps

    Changes the framerate of the clip by interpolating frames between existing frames

  • compensate

    Perform motion compensation by moving blocks from reference frames to the current frame

  • degrain

    Perform temporal denoising using motion compensation.

  • flow

    Performs motion compensation using pixel-level motion vectors interpolated from block vectors.

  • flow_blur

    Creates a motion blur effect by simulating finite shutter time, similar to film cameras.

  • flow_fps

    Changes the framerate of the clip by interpolating frames between existing frames.

  • flow_interpolate

    Motion interpolation function that creates an intermediate frame between two frames.

  • mask

    Creates a mask clip from motion vectors data.

  • recalculate

    Refines and recalculates motion vectors that were previously estimated,

  • sc_detection

    Creates scene change frameprops from motion vectors data.

  • super

    Get source clip and prepare special "super" clip with multilevel (hierarchical scaled) frames data.

Attributes:

Source code in vsdenoise/mvtools/mvtools.py
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
def __init__(
    self,
    clip: vs.VideoNode,
    search_clip: vs.VideoNode | VSFunctionNoArgs | None = None,
    vectors: MotionVectors | None = None,
    pad: int | tuple[int | None, int | None] | None = None,
    pel: int | None = None,
    chroma: bool | None = None,
    field: FieldLike | None = None,
    *,
    super_args: Mapping[str, Any] | None = None,
    analyze_args: Mapping[str, Any] | None = None,
    recalculate_args: Mapping[str, Any] | None = None,
    compensate_args: Mapping[str, Any] | None = None,
    flow_args: Mapping[str, Any] | None = None,
    degrain_args: Mapping[str, Any] | None = None,
    flow_interpolate_args: Mapping[str, Any] | None = None,
    flow_fps_args: Mapping[str, Any] | None = None,
    block_fps_args: Mapping[str, Any] | None = None,
    flow_blur_args: Mapping[str, Any] | None = None,
    mask_args: Mapping[str, Any] | None = None,
    sc_detection_args: Mapping[str, Any] | None = None,
) -> None:
    """
    MVTools is a collection of functions for motion estimation and compensation in video.

    Motion compensation may be used for strong temporal denoising, advanced framerate conversions,
    image restoration, and other similar tasks.

    The plugin uses a block-matching method of motion estimation (similar methods as used in MPEG2, MPEG4, etc.).
    During the analysis stage the plugin divides frames into smaller blocks and tries to find the most similar
    matching block for every block in current frame in the second frame (which is either the previous
    or next frame).
    The relative shift of these blocks is the motion vector.

    The main method of measuring block similarity is by calculating the sum of absolute differences (SAD)
    of all pixels of these two blocks, which indicates how correct the motion estimation was.

    More information:
        - [VapourSynth plugin](https://github.com/dubhater/vapoursynth-mvtools)
        - [AviSynth docs](https://htmlpreview.github.io/?https://github.com/pinterf/mvtools/blob/mvtools-pfmod/Documentation/mvtools2.html)

    Args:
        clip: The clip to process.
        search_clip: Optional clip or callable to be used for motion vector gathering only.
        vectors: Motion vectors to use. If None, uses the vectors from this instance.
        pad: How much padding to add to the source frame. Small padding is added to help with motion estimation near
            frame borders.
        pel: Subpixel precision for motion estimation (1=pixel, 2=half-pixel, 4=quarter-pixel). Default: 1.
        chroma: Whether to consider chroma in motion vector calculations.
        field: Set field order for interlaced processing, input is expected to be separated fields.
        super_args: Arguments passed to every [MVTools.super][vsdenoise.MVTools.super] call.
        analyze_args: Arguments passed to every [MVTools.analyze][vsdenoise.MVTools.analyze] call.
        recalculate_args: Arguments passed to every [MVTools.recalculate][vsdenoise.MVTools.recalculate] call.
        compensate_args: Arguments passed to every [MVTools.compensate][vsdenoise.MVTools.compensate] call.
        flow_args: Arguments passed to every [MVTools.flow][vsdenoise.MVTools.flow] call.
        degrain_args: Arguments passed to every [MVTools.degrain][vsdenoise.MVTools.degrain] call.
        flow_interpolate_args: Arguments passed to every
            [MVTools.flow_interpolate][vsdenoise.MVTools.flow_interpolate] call.
        flow_fps_args: Arguments passed to every [MVTools.flow_fps][vsdenoise.MVTools.flow_fps] call.
        block_fps_args: Arguments passed to every [MVTools.block_fps][vsdenoise.MVTools.block_fps] call.
        flow_blur_args: Arguments passed to every [MVTools.flow_blur][vsdenoise.MVTools.flow_blur] call.
        mask_args: Arguments passed to every [MVTools.mask][vsdenoise.MVTools.mask] call.
        sc_detection_args: Arguments passed to every [MVTools.sc_detection][vsdenoise.MVTools.sc_detection] call.
    """
    UnsupportedColorFamilyError.check(clip, (vs.YUV, vs.GRAY), self.__class__)

    self.clip = clip
    self.pel = pel
    self.pad = normalize_seq(pad, 2)
    self.chroma = chroma
    self.fields = field is not None
    self.tff = Field.from_param_with_fallback(field)

    self.vectors = fallback(vectors, MotionVectors())

    if callable(search_clip):
        self.search_clip = search_clip(self.clip)
    else:
        self.search_clip = fallback(search_clip, self.clip)

    self.super_args = dict(super_args) if super_args else {}
    self.analyze_args = dict(analyze_args) if analyze_args else {}
    self.recalculate_args = dict(recalculate_args) if recalculate_args else {}
    self.compensate_args = dict(compensate_args) if compensate_args else {}
    self.degrain_args = dict(degrain_args) if degrain_args else {}
    self.flow_args = dict(flow_args) if flow_args else {}
    self.flow_interpolate_args = dict(flow_interpolate_args) if flow_interpolate_args else {}
    self.flow_fps_args = dict(flow_fps_args) if flow_fps_args else {}
    self.block_fps_args = dict(block_fps_args) if block_fps_args else {}
    self.flow_blur_args = dict(flow_blur_args) if flow_blur_args else {}
    self.mask_args = dict(mask_args) if mask_args else {}
    self.sc_detection_args = dict(sc_detection_args) if sc_detection_args else {}

analyze_args instance-attribute

analyze_args: dict[str, Any] = dict(analyze_args) if analyze_args else {}

Arguments passed to every MVTools.analyze call.

block_fps_args instance-attribute

block_fps_args: dict[str, Any] = dict(block_fps_args) if block_fps_args else {}

Arguments passed to every MVTools.block_fps call.

chroma instance-attribute

chroma = chroma

clip instance-attribute

clip: VideoNode = clip

Clip to process.

compensate_args instance-attribute

compensate_args: dict[str, Any] = (
    dict(compensate_args) if compensate_args else {}
)

Arguments passed to every MVTools.compensate call.

degrain_args instance-attribute

degrain_args: dict[str, Any] = dict(degrain_args) if degrain_args else {}

Arguments passed to every MVTools.degrain call.

fields instance-attribute

fields = field is not None

flow_args instance-attribute

flow_args: dict[str, Any] = dict(flow_args) if flow_args else {}

Arguments passed to every MVTools.flow call.

flow_blur_args instance-attribute

flow_blur_args: dict[str, Any] = dict(flow_blur_args) if flow_blur_args else {}

Arguments passed to every MVTools.flow_blur call.

flow_fps_args instance-attribute

flow_fps_args: dict[str, Any] = dict(flow_fps_args) if flow_fps_args else {}

Arguments passed to every MVTools.flow_fps call.

flow_interpolate_args instance-attribute

flow_interpolate_args: dict[str, Any] = (
    dict(flow_interpolate_args) if flow_interpolate_args else {}
)

Arguments passed to every MVTools.flow_interpolate call.

mask_args instance-attribute

mask_args: dict[str, Any] = dict(mask_args) if mask_args else {}

Arguments passed to every MVTools.mask call.

pad instance-attribute

pad = normalize_seq(pad, 2)

pel instance-attribute

pel = pel

recalculate_args instance-attribute

recalculate_args: dict[str, Any] = (
    dict(recalculate_args) if recalculate_args else {}
)

Arguments passed to every MVTools.recalculate call.

sc_detection_args instance-attribute

sc_detection_args: dict[str, Any] = (
    dict(sc_detection_args) if sc_detection_args else {}
)

Arguments passed to every MVTools.sc_detection call.

search_clip instance-attribute

search_clip = search_clip(clip)

super_args instance-attribute

super_args: dict[str, Any] = dict(super_args) if super_args else {}

Arguments passed to every MVTools.super call.

tff instance-attribute

vectors instance-attribute

Motion vectors analyzed and used for all operations.

analyze

analyze(
    super: VideoNode | None = None,
    tr: int = 1,
    blksize: int | tuple[int | None, int | None] | None = None,
    levels: int | None = None,
    search: SearchMode | None = None,
    searchparam: int | None = None,
    pelsearch: int | None = None,
    lambda_: int | None = None,
    truemotion: MotionMode | None = None,
    lsad: int | None = None,
    plevel: PenaltyMode | None = None,
    global_: bool | None = None,
    pnew: int | None = None,
    pzero: int | None = None,
    pglobal: int | None = None,
    overlap: int | tuple[int | None, int | None] | None = None,
    divide: bool | None = None,
    badsad: int | None = None,
    badrange: int | None = None,
    meander: bool | None = None,
    trymany: bool | None = None,
    dct: SADMode | None = None,
    scale_lambda: bool = True,
) -> None

Analyze motion vectors in a clip using block matching.

Takes a prepared super clip (containing hierarchical frame data) and estimates motion by comparing blocks between frames. Outputs motion vector data that can be used by other functions for motion compensation.

The motion vector search is performed hierarchically, starting from a coarse image scale and progressively refining to finer scales. For each block, the function first checks predictors like the zero vector and neighboring block vectors.

This method calculates the Sum of Absolute Differences (SAD) for these predictors, then iteratively tests new candidate vectors by adjusting the current best vector. The vector with the lowest SAD value is chosen as the final motion vector, with a penalty applied to maintain motion coherence between blocks.

Parameters:

  • super

    (VideoNode | None, default: None ) –

    The multilevel super clip prepared by super. If None, super will be obtained from clip.

  • tr

    (int, default: 1 ) –

    The temporal radius. This determines how many frames are analyzed before/after the current frame. Default: 1.

  • blksize

    (int | tuple[int | None, int | None] | None, default: None ) –

    Size of a block. Larger blocks are less sensitive to noise, are faster, but also less accurate.

  • levels

    (int | None, default: None ) –

    Number of levels used in hierarchical motion vector analysis. A positive value specifies how many levels to use. A negative or zero value specifies how many coarse levels to skip. Lower values generally give better results since vectors of any length can be found. Sometimes adding more levels can help prevent false vectors in CGI or similar content.

  • search

    (SearchMode | None, default: None ) –

    Search algorithm to use at the finest level. See SearchMode for options.

  • searchparam

    (int | None, default: None ) –

    Additional parameter for the search algorithm. For NSTEP, this is the step size. For EXHAUSTIVE, EXHAUSTIVE_H, EXHAUSTIVE_V, HEXAGON and UMH, this is the search radius.

  • lambda_

    (int | None, default: None ) –

    Controls the coherence of the motion vector field. Higher values enforce more coherent/smooth motion between blocks. Too high values may cause the algorithm to miss the optimal vectors.

  • truemotion

    (MotionMode | None, default: None ) –

    Preset that controls the default values of motion estimation parameters to optimize for true motion. For more information, see MotionMode.

  • lsad

    (int | None, default: None ) –

    SAD limit for lambda. When the SAD value of a vector predictor (formed from neighboring blocks) exceeds this limit, the local lambda value is decreased. This helps prevent the use of bad predictors, but reduces motion coherence between blocks.

  • plevel

    (PenaltyMode | None, default: None ) –

    Controls how the penalty factor (lambda) scales with hierarchical levels. For more information, see PenaltyMode.

  • global_

    (bool | None, default: None ) –

    Whether to estimate global motion at each level and use it as an additional predictor. This can help with camera motion.

  • pnew

    (int | None, default: None ) –

    Penalty multiplier (relative to 256) applied to the SAD cost when evaluating new candidate vectors. Higher values make the search more conservative.

  • pzero

    (int | None, default: None ) –

    Penalty multiplier (relative to 256) applied to the SAD cost for the zero motion vector. Higher values discourage using zero motion.

  • pglobal

    (int | None, default: None ) –

    Penalty multiplier (relative to 256) applied to the SAD cost when using the global motion predictor.

  • overlap

    (int | tuple[int | None, int | None] | None, default: None ) –

    Block overlap value. Can be a single integer for both dimensions or a tuple of (horizontal, vertical) overlap values. Each value must be even and less than its corresponding block size dimension.

  • divide

    (bool | None, default: None ) –

    Whether to divide each block into 4 subblocks during post-processing. This may improve accuracy at the cost of performance.

  • badsad

    (int | None, default: None ) –

    SAD threshold above which a wider secondary search will be performed to find better motion vectors. Higher values mean fewer blocks will trigger the secondary search.

  • badrange

    (int | None, default: None ) –

    Search radius for the secondary search when a block's SAD exceeds badsad.

  • meander

    (bool | None, default: None ) –

    Whether to use a meandering scan pattern when processing blocks. If True, alternates between left- to-right and right-to-left scanning between rows to improve motion coherence.

  • trymany

    (bool | None, default: None ) –

    Whether to test multiple predictor vectors during the search process at coarser levels. Enabling this can find better vectors but increases processing time.

  • dct

    (SADMode | None, default: None ) –

    SAD calculation mode using block DCT (frequency spectrum) for comparing blocks. For more information, see SADMode.

  • scale_lambda

    (bool, default: True ) –

    Whether to scale lambda_ value according to truemotion's default value formula.

Returns:

  • None

    A MotionVectors object containing the analyzed motion vectors for each frame.

  • None

    These vectors describe the estimated motion between frames and can be used for motion compensation.

Source code in vsdenoise/mvtools/mvtools.py
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
def analyze(
    self,
    super: vs.VideoNode | None = None,
    tr: int = 1,
    blksize: int | tuple[int | None, int | None] | None = None,
    levels: int | None = None,
    search: SearchMode | None = None,
    searchparam: int | None = None,
    pelsearch: int | None = None,
    lambda_: int | None = None,
    truemotion: MotionMode | None = None,
    lsad: int | None = None,
    plevel: PenaltyMode | None = None,
    global_: bool | None = None,
    pnew: int | None = None,
    pzero: int | None = None,
    pglobal: int | None = None,
    overlap: int | tuple[int | None, int | None] | None = None,
    divide: bool | None = None,
    badsad: int | None = None,
    badrange: int | None = None,
    meander: bool | None = None,
    trymany: bool | None = None,
    dct: SADMode | None = None,
    scale_lambda: bool = True,
) -> None:
    """
    Analyze motion vectors in a clip using block matching.

    Takes a prepared super clip (containing hierarchical frame data) and estimates motion by comparing blocks
    between frames.
    Outputs motion vector data that can be used by other functions for motion compensation.

    The motion vector search is performed hierarchically, starting from a coarse image scale and progressively
    refining to finer scales.
    For each block, the function first checks predictors like the zero vector and neighboring block vectors.

    This method calculates the Sum of Absolute Differences (SAD) for these predictors,
    then iteratively tests new candidate vectors by adjusting the current best vector.
    The vector with the lowest SAD value is chosen as the final motion vector,
    with a penalty applied to maintain motion coherence between blocks.

    Args:
        super: The multilevel super clip prepared by [super][vsdenoise.MVTools.super].
            If None, super will be obtained from clip.
        tr: The temporal radius. This determines how many frames are analyzed before/after the current frame.
            Default: 1.
        blksize: Size of a block. Larger blocks are less sensitive to noise, are faster, but also less accurate.
        levels: Number of levels used in hierarchical motion vector analysis. A positive value specifies how many
            levels to use. A negative or zero value specifies how many coarse levels to skip. Lower values generally
            give better results since vectors of any length can be found. Sometimes adding more levels can help
            prevent false vectors in CGI or similar content.
        search: Search algorithm to use at the finest level. See [SearchMode][vsdenoise.SearchMode] for options.
        searchparam: Additional parameter for the search algorithm. For NSTEP, this is the step size. For
            EXHAUSTIVE, EXHAUSTIVE_H, EXHAUSTIVE_V, HEXAGON and UMH, this is the search radius.
        lambda_: Controls the coherence of the motion vector field. Higher values enforce more coherent/smooth
            motion between blocks. Too high values may cause the algorithm to miss the optimal vectors.
        truemotion: Preset that controls the default values of motion estimation parameters to optimize for true
            motion. For more information, see [MotionMode][vsdenoise.MotionMode].
        lsad: SAD limit for lambda. When the SAD value of a vector predictor (formed from neighboring blocks)
            exceeds this limit, the local lambda value is decreased. This helps prevent the use of bad predictors,
            but reduces motion coherence between blocks.
        plevel: Controls how the penalty factor (lambda) scales with hierarchical levels. For more information, see
            [PenaltyMode][vsdenoise.PenaltyMode].
        global_: Whether to estimate global motion at each level and use it as an additional predictor. This can
            help with camera motion.
        pnew: Penalty multiplier (relative to 256) applied to the SAD cost when evaluating new candidate vectors.
            Higher values make the search more conservative.
        pzero: Penalty multiplier (relative to 256) applied to the SAD cost for the zero motion vector. Higher
            values discourage using zero motion.
        pglobal: Penalty multiplier (relative to 256) applied to the SAD cost when using the global motion
            predictor.
        overlap: Block overlap value. Can be a single integer for both dimensions or a tuple of (horizontal,
            vertical) overlap values. Each value must be even and less than its corresponding block size dimension.
        divide: Whether to divide each block into 4 subblocks during post-processing. This may improve accuracy at
            the cost of performance.
        badsad: SAD threshold above which a wider secondary search will be performed to find better motion vectors.
            Higher values mean fewer blocks will trigger the secondary search.
        badrange: Search radius for the secondary search when a block's SAD exceeds badsad.
        meander: Whether to use a meandering scan pattern when processing blocks. If True, alternates between left-
            to-right and right-to-left scanning between rows to improve motion coherence.
        trymany: Whether to test multiple predictor vectors during the search process at coarser levels. Enabling
            this can find better vectors but increases processing time.
        dct: SAD calculation mode using block DCT (frequency spectrum) for comparing blocks. For more information,
            see [SADMode][vsdenoise.SADMode].
        scale_lambda: Whether to scale lambda_ value according to truemotion's default value formula.

    Returns:
        A [MotionVectors][vsdenoise.MotionVectors] object containing the analyzed motion vectors for each frame.
        These vectors describe the estimated motion between frames and can be used for motion compensation.
    """

    super_clip = self.super(
        fallback(super, self.search_clip), levels=fallback(levels, self.analyze_args.get("levels"), 0)
    )

    blksize, blksizev = normalize_seq(blksize, 2)
    overlap, overlapv = normalize_seq(overlap, 2)

    if scale_lambda and lambda_ and blksize:
        lambda_ = lambda_ * blksize * fallback(blksizev, blksize) // 64

    analyze_args = self.analyze_args | KwargsNotNone(
        blksize=blksize,
        blksizev=blksizev,
        levels=levels,
        search=search,
        searchparam=searchparam,
        pelsearch=pelsearch,
        lambda_=lambda_,
        chroma=self.chroma,
        truemotion=truemotion,
        lsad=lsad,
        plevel=plevel,
        global_=global_,
        pnew=pnew,
        pzero=pzero,
        pglobal=pglobal,
        overlap=overlap,
        overlapv=overlapv,
        divide=divide,
        badsad=badsad,
        badrange=badrange,
        meander=meander,
        trymany=trymany,
        dct=dct,
        fields=self.fields,
        tff=self.tff,
    )

    self.vectors.clear()

    for delta in range(1, tr + 1):
        for direction in MVDirection:
            self.vectors.set_vector(
                core.mv.Analyse(super_clip, isb=direction is MVDirection.BACKWARD, delta=delta, **analyze_args),
                direction,
                delta,
            )

block_fps

block_fps(
    clip: VideoNode | None = None,
    super: VideoNode | None = None,
    vectors: MotionVectors | None = None,
    fps: Fraction | None = None,
    mode: int | None = None,
    ml: float | None = None,
    blend: bool | None = None,
    thscd: int | tuple[int | None, float | None] | None = None,
) -> VideoNode

Changes the framerate of the clip by interpolating frames between existing frames using block-based motion compensation.

Uses both backward and forward motion vectors to estimate motion and create frames at any time position between the current and next frame. Occlusion masks are used to handle areas where motion estimation fails, and time weighting ensures smooth blending between frames to minimize artifacts.

Parameters:

  • clip

    (VideoNode | None, default: None ) –

    The clip to process.

  • super

    (VideoNode | None, default: None ) –

    The multilevel super clip prepared by super. If None, super will be obtained from clip.

  • vectors

    (MotionVectors | None, default: None ) –

    Motion vectors to use. If None, uses the vectors from this instance.

  • fps

    (Fraction | None, default: None ) –

    Target output framerate as a Fraction.

  • mode

    (int | None, default: None ) –

    Processing mask mode for handling occlusions and motion failures.

  • ml

    (float | None, default: None ) –

    Mask scale parameter that controls occlusion mask strength. Higher values produce weaker occlusion masks. Used in MakeVectorOcclusionMaskTime for modes 3-5. Used in MakeSADMaskTime for modes 6-8.

  • blend

    (bool | None, default: None ) –

    Whether to blend frames at scene changes. If True, frames will be blended. If False, frames will be copied.

  • thscd

    (int | tuple[int | None, float | None] | None, default: None ) –

    Scene change detection thresholds:

    • First value: SAD threshold for considering a block changed between frames.
    • Second value: Percentage of changed blocks needed to trigger a scene change.

Returns:

  • VideoNode

    Clip with its framerate resampled.

Source code in vsdenoise/mvtools/mvtools.py
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
def block_fps(
    self,
    clip: vs.VideoNode | None = None,
    super: vs.VideoNode | None = None,
    vectors: MotionVectors | None = None,
    fps: Fraction | None = None,
    mode: int | None = None,
    ml: float | None = None,
    blend: bool | None = None,
    thscd: int | tuple[int | None, float | None] | None = None,
) -> vs.VideoNode:
    """
    Changes the framerate of the clip by interpolating frames between existing frames
    using block-based motion compensation.

    Uses both backward and forward motion vectors to estimate motion and create frames at any time position between
    the current and next frame. Occlusion masks are used to handle areas where motion estimation fails, and time
    weighting ensures smooth blending between frames to minimize artifacts.

    Args:
        clip: The clip to process.
        super: The multilevel super clip prepared by [super][vsdenoise.MVTools.super].
            If None, super will be obtained from clip.
        vectors: Motion vectors to use. If None, uses the vectors from this instance.
        fps: Target output framerate as a Fraction.
        mode: Processing mask mode for handling occlusions and motion failures.
        ml: Mask scale parameter that controls occlusion mask strength. Higher values produce weaker occlusion
            masks. Used in MakeVectorOcclusionMaskTime for modes 3-5. Used in MakeSADMaskTime for modes 6-8.
        blend: Whether to blend frames at scene changes. If True, frames will be blended. If False, frames will be
            copied.
        thscd: Scene change detection thresholds:

               - First value: SAD threshold for considering a block changed between frames.
               - Second value: Percentage of changed blocks needed to trigger a scene change.

    Returns:
        Clip with its framerate resampled.
    """

    clip = fallback(clip, self.clip)
    super_clip = self.super(fallback(super, clip), levels=1)

    vectors = fallback(vectors, self.vectors)
    vect_b, vect_f = vectors.get_vectors(tr=1)

    thscd1, thscd2 = normalize_thscd(thscd)

    block_fps_args: dict[str, Any] = KwargsNotNone(mode=mode, ml=ml, blend=blend, thscd1=thscd1, thscd2=thscd2)

    if fps is not None:
        block_fps_args.update(num=fps.numerator, den=fps.denominator)

    block_fps_args = self.block_fps_args | block_fps_args

    return core.mv.BlockFPS(clip, super_clip, vect_b[0], vect_f[0], **block_fps_args)

compensate

compensate(
    clip: VideoNode | None = None,
    super: VideoNode | None = None,
    vectors: MotionVectors | None = None,
    direction: MVDirection = BOTH,
    tr: int | None = None,
    scbehavior: bool | None = None,
    thsad: int | None = None,
    time: float | None = None,
    thscd: int | tuple[int | None, float | None] | None = None,
    interleave: Literal[True] = True,
    temporal_func: None = None,
) -> tuple[VideoNode, tuple[int, int]]
compensate(
    clip: VideoNode | None = None,
    super: VideoNode | None = None,
    vectors: MotionVectors | None = None,
    direction: MVDirection = BOTH,
    tr: int | None = None,
    scbehavior: bool | None = None,
    thsad: int | None = None,
    time: float | None = None,
    thscd: int | tuple[int | None, float | None] | None = None,
    interleave: Literal[True] = True,
    *,
    temporal_func: VSFunctionNoArgs,
) -> VideoNode
compensate(
    clip: VideoNode | None = None,
    super: VideoNode | None = None,
    vectors: MotionVectors | None = None,
    direction: MVDirection = BOTH,
    tr: int | None = None,
    scbehavior: bool | None = None,
    thsad: int | None = None,
    time: float | None = None,
    thscd: int | tuple[int | None, float | None] | None = None,
    *,
    interleave: Literal[False],
    temporal_func: None = None,
) -> tuple[list[VideoNode], list[VideoNode]]
compensate(
    clip: VideoNode | None = None,
    super: VideoNode | None = None,
    vectors: MotionVectors | None = None,
    direction: MVDirection = BOTH,
    tr: int | None = None,
    scbehavior: bool | None = None,
    thsad: int | None = None,
    time: float | None = None,
    thscd: int | tuple[int | None, float | None] | None = None,
    interleave: bool = True,
    temporal_func: VSFunctionNoArgs | None = None,
) -> (
    VideoNode
    | tuple[list[VideoNode], list[VideoNode]]
    | tuple[VideoNode, tuple[int, int]]
)

Perform motion compensation by moving blocks from reference frames to the current frame according to motion vectors.

This creates a prediction of the current frame by taking blocks from neighboring frames and moving them along their estimated motion paths.

Parameters:

  • clip

    (VideoNode | None, default: None ) –

    The clip to process.

  • super

    (VideoNode | None, default: None ) –

    The multilevel super clip prepared by super. If None, super will be obtained from clip.

  • vectors

    (MotionVectors | None, default: None ) –

    Motion vectors to use. If None, uses the vectors from this instance.

  • direction

    (MVDirection, default: BOTH ) –

    Motion vector direction to use.

  • tr

    (int | None, default: None ) –

    The temporal radius. This determines how many frames are analyzed before/after the current frame.

  • scbehavior

    (bool | None, default: None ) –

    Whether to keep the current frame on scene changes. If True, the frame is left unchanged. If False, the reference frame is copied.

  • thsad

    (int | None, default: None ) –

    SAD threshold for safe compensation. If block SAD is above thsad, the source block is used instead of the compensated block.

  • time

    (float | None, default: None ) –

    Time position between frames as a percentage (0.0-100.0). Controls the interpolation position between frames.

  • thscd

    (int | tuple[int | None, float | None] | None, default: None ) –

    Scene change detection thresholds:

    • First value: SAD threshold for considering a block changed between frames.
    • Second value: Percentage of changed blocks needed to trigger a scene change.
  • interleave

    (bool, default: True ) –

    Whether to interleave the compensated frames with the input.

  • temporal_func

    (VSFunctionNoArgs | None, default: None ) –

    Temporal function to apply to the motion compensated frames.

Returns:

  • VideoNode | tuple[list[VideoNode], list[VideoNode]] | tuple[VideoNode, tuple[int, int]]

    Motion compensated frames if func is provided, otherwise returns a tuple containing:

    • The interleaved compensated frames.
    • A tuple of (total_frames, center_offset) for manual frame selection.
Source code in vsdenoise/mvtools/mvtools.py
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
def compensate(
    self,
    clip: vs.VideoNode | None = None,
    super: vs.VideoNode | None = None,
    vectors: MotionVectors | None = None,
    direction: MVDirection = MVDirection.BOTH,
    tr: int | None = None,
    scbehavior: bool | None = None,
    thsad: int | None = None,
    time: float | None = None,
    thscd: int | tuple[int | None, float | None] | None = None,
    interleave: bool = True,
    temporal_func: VSFunctionNoArgs | None = None,
) -> vs.VideoNode | tuple[list[vs.VideoNode], list[vs.VideoNode]] | tuple[vs.VideoNode, tuple[int, int]]:
    """
    Perform motion compensation by moving blocks from reference frames to the current frame
    according to motion vectors.

    This creates a prediction of the current frame by taking blocks from neighboring frames
    and moving them along their estimated motion paths.

    Args:
        clip: The clip to process.
        super: The multilevel super clip prepared by [super][vsdenoise.MVTools.super].
            If None, super will be obtained from clip.
        vectors: Motion vectors to use. If None, uses the vectors from this instance.
        direction: Motion vector direction to use.
        tr: The temporal radius. This determines how many frames are analyzed before/after the current frame.
        scbehavior: Whether to keep the current frame on scene changes. If True, the frame is left unchanged. If
            False, the reference frame is copied.
        thsad: SAD threshold for safe compensation. If block SAD is above thsad, the source block is used instead of
            the compensated block.
        time: Time position between frames as a percentage (0.0-100.0). Controls the interpolation position between
            frames.
        thscd: Scene change detection thresholds:

               - First value: SAD threshold for considering a block changed between frames.
               - Second value: Percentage of changed blocks needed to trigger a scene change.

        interleave: Whether to interleave the compensated frames with the input.
        temporal_func: Temporal function to apply to the motion compensated frames.

    Returns:
        Motion compensated frames if func is provided, otherwise returns a tuple containing:

               - The interleaved compensated frames.
               - A tuple of (total_frames, center_offset) for manual frame selection.
    """

    clip = fallback(clip, self.clip)
    super_clip = self.super(fallback(super, clip), levels=1)

    vectors = fallback(vectors, self.vectors)
    vect_b, vect_f = vectors.get_vectors(direction, tr)

    thscd1, thscd2 = normalize_thscd(thscd)

    compensate_args = self.compensate_args | KwargsNotNone(
        scbehavior=scbehavior,
        thsad=thsad,
        time=time,
        thscd1=thscd1,
        thscd2=thscd2,
        fields=self.fields,
        tff=self.tff,
    )

    comp_back, comp_fwrd = [
        [core.mv.Compensate(clip, super_clip, vectors=vect, **compensate_args) for vect in vectors]
        for vectors in (reversed(vect_b), vect_f)
    ]

    if not interleave:
        return (comp_back, comp_fwrd)

    comp_clips = [*comp_fwrd, clip, *comp_back]
    cycle = len(comp_clips)
    offset = (cycle - 1) // 2

    interleaved = core.std.Interleave(comp_clips)

    if temporal_func:
        return core.std.SelectEvery(temporal_func(interleaved), cycle, offset)

    return interleaved, (cycle, offset)

degrain

degrain(
    clip: VideoNode | None = None,
    super: VideoNode | None = None,
    vectors: MotionVectors | None = None,
    tr: int | None = None,
    thsad: int | tuple[int | None, int | None] | None = None,
    limit: float | tuple[float | None, float | None] | None = None,
    thscd: int | tuple[int | None, float | None] | None = None,
    planes: Planes = None,
) -> VideoNode

Perform temporal denoising using motion compensation.

Motion compensated blocks from previous and next frames are averaged with the current frame. The weighting factors for each block depend on their SAD from the current frame.

Parameters:

  • clip

    (VideoNode | None, default: None ) –

    The clip to process. If None, the clip attribute is used.

  • super

    (VideoNode | None, default: None ) –

    The multilevel super clip prepared by super. If None, super will be obtained from clip.

  • vectors

    (MotionVectors | None, default: None ) –

    Motion vectors to use. If None, uses the vectors from this instance.

  • tr

    (int | None, default: None ) –

    The temporal radius. This determines how many frames are analyzed before/after the current frame.

  • thsad

    (int | tuple[int | None, int | None] | None, default: None ) –

    Defines the soft threshold of block sum absolute differences. Blocks with SAD above this threshold have zero weight for averaging (denoising). Blocks with low SAD have highest weight. The remaining weight is taken from pixels of source clip.

  • limit

    (float | tuple[float | None, float | None] | None, default: None ) –

    Maximum allowed change in pixel values (8 bits scale).

  • thscd

    (int | tuple[int | None, float | None] | None, default: None ) –

    Scene change detection thresholds:

    • First value: SAD threshold for considering a block changed between frames.
    • Second value: Percentage of changed blocks needed to trigger a scene change.
  • planes

    (Planes, default: None ) –

    Which planes to process. Default: None (all planes).

Returns:

  • VideoNode

    Motion compensated and temporally filtered clip with reduced noise.

Source code in vsdenoise/mvtools/mvtools.py
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
def degrain(
    self,
    clip: vs.VideoNode | None = None,
    super: vs.VideoNode | None = None,
    vectors: MotionVectors | None = None,
    tr: int | None = None,
    thsad: int | tuple[int | None, int | None] | None = None,
    limit: float | tuple[float | None, float | None] | None = None,
    thscd: int | tuple[int | None, float | None] | None = None,
    planes: Planes = None,
) -> vs.VideoNode:
    """
    Perform temporal denoising using motion compensation.

    Motion compensated blocks from previous and next frames are averaged with the current frame.
    The weighting factors for each block depend on their SAD from the current frame.

    Args:
        clip: The clip to process. If None, the [clip][vsdenoise.MVTools.clip] attribute is used.
        super: The multilevel super clip prepared by [super][vsdenoise.MVTools.super].
            If None, super will be obtained from clip.
        vectors: Motion vectors to use. If None, uses the vectors from this instance.
        tr: The temporal radius. This determines how many frames are analyzed before/after the current frame.
        thsad: Defines the soft threshold of block sum absolute differences. Blocks with SAD above this threshold
            have zero weight for averaging (denoising). Blocks with low SAD have highest weight. The remaining
            weight is taken from pixels of source clip.
        limit: Maximum allowed change in pixel values (8 bits scale).
        thscd: Scene change detection thresholds:

               - First value: SAD threshold for considering a block changed between frames.
               - Second value: Percentage of changed blocks needed to trigger a scene change.
        planes: Which planes to process. Default: None (all planes).

    Returns:
        Motion compensated and temporally filtered clip with reduced noise.
    """

    clip = fallback(clip, self.clip)
    super_clip = self.super(fallback(super, clip), levels=1)

    vectors = fallback(vectors, self.vectors)
    tr = fallback(tr, vectors.tr)
    vect_b, vect_f = vectors.get_vectors(tr=tr)

    thscd1, thscd2 = normalize_thscd(thscd)

    thsad, thsadc = normalize_seq(thsad, 2)
    nlimit, nlimitc = normalize_seq(limit, 2)

    if nlimit is not None:
        nlimit = scale_delta(nlimit, 8, clip)

    if nlimitc is not None:
        nlimitc = scale_delta(nlimitc, 8, clip)

    degrain_args = self.degrain_args | KwargsNotNone(
        thsad=thsad,
        thsadc=thsadc,
        plane=planes_to_mvtools(clip, planes),
        limit=nlimit,
        limitc=nlimitc,
        thscd1=thscd1,
        thscd2=thscd2,
    )

    return getattr(core.mv, f"Degrain{tr}")(
        clip, super_clip, *chain.from_iterable(zip(vect_b, vect_f)), **degrain_args
    )

flow

flow(
    clip: VideoNode | None = None,
    super: VideoNode | None = None,
    vectors: MotionVectors | None = None,
    direction: MVDirection = BOTH,
    tr: int | None = None,
    time: float | None = None,
    mode: FlowMode | None = None,
    thscd: int | tuple[int | None, float | None] | None = None,
    interleave: Literal[True] = True,
    temporal_func: None = None,
) -> tuple[VideoNode, tuple[int, int]]
flow(
    clip: VideoNode | None = None,
    super: VideoNode | None = None,
    vectors: MotionVectors | None = None,
    direction: MVDirection = BOTH,
    tr: int | None = None,
    time: float | None = None,
    mode: FlowMode | None = None,
    thscd: int | tuple[int | None, float | None] | None = None,
    interleave: Literal[True] = True,
    *,
    temporal_func: VSFunctionNoArgs,
) -> VideoNode
flow(
    clip: VideoNode | None = None,
    super: VideoNode | None = None,
    vectors: MotionVectors | None = None,
    direction: MVDirection = BOTH,
    tr: int | None = None,
    time: float | None = None,
    mode: FlowMode | None = None,
    thscd: int | tuple[int | None, float | None] | None = None,
    *,
    interleave: Literal[False],
    temporal_func: None = None,
) -> tuple[list[VideoNode], list[VideoNode]]
flow(
    clip: VideoNode | None = None,
    super: VideoNode | None = None,
    vectors: MotionVectors | None = None,
    direction: MVDirection = BOTH,
    tr: int | None = None,
    time: float | None = None,
    mode: FlowMode | None = None,
    thscd: int | tuple[int | None, float | None] | None = None,
    interleave: bool = True,
    temporal_func: VSFunctionNoArgs | None = None,
) -> (
    VideoNode
    | tuple[list[VideoNode], list[VideoNode]]
    | tuple[VideoNode, tuple[int, int]]
)

Performs motion compensation using pixel-level motion vectors interpolated from block vectors.

Unlike block-based compensation, this calculates a unique motion vector for each pixel by bilinearly interpolating between the motion vectors of the current block and its neighbors based on the pixel's position. The pixels in the reference frame are then moved along these interpolated vectors to their estimated positions in the current frame.

Parameters:

  • clip

    (VideoNode | None, default: None ) –

    The clip to process.

  • super

    (VideoNode | None, default: None ) –

    The multilevel super clip prepared by super. If None, super will be obtained from clip.

  • vectors

    (MotionVectors | None, default: None ) –

    Motion vectors to use. If None, uses the vectors from this instance.

  • direction

    (MVDirection, default: BOTH ) –

    Motion vector direction to use.

  • tr

    (int | None, default: None ) –

    The temporal radius. This determines how many frames are analyzed before/after the current frame.

  • time

    (float | None, default: None ) –

    Time position between frames as a percentage (0.0-100.0). Controls the interpolation position between frames.

  • mode

    (FlowMode | None, default: None ) –

    Method for positioning pixels during motion compensation. See FlowMode for options.

  • thscd

    (int | tuple[int | None, float | None] | None, default: None ) –

    Scene change detection thresholds:

    • First value: SAD threshold for considering a block changed between frames.
    • Second value: Percentage of changed blocks needed to trigger a scene change.
  • interleave

    (bool, default: True ) –

    Whether to interleave the compensated frames with the input.

  • temporal_func

    (VSFunctionNoArgs | None, default: None ) –

    Optional function to process the motion compensated frames. Takes the interleaved frames as input and returns processed frames.

Returns:

  • VideoNode | tuple[list[VideoNode], list[VideoNode]] | tuple[VideoNode, tuple[int, int]]

    Motion compensated frames if func is provided, otherwise returns a tuple containing:

    • The interleaved compensated frames.
    • A tuple of (total_frames, center_offset) for manual frame selection.
Source code in vsdenoise/mvtools/mvtools.py
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
def flow(
    self,
    clip: vs.VideoNode | None = None,
    super: vs.VideoNode | None = None,
    vectors: MotionVectors | None = None,
    direction: MVDirection = MVDirection.BOTH,
    tr: int | None = None,
    time: float | None = None,
    mode: FlowMode | None = None,
    thscd: int | tuple[int | None, float | None] | None = None,
    interleave: bool = True,
    temporal_func: VSFunctionNoArgs | None = None,
) -> vs.VideoNode | tuple[list[vs.VideoNode], list[vs.VideoNode]] | tuple[vs.VideoNode, tuple[int, int]]:
    """
    Performs motion compensation using pixel-level motion vectors interpolated from block vectors.

    Unlike block-based compensation, this calculates a unique motion vector for each pixel
    by bilinearly interpolating between the motion vectors of the current block and its neighbors
    based on the pixel's position.
    The pixels in the reference frame are then moved along these interpolated vectors
    to their estimated positions in the current frame.

    Args:
        clip: The clip to process.
        super: The multilevel super clip prepared by [super][vsdenoise.MVTools.super].
            If None, super will be obtained from clip.
        vectors: Motion vectors to use. If None, uses the vectors from this instance.
        direction: Motion vector direction to use.
        tr: The temporal radius. This determines how many frames are analyzed before/after the current frame.
        time: Time position between frames as a percentage (0.0-100.0). Controls the interpolation position between
            frames.
        mode: Method for positioning pixels during motion compensation.
            See [FlowMode][vsdenoise.FlowMode] for options.
        thscd: Scene change detection thresholds:

               - First value: SAD threshold for considering a block changed between frames.
               - Second value: Percentage of changed blocks needed to trigger a scene change.
        interleave: Whether to interleave the compensated frames with the input.
        temporal_func: Optional function to process the motion compensated frames. Takes the interleaved frames as
            input and returns processed frames.

    Returns:
        Motion compensated frames if func is provided, otherwise returns a tuple containing:

               - The interleaved compensated frames.
               - A tuple of (total_frames, center_offset) for manual frame selection.
    """

    clip = fallback(clip, self.clip)
    super_clip = self.super(fallback(super, clip), levels=1)

    vectors = fallback(vectors, self.vectors)
    vect_b, vect_f = vectors.get_vectors(direction, tr)

    thscd1, thscd2 = normalize_thscd(thscd)

    flow_args = self.flow_args | KwargsNotNone(
        time=time,
        mode=mode,
        thscd1=thscd1,
        thscd2=thscd2,
        fields=self.fields,
        tff=self.tff,
    )

    flow_back, flow_fwrd = [
        [core.mv.Flow(clip, super_clip, vectors=vect, **flow_args) for vect in vectors]
        for vectors in (reversed(vect_b), vect_f)
    ]

    if not interleave:
        return (flow_back, flow_fwrd)

    flow_clips = [*flow_fwrd, clip, *flow_back]
    cycle = len(flow_clips)
    offset = (cycle - 1) // 2

    interleaved = core.std.Interleave(flow_clips)

    if temporal_func:
        return core.std.SelectEvery(temporal_func(interleaved), cycle, offset)

    return interleaved, (cycle, offset)

flow_blur

flow_blur(
    clip: VideoNode | None = None,
    super: VideoNode | None = None,
    vectors: MotionVectors | None = None,
    blur: float | None = None,
    prec: int | None = None,
    thscd: int | tuple[int | None, float | None] | None = None,
) -> VideoNode

Creates a motion blur effect by simulating finite shutter time, similar to film cameras.

Uses backward and forward motion vectors to create and overlay multiple copies of motion compensated pixels at intermediate time positions within a blurring interval around the current frame.

Parameters:

  • clip

    (VideoNode | None, default: None ) –

    The clip to process.

  • super

    (VideoNode | None, default: None ) –

    The multilevel super clip prepared by super. If None, super will be obtained from clip.

  • vectors

    (MotionVectors | None, default: None ) –

    Motion vectors to use. If None, uses the vectors from this instance.

  • blur

    (float | None, default: None ) –

    Blur time interval between frames as a percentage (0.0-100.0). Controls the simulated shutter time/motion blur strength.

  • prec

    (int | None, default: None ) –

    Blur precision in pixel units. Controls the accuracy of the motion blur.

  • thscd

    (int | tuple[int | None, float | None] | None, default: None ) –

    Scene change detection thresholds:

    • First value: SAD threshold for considering a block changed between frames.
    • Second value: Percentage of changed blocks needed to trigger a scene change.

Returns:

  • VideoNode

    Motion blurred clip.

Source code in vsdenoise/mvtools/mvtools.py
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
def flow_blur(
    self,
    clip: vs.VideoNode | None = None,
    super: vs.VideoNode | None = None,
    vectors: MotionVectors | None = None,
    blur: float | None = None,
    prec: int | None = None,
    thscd: int | tuple[int | None, float | None] | None = None,
) -> vs.VideoNode:
    """
    Creates a motion blur effect by simulating finite shutter time, similar to film cameras.

    Uses backward and forward motion vectors to create and overlay multiple copies of motion compensated pixels
    at intermediate time positions within a blurring interval around the current frame.

    Args:
        clip: The clip to process.
        super: The multilevel super clip prepared by [super][vsdenoise.MVTools.super].
            If None, super will be obtained from clip.
        vectors: Motion vectors to use. If None, uses the vectors from this instance.
        blur: Blur time interval between frames as a percentage (0.0-100.0). Controls the simulated shutter
            time/motion blur strength.
        prec: Blur precision in pixel units. Controls the accuracy of the motion blur.
        thscd: Scene change detection thresholds:

               - First value: SAD threshold for considering a block changed between frames.
               - Second value: Percentage of changed blocks needed to trigger a scene change.

    Returns:
        Motion blurred clip.
    """

    clip = fallback(clip, self.clip)
    super_clip = self.super(fallback(super, clip), levels=1)

    vectors = fallback(vectors, self.vectors)
    vect_b, vect_f = vectors.get_vectors(tr=1)

    thscd1, thscd2 = normalize_thscd(thscd)

    flow_blur_args = self.flow_blur_args | KwargsNotNone(blur=blur, prec=prec, thscd1=thscd1, thscd2=thscd2)

    return core.mv.FlowBlur(clip, super_clip, vect_b[0], vect_f[0], **flow_blur_args)

flow_fps

flow_fps(
    clip: VideoNode | None = None,
    super: VideoNode | None = None,
    vectors: MotionVectors | None = None,
    fps: Fraction | None = None,
    mask: int | None = None,
    ml: float | None = None,
    blend: bool | None = None,
    thscd: int | tuple[int | None, float | None] | None = None,
) -> VideoNode

Changes the framerate of the clip by interpolating frames between existing frames.

Uses both backward and forward motion vectors to estimate motion and create frames at any time position between the current and next frame. Occlusion masks are used to handle areas where motion estimation fails, and time weighting ensures smooth blending between frames to minimize artifacts.

Parameters:

  • clip

    (VideoNode | None, default: None ) –

    The clip to process.

  • super

    (VideoNode | None, default: None ) –

    The multilevel super clip prepared by super. If None, super will be obtained from clip.

  • vectors

    (MotionVectors | None, default: None ) –

    Motion vectors to use. If None, uses the vectors from this instance.

  • fps

    (Fraction | None, default: None ) –

    Target output framerate as a Fraction.

  • mask

    (int | None, default: None ) –

    Processing mask mode for handling occlusions and motion failures.

  • ml

    (float | None, default: None ) –

    Mask scale parameter that controls occlusion mask strength. Higher values produce weaker occlusion masks. Used in MakeVectorOcclusionMaskTime for modes 3-5. Used in MakeSADMaskTime for modes 6-8.

  • blend

    (bool | None, default: None ) –

    Whether to blend frames at scene changes. If True, frames will be blended. If False, frames will be copied.

  • thscd

    (int | tuple[int | None, float | None] | None, default: None ) –

    Scene change detection thresholds:

    • First value: SAD threshold for considering a block changed between frames.
    • Second value: Percentage of changed blocks needed to trigger a scene change.

Returns:

  • VideoNode

    Clip with its framerate resampled.

Source code in vsdenoise/mvtools/mvtools.py
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
def flow_fps(
    self,
    clip: vs.VideoNode | None = None,
    super: vs.VideoNode | None = None,
    vectors: MotionVectors | None = None,
    fps: Fraction | None = None,
    mask: int | None = None,
    ml: float | None = None,
    blend: bool | None = None,
    thscd: int | tuple[int | None, float | None] | None = None,
) -> vs.VideoNode:
    """
    Changes the framerate of the clip by interpolating frames between existing frames.

    Uses both backward and forward motion vectors to estimate motion and create frames at any time position between
    the current and next frame. Occlusion masks are used to handle areas where motion estimation fails, and time
    weighting ensures smooth blending between frames to minimize artifacts.

    Args:
        clip: The clip to process.
        super: The multilevel super clip prepared by [super][vsdenoise.MVTools.super].
            If None, super will be obtained from clip.
        vectors: Motion vectors to use. If None, uses the vectors from this instance.
        fps: Target output framerate as a Fraction.
        mask: Processing mask mode for handling occlusions and motion failures.
        ml: Mask scale parameter that controls occlusion mask strength. Higher values produce weaker occlusion
            masks. Used in MakeVectorOcclusionMaskTime for modes 3-5. Used in MakeSADMaskTime for modes 6-8.
        blend: Whether to blend frames at scene changes. If True, frames will be blended. If False, frames will be
            copied.
        thscd: Scene change detection thresholds:

               - First value: SAD threshold for considering a block changed between frames.
               - Second value: Percentage of changed blocks needed to trigger a scene change.

    Returns:
        Clip with its framerate resampled.
    """

    clip = fallback(clip, self.clip)
    super_clip = self.super(fallback(super, clip), levels=1)

    vectors = fallback(vectors, self.vectors)
    vect_b, vect_f = vectors.get_vectors(tr=1)

    thscd1, thscd2 = normalize_thscd(thscd)

    flow_fps_args: dict[str, Any] = KwargsNotNone(mask=mask, ml=ml, blend=blend, thscd1=thscd1, thscd2=thscd2)

    if fps is not None:
        flow_fps_args.update(num=fps.numerator, den=fps.denominator)

    flow_fps_args = self.flow_fps_args | flow_fps_args

    return core.mv.FlowFPS(clip, super_clip, vect_b[0], vect_f[0], **flow_fps_args)

flow_interpolate

flow_interpolate(
    clip: VideoNode | None = None,
    super: VideoNode | None = None,
    vectors: MotionVectors | None = None,
    time: float | None = None,
    ml: float | None = None,
    blend: bool | None = None,
    thscd: int | tuple[int | None, float | None] | None = None,
    interleave: bool = True,
) -> VideoNode

Motion interpolation function that creates an intermediate frame between two frames.

Uses both backward and forward motion vectors to estimate motion and create a frame at any time position between the current and next frame. Occlusion masks are used to handle areas where motion estimation fails, and time weighting ensures smooth blending between frames to minimize artifacts.

Parameters:

  • clip

    (VideoNode | None, default: None ) –

    The clip to process.

  • super

    (VideoNode | None, default: None ) –

    The multilevel super clip prepared by super. If None, super will be obtained from clip.

  • vectors

    (MotionVectors | None, default: None ) –

    Motion vectors to use. If None, uses the vectors from this instance.

  • time

    (float | None, default: None ) –

    Time position between frames as a percentage (0.0-100.0). Controls the interpolation position between frames. Does nothing if multi is specified.

  • ml

    (float | None, default: None ) –

    Mask scale parameter that controls occlusion mask strength. Higher values produce weaker occlusion masks. Used in MakeVectorOcclusionMaskTime for modes 3-5. Used in MakeSADMaskTime for modes 6-8.

  • blend

    (bool | None, default: None ) –

    Whether to blend frames at scene changes. If True, frames will be blended. If False, frames will be copied.

  • thscd

    (int | tuple[int | None, float | None] | None, default: None ) –

    Scene change detection thresholds:

    • First value: SAD threshold for considering a block changed between frames.
    • Second value: Percentage of changed blocks needed to trigger a scene change.
  • interleave

    (bool, default: True ) –

    Whether to interleave the interpolated frames with the source clip.

Returns:

  • VideoNode

    List of the motion interpolated frames if interleave=False else a motion interpolated clip.

Source code in vsdenoise/mvtools/mvtools.py
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
def flow_interpolate(
    self,
    clip: vs.VideoNode | None = None,
    super: vs.VideoNode | None = None,
    vectors: MotionVectors | None = None,
    time: float | None = None,
    ml: float | None = None,
    blend: bool | None = None,
    thscd: int | tuple[int | None, float | None] | None = None,
    interleave: bool = True,
) -> vs.VideoNode:
    """
    Motion interpolation function that creates an intermediate frame between two frames.

    Uses both backward and forward motion vectors to estimate motion and create a frame at any time position between
    the current and next frame. Occlusion masks are used to handle areas where motion estimation fails, and time
    weighting ensures smooth blending between frames to minimize artifacts.

    Args:
        clip: The clip to process.
        super: The multilevel super clip prepared by [super][vsdenoise.MVTools.super].
            If None, super will be obtained from clip.
        vectors: Motion vectors to use. If None, uses the vectors from this instance.
        time: Time position between frames as a percentage (0.0-100.0). Controls the interpolation position between
            frames. Does nothing if multi is specified.
        ml: Mask scale parameter that controls occlusion mask strength. Higher values produce weaker occlusion
            masks. Used in MakeVectorOcclusionMaskTime for modes 3-5. Used in MakeSADMaskTime for modes 6-8.
        blend: Whether to blend frames at scene changes. If True, frames will be blended. If False, frames will be
            copied.
        thscd: Scene change detection thresholds:

               - First value: SAD threshold for considering a block changed between frames.
               - Second value: Percentage of changed blocks needed to trigger a scene change.
        interleave: Whether to interleave the interpolated frames with the source clip.

    Returns:
        List of the motion interpolated frames if interleave=False else a motion interpolated clip.
    """
    clip = fallback(clip, self.clip)

    super_clip = self.super(fallback(super, clip), levels=1)

    vectors = fallback(vectors, self.vectors)
    vect_b, vect_f = vectors.get_vectors(tr=1)

    thscd1, thscd2 = normalize_thscd(thscd)

    flow_interpolate_args = self.flow_interpolate_args | KwargsNotNone(
        time=time, ml=ml, blend=blend, thscd1=thscd1, thscd2=thscd2
    )

    interpolated = core.mv.FlowInter(clip, super_clip, vect_b[0], vect_f[0], **flow_interpolate_args)

    if interleave:
        interpolated = core.std.Interleave([clip, interpolated])

    return interpolated

mask

mask(
    clip: VideoNode | None = None,
    vectors: MotionVectors | None = None,
    direction: Literal[FORWARD, BACKWARD] = FORWARD,
    delta: int = 1,
    ml: float | None = None,
    gamma: float | None = None,
    kind: MaskMode | None = None,
    time: float | None = None,
    ysc: int | None = None,
    thscd: int | tuple[int | None, float | None] | None = None,
) -> VideoNode

Creates a mask clip from motion vectors data.

The processing is always done at 8-bits https://github.com/dubhater/vapoursynth-mvtools/issues/16.

Parameters:

  • clip

    (VideoNode | None, default: None ) –

    The clip to process. If None, the clip attribute is used.

  • vectors

    (MotionVectors | None, default: None ) –

    Motion vectors to use. If None, uses the vectors from this instance.

  • direction

    (Literal[FORWARD, BACKWARD], default: FORWARD ) –

    Motion vector direction to use.

  • delta

    (int, default: 1 ) –

    Motion vector delta to use.

  • ml

    (float | None, default: None ) –

    Motion length scale factor. When the vector's length (or other mask value) is greater than or equal to ml, the output is saturated to 255.

  • gamma

    (float | None, default: None ) –

    Exponent for the relation between input and output values. 1.0 gives a linear relation, 2.0 gives a quadratic relation.

  • kind

    (MaskMode | None, default: None ) –

    Type of mask to generate. See MaskMode for options.

  • time

    (float | None, default: None ) –

    Time position between frames as a percentage (0.0-100.0).

  • ysc

    (int | None, default: None ) –

    Value assigned to the mask on scene changes.

  • thscd

    (int | tuple[int | None, float | None] | None, default: None ) –

    Scene change detection thresholds:

    • First value: SAD threshold for considering a block changed between frames.
    • Second value: Percentage of changed blocks needed to trigger a scene change.

Returns:

  • VideoNode

    Motion mask clip.

Source code in vsdenoise/mvtools/mvtools.py
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
def mask(
    self,
    clip: vs.VideoNode | None = None,
    vectors: MotionVectors | None = None,
    direction: Literal[MVDirection.FORWARD, MVDirection.BACKWARD] = MVDirection.FORWARD,
    delta: int = 1,
    ml: float | None = None,
    gamma: float | None = None,
    kind: MaskMode | None = None,
    time: float | None = None,
    ysc: int | None = None,
    thscd: int | tuple[int | None, float | None] | None = None,
) -> vs.VideoNode:
    """
    Creates a mask clip from motion vectors data.

    The processing is always done at 8-bits <https://github.com/dubhater/vapoursynth-mvtools/issues/16>.

    Args:
        clip: The clip to process. If None, the [clip][vsdenoise.MVTools.clip] attribute is used.
        vectors: Motion vectors to use. If None, uses the vectors from this instance.
        direction: Motion vector direction to use.
        delta: Motion vector delta to use.
        ml: Motion length scale factor. When the vector's length (or other mask value) is greater than or equal to
            ml, the output is saturated to 255.
        gamma: Exponent for the relation between input and output values. 1.0 gives a linear relation, 2.0 gives a
            quadratic relation.
        kind: Type of mask to generate. See [MaskMode][vsdenoise.MaskMode] for options.
        time: Time position between frames as a percentage (0.0-100.0).
        ysc: Value assigned to the mask on scene changes.
        thscd: Scene change detection thresholds:

               - First value: SAD threshold for considering a block changed between frames.
               - Second value: Percentage of changed blocks needed to trigger a scene change.

    Returns:
        Motion mask clip.
    """

    clip = fallback(clip, self.clip)

    vectors = fallback(vectors, self.vectors)
    vect = vectors.get_vector(direction, delta)

    thscd1, thscd2 = normalize_thscd(thscd)

    mask_args = self.mask_args | KwargsNotNone(
        ml=ml, gamma=gamma, kind=kind, time=time, ysc=ysc, thscd1=thscd1, thscd2=thscd2
    )

    mask_clip = core.mv.Mask(depth(clip, 8), vect, **mask_args)

    return depth(mask_clip, clip, dither_type=DitherType.NONE, range_in=Range.FULL, range_out=Range.FULL)

recalculate

recalculate(
    super: VideoNode | None = None,
    vectors: MotionVectors | None = None,
    thsad: int | None = None,
    blksize: int | tuple[int | None, int | None] | None = None,
    search: SearchMode | None = None,
    searchparam: int | None = None,
    lambda_: int | None = None,
    truemotion: MotionMode | None = None,
    pnew: int | None = None,
    overlap: int | tuple[int | None, int | None] | None = None,
    divide: bool | None = None,
    meander: bool | None = None,
    dct: SADMode | None = None,
    scale_lambda: bool = True,
) -> None

Refines and recalculates motion vectors that were previously estimated, optionally using a different super clip or parameters.

This two-stage approach can provide more stable and robust motion estimation.

The refinement only occurs at the finest hierarchical level. It uses the interpolated vectors from the original blocks as predictors for the new vectors, and recalculates their SAD values.

Only vectors with poor quality (SAD above threshold) will be re-estimated through a new search. The SAD threshold is normalized to an 8x8 block size. Vectors with good quality are preserved, though their SAD values are still recalculated and updated.

Parameters:

  • super

    (VideoNode | None, default: None ) –

    The multilevel super clip prepared by super. If None, super will be obtained from clip.

  • vectors

    (MotionVectors | None, default: None ) –

    Motion vectors to use. If None, uses the vectors from this instance.

  • thsad

    (int | None, default: None ) –

    Only bad quality new vectors with a SAD above this will be re-estimated by search. thsad value is scaled to 8x8 block size.

  • blksize

    (int | tuple[int | None, int | None] | None, default: None ) –

    Size of blocks for motion estimation. Can be an int or tuple of (width, height). Larger blocks are less sensitive to noise and faster to process, but will produce less accurate vectors.

  • search

    (SearchMode | None, default: None ) –

    Search algorithm to use at the finest level. See SearchMode for options.

  • searchparam

    (int | None, default: None ) –

    Additional parameter for the search algorithm. For NSTEP, this is the step size. For EXHAUSTIVE, EXHAUSTIVE_H, EXHAUSTIVE_V, HEXAGON and UMH, this is the search radius.

  • lambda_

    (int | None, default: None ) –

    Controls the coherence of the motion vector field. Higher values enforce more coherent/smooth motion between blocks. Too high values may cause the algorithm to miss the optimal vectors.

  • truemotion

    (MotionMode | None, default: None ) –

    Preset that controls the default values of motion estimation parameters to optimize for true motion. For more information, see MotionMode.

  • pnew

    (int | None, default: None ) –

    Penalty multiplier (relative to 256) applied to the SAD cost when evaluating new candidate vectors. Higher values make the search more conservative.

  • overlap

    (int | tuple[int | None, int | None] | None, default: None ) –

    Block overlap value. Can be a single integer for both dimensions or a tuple of (horizontal, vertical) overlap values. Each value must be even and less than its corresponding block size dimension.

  • divide

    (bool | None, default: None ) –

    Whether to divide each block into 4 subblocks during post-processing. This may improve accuracy at the cost of performance.

  • meander

    (bool | None, default: None ) –

    Whether to use a meandering scan pattern when processing blocks. If True, alternates between left- to-right and right-to-left scanning between rows to improve motion coherence.

  • dct

    (SADMode | None, default: None ) –

    SAD calculation mode using block DCT (frequency spectrum) for comparing blocks. For more information, see SADMode.

  • scale_lambda

    (bool, default: True ) –

    Whether to scale lambda_ value according to truemotion's default value formula.

Source code in vsdenoise/mvtools/mvtools.py
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
def recalculate(
    self,
    super: vs.VideoNode | None = None,
    vectors: MotionVectors | None = None,
    thsad: int | None = None,
    blksize: int | tuple[int | None, int | None] | None = None,
    search: SearchMode | None = None,
    searchparam: int | None = None,
    lambda_: int | None = None,
    truemotion: MotionMode | None = None,
    pnew: int | None = None,
    overlap: int | tuple[int | None, int | None] | None = None,
    divide: bool | None = None,
    meander: bool | None = None,
    dct: SADMode | None = None,
    scale_lambda: bool = True,
) -> None:
    """
    Refines and recalculates motion vectors that were previously estimated,
    optionally using a different super clip or parameters.

    This two-stage approach can provide more stable and robust motion estimation.

    The refinement only occurs at the finest hierarchical level.
    It uses the interpolated vectors from the original blocks as predictors for the new vectors,
    and recalculates their SAD values.

    Only vectors with poor quality (SAD above threshold) will be re-estimated through a new search.
    The SAD threshold is normalized to an 8x8 block size. Vectors with good quality are preserved,
    though their SAD values are still recalculated and updated.

    Args:
        super: The multilevel super clip prepared by [super][vsdenoise.MVTools.super].
            If None, super will be obtained from clip.
        vectors: Motion vectors to use. If None, uses the vectors from this instance.
        thsad: Only bad quality new vectors with a SAD above this will be re-estimated by search. thsad value is
            scaled to 8x8 block size.
        blksize: Size of blocks for motion estimation. Can be an int or tuple of (width, height). Larger blocks are
            less sensitive to noise and faster to process, but will produce less accurate vectors.
        search: Search algorithm to use at the finest level. See [SearchMode][vsdenoise.SearchMode] for options.
        searchparam: Additional parameter for the search algorithm. For NSTEP, this is the step size. For
            EXHAUSTIVE, EXHAUSTIVE_H, EXHAUSTIVE_V, HEXAGON and UMH, this is the search radius.
        lambda_: Controls the coherence of the motion vector field. Higher values enforce more coherent/smooth
            motion between blocks. Too high values may cause the algorithm to miss the optimal vectors.
        truemotion: Preset that controls the default values of motion estimation parameters to optimize for true
            motion. For more information, see [MotionMode][vsdenoise.MotionMode].
        pnew: Penalty multiplier (relative to 256) applied to the SAD cost when evaluating new candidate vectors.
            Higher values make the search more conservative.
        overlap: Block overlap value. Can be a single integer for both dimensions or a tuple of (horizontal,
            vertical) overlap values. Each value must be even and less than its corresponding block size dimension.
        divide: Whether to divide each block into 4 subblocks during post-processing. This may improve accuracy at
            the cost of performance.
        meander: Whether to use a meandering scan pattern when processing blocks. If True, alternates between left-
            to-right and right-to-left scanning between rows to improve motion coherence.
        dct: SAD calculation mode using block DCT (frequency spectrum) for comparing blocks. For more information,
            see [SADMode][vsdenoise.SADMode].
        scale_lambda: Whether to scale lambda_ value according to truemotion's default value formula.
    """

    super_clip = self.super(fallback(super, self.search_clip), levels=1)

    vectors = fallback(vectors, self.vectors)

    blksize, blksizev = normalize_seq(blksize, 2)
    overlap, overlapv = normalize_seq(overlap, 2)

    if scale_lambda and lambda_ and blksize:
        lambda_ = lambda_ * blksize * fallback(blksizev, blksize) // 64

    recalculate_args = self.recalculate_args | KwargsNotNone(
        thsad=thsad,
        blksize=blksize,
        blksizev=blksizev,
        search=search,
        searchparam=searchparam,
        lambda_=lambda_,
        chroma=self.chroma,
        truemotion=truemotion,
        pnew=pnew,
        overlap=overlap,
        overlapv=overlapv,
        divide=divide,
        meander=meander,
        dct=dct,
        fields=self.fields,
        tff=self.tff,
    )

    del vectors.analysis_data

    for delta in range(1, vectors.tr + 1):
        for direction in MVDirection:
            vectors.set_vector(
                core.mv.Recalculate(super_clip, vectors.get_vector(direction, delta), **recalculate_args),
                direction,
                delta,
            )

sc_detection

sc_detection(
    clip: VideoNode | None = None,
    vectors: MotionVectors | None = None,
    delta: int = 1,
    thscd: int | tuple[int | None, float | None] | None = None,
) -> VideoNode

Creates scene change frameprops from motion vectors data.

Parameters:

  • clip

    (VideoNode | None, default: None ) –

    The clip to process. If None, the clip attribute is used.

  • vectors

    (MotionVectors | None, default: None ) –

    Motion vectors to use. If None, uses the vectors from this instance.

  • delta

    (int, default: 1 ) –

    Motion vector delta to use.

  • thscd

    (int | tuple[int | None, float | None] | None, default: None ) –

    Scene change detection thresholds:

    • First value: SAD threshold for considering a block changed between frames.
    • Second value: Percentage of changed blocks needed to trigger a scene change.

Returns:

  • VideoNode

    Clip with scene change properties set.

Source code in vsdenoise/mvtools/mvtools.py
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
def sc_detection(
    self,
    clip: vs.VideoNode | None = None,
    vectors: MotionVectors | None = None,
    delta: int = 1,
    thscd: int | tuple[int | None, float | None] | None = None,
) -> vs.VideoNode:
    """
    Creates scene change frameprops from motion vectors data.

    Args:
        clip: The clip to process. If None, the [clip][vsdenoise.MVTools.clip] attribute is used.
        vectors: Motion vectors to use. If None, uses the vectors from this instance.
        delta: Motion vector delta to use.
        thscd: Scene change detection thresholds:

               - First value: SAD threshold for considering a block changed between frames.
               - Second value: Percentage of changed blocks needed to trigger a scene change.

    Returns:
        Clip with scene change properties set.
    """

    clip = fallback(clip, self.clip)

    vectors = fallback(vectors, self.vectors)

    thscd1, thscd2 = normalize_thscd(thscd)

    sc_detection_args = self.sc_detection_args | KwargsNotNone(thscd1=thscd1, thscd2=thscd2)

    detect = clip
    for direction in MVDirection:
        detect = core.mv.SCDetection(detect, vectors.get_vector(direction, delta), **sc_detection_args)

    return detect

super

super(
    clip: VideoNode | None = None,
    vectors: MotionVectors | None = None,
    levels: int | None = None,
    sharp: SharpMode | None = None,
    rfilter: RFilterMode | None = None,
    pelclip: VideoNode | VSFunctionNoArgs | None = None,
) -> VideoNode

Get source clip and prepare special "super" clip with multilevel (hierarchical scaled) frames data. The super clip is used by both analyze and motion compensation (client) functions.

You can use different Super clip for generation vectors with analyze and a different super clip format for the actual action. Source clip is appended to clip's frameprops, [get_super][vsdenoise.MVTools.get_super] can be used to extract the super clip if you wish to view it yourself.

Parameters:

  • clip

    (VideoNode | None, default: None ) –

    The clip to process. If None, the clip attribute is used.

  • vectors

    (MotionVectors | None, default: None ) –

    Motion vectors to use. If None, uses the vectors from this instance.

  • levels

    (int | None, default: None ) –

    The number of hierarchical levels in super clip frames. More levels are needed for analyze to get better vectors, but fewer levels are needed for the actual motion compensation. 0 = auto, all possible levels are produced.

  • sharp

    (SharpMode | None, default: None ) –

    Subpixel interpolation method if pel is 2 or 4. For more information, see SharpMode.

  • rfilter

    (RFilterMode | None, default: None ) –

    Hierarchical levels smoothing and reducing (halving) filter. For more information, see RFilterMode.

  • pelclip

    (VideoNode | VSFunctionNoArgs | None, default: None ) –

    Optional upsampled source clip to use instead of internal subpixel interpolation (if pel > 1). The clip must contain the original source pixels at positions that are multiples of pel (e.g., positions 0, 2, 4, etc. for pel=2), with interpolated pixels in between. The clip should not be padded.

Returns:

  • VideoNode

    The original clip with the super clip attached as a frame property.

Source code in vsdenoise/mvtools/mvtools.py
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
def super(
    self,
    clip: vs.VideoNode | None = None,
    vectors: MotionVectors | None = None,
    levels: int | None = None,
    sharp: SharpMode | None = None,
    rfilter: RFilterMode | None = None,
    pelclip: vs.VideoNode | VSFunctionNoArgs | None = None,
) -> vs.VideoNode:
    """
    Get source clip and prepare special "super" clip with multilevel (hierarchical scaled) frames data.
    The super clip is used by both [analyze][vsdenoise.MVTools.analyze] and motion compensation (client) functions.

    You can use different Super clip for generation vectors with [analyze][vsdenoise.MVTools.analyze]
    and a different super clip format for the actual action.
    Source clip is appended to clip's frameprops, [get_super][vsdenoise.MVTools.get_super] can be used
    to extract the super clip if you wish to view it yourself.

    Args:
        clip: The clip to process. If None, the [clip][vsdenoise.MVTools.clip] attribute is used.
        vectors: Motion vectors to use. If None, uses the vectors from this instance.
        levels: The number of hierarchical levels in super clip frames.
            More levels are needed for [analyze][vsdenoise.MVTools.analyze] to get better vectors,
            but fewer levels are needed for the actual motion compensation.
            0 = auto, all possible levels are produced.
        sharp: Subpixel interpolation method if pel is 2 or 4.
            For more information, see [SharpMode][vsdenoise.SharpMode].
        rfilter: Hierarchical levels smoothing and reducing (halving) filter. For more information, see
            [RFilterMode][vsdenoise.RFilterMode].
        pelclip: Optional upsampled source clip to use instead of internal subpixel interpolation (if pel > 1). The
            clip must contain the original source pixels at positions that are multiples of pel (e.g., positions 0,
            2, 4, etc. for pel=2), with interpolated pixels in between. The clip should not be padded.

    Returns:
        The original clip with the super clip attached as a frame property.
    """

    clip = fallback(clip, self.clip)

    vectors = fallback(vectors, self.vectors)

    if vectors.scaled:
        hpad, vpad = vectors.analysis_data["Analysis_Padding"]
    else:
        hpad, vpad = self.pad

    if callable(pelclip):
        pelclip = pelclip(clip)

    super_args = {
        "hpad": fallback(hpad, 16),
        "vpad": fallback(vpad, 16),
        "pel": fallback(self.pel, 2),
        "chroma": fallback(self.chroma, True),
        "sharp": fallback(sharp, self.super_args.get("sharp"), 2),
        "rfilter": fallback(rfilter, self.super_args.get("rfilter"), 2),
        "pelclip": fallback(pelclip, default=self.super_args.get("pelclip")),
    }

    return _super_clip_cache.get_cached_super(
        clip, fallback(levels, self.super_args.get("levels"), 0), **super_args
    )