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:
-
(clip¶VideoNode) –The clip to process.
-
(search_clip¶VideoNode | VSFunctionNoArgs | None, default:None) –Optional clip or callable to be used for motion vector gathering only.
-
(vectors¶MotionVectors | None, default:None) –Motion vectors to use. If None, uses the vectors from this instance.
-
(pad¶int | tuple[int | None, int | None] | None, default:None) –How much padding to add to the source frame. Small padding is added to help with motion estimation near frame borders.
-
(pel¶int | None, default:None) –Subpixel precision for motion estimation (1=pixel, 2=half-pixel, 4=quarter-pixel). Default: 1.
-
(chroma¶bool | None, default:None) –Whether to consider chroma in motion vector calculations.
-
(field¶FieldLike | None, default:None) –Set field order for interlaced processing, input is expected to be separated fields.
-
(super_args¶Mapping[str, Any] | None, default:None) –Arguments passed to every MVTools.super call.
-
(analyze_args¶Mapping[str, Any] | None, default:None) –Arguments passed to every MVTools.analyze call.
-
(recalculate_args¶Mapping[str, Any] | None, default:None) –Arguments passed to every MVTools.recalculate call.
-
(compensate_args¶Mapping[str, Any] | None, default:None) –Arguments passed to every MVTools.compensate call.
-
(flow_args¶Mapping[str, Any] | None, default:None) –Arguments passed to every MVTools.flow call.
-
(degrain_args¶Mapping[str, Any] | None, default:None) –Arguments passed to every MVTools.degrain call.
-
(flow_interpolate_args¶Mapping[str, Any] | None, default:None) –Arguments passed to every MVTools.flow_interpolate call.
-
(flow_fps_args¶Mapping[str, Any] | None, default:None) –Arguments passed to every MVTools.flow_fps call.
-
(block_fps_args¶Mapping[str, Any] | None, default:None) –Arguments passed to every MVTools.block_fps call.
-
(flow_blur_args¶Mapping[str, Any] | None, default:None) –Arguments passed to every MVTools.flow_blur call.
-
(mask_args¶Mapping[str, Any] | None, default:None) –Arguments passed to every MVTools.mask call.
-
(sc_detection_args¶Mapping[str, Any] | None, default:None) –Arguments passed to every MVTools.sc_detection call.
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:
-
analyze_args(dict[str, Any]) –Arguments passed to every MVTools.analyze call.
-
block_fps_args(dict[str, Any]) –Arguments passed to every MVTools.block_fps call.
-
chroma– -
clip(VideoNode) –Clip to process.
-
compensate_args(dict[str, Any]) –Arguments passed to every MVTools.compensate call.
-
degrain_args(dict[str, Any]) –Arguments passed to every MVTools.degrain call.
-
fields– -
flow_args(dict[str, Any]) –Arguments passed to every MVTools.flow call.
-
flow_blur_args(dict[str, Any]) –Arguments passed to every MVTools.flow_blur call.
-
flow_fps_args(dict[str, Any]) –Arguments passed to every MVTools.flow_fps call.
-
flow_interpolate_args(dict[str, Any]) –Arguments passed to every MVTools.flow_interpolate call.
-
mask_args(dict[str, Any]) –Arguments passed to every MVTools.mask call.
-
pad– -
pel– -
recalculate_args(dict[str, Any]) –Arguments passed to every MVTools.recalculate call.
-
sc_detection_args(dict[str, Any]) –Arguments passed to every MVTools.sc_detection call.
-
search_clip– -
super_args(dict[str, Any]) –Arguments passed to every MVTools.super call.
-
tff– -
vectors(MotionVectors) –Motion vectors analyzed and used for all operations.
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 | |
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.
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.
flow_args instance-attribute ¶
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 ¶
Arguments passed to every MVTools.mask call.
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.
super_args instance-attribute ¶
super_args: dict[str, Any] = dict(super_args) if super_args else {}
Arguments passed to every MVTools.super call.
vectors instance-attribute ¶
vectors: MotionVectors = fallback(vectors, MotionVectors())
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 | |
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 | |
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 | |
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 | |
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 | |
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 | |
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 | |
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 | |
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 | |
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 | |
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 | |
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 | |