lvsfunc.comparison
Comparison and analysis functions and wrappers.
|
Allows for the same frames from two different clips to be compared by interleaving them into a single clip. |
Creates a standard |
|
|
Diff func for |
|
Small convenience function for interleaving clips. |
|
Small convenience function for splitting clips along the x-axis and then stacking. |
|
A simple wrapper that allows you to compare two clips by stacking them. |
|
Small convenience function for stacking clips horizontally. |
|
Stacks the planes of a clip. |
|
Small convenience function for stacking clips vertically. |
|
Small convenience function for tiling clips in a rectangular pattern. |
- class lvsfunc.comparison.Comparer(clips, /, *, label_alignment=7)
Bases:
abc.ABC
Base class for comparison functions.
- Parameters
clips (
Union
[Dict
[str
,VideoNode
],Sequence
[VideoNode
]]) – A dict mapping names to clips or simply a sequence of clips in a tuple or a list. If given a dict, the names will be overlaid on the clips usingVideoNode.text.Text
. If given a simple sequence of clips, the label_alignment parameter will have no effect and the clips will not be labeled. The order of the clips in either a dict or a sequence will be kept in the comparison.label_alignment (
int
) – An integer from 1-9, corresponding to the positions of the keys on a numpad. Only used if clips is a dict. Determines where to place clip name usingVideoNode.text.Text
(Default: 7)
- property clip: vapoursynth.VideoNode
Returns the comparison as a single VideoNode for further manipulation or attribute inspection.
comp_clip = Comparer(...).clip
is the intended use in encoding scripts.- Return type
VideoNode
- class lvsfunc.comparison.Interleave(clips, /, *, label_alignment=7)
Bases:
lvsfunc.comparison.Comparer
From the VapourSynth documentation: Returns a clip with the frames from all clips interleaved. For example, Interleave(A=clip1, B=clip2) will return A.Frame 0, B.Frame 0, A.Frame 1, B.Frame 1, …
Acts as a convenience combination function of
vapoursynth.core.text.Text
andvapoursynth.core.std.Interleave
.- Parameters
clips (
Union
[Dict
[str
,VideoNode
],Sequence
[VideoNode
]]) – A dict mapping names to clips or simply a sequence of clips in a tuple or a list. If given a dict, the names will be overlaid on the clips usingVideoNode.text.Text
. If given a simple sequence of clips, the label_alignment parameter will have no effect and the clips will not be labeled. The order of the clips in either a dict or a sequence will be kept in the comparison.label_alignment (
int
) – An integer from 1-9, corresponding to the positions of the keys on a numpad. Only used if clips is a dict. Determines where to place clip name usingVideoNode.text.Text
(Default: 7)
- class lvsfunc.comparison.Split(clips, /, *, direction=Direction.HORIZONTAL, label_alignment=7)
Bases:
lvsfunc.comparison.Stack
Split an unlimited amount of clips into one VideoNode with the same dimensions as the original clips. Handles odd-sized resolutions or resolutions that can’t be evenly split by the amount of clips specified.
The remaining pixel width/height (
clip.dimension % number_of_clips
) will be always given to the last clip specified. For example, five 104 x 200 clips will result in a ((20 x 200) * 4) + (24 x 200) horiztonal stack of clips.- Parameters
clips (
Union
[Dict
[str
,VideoNode
],Sequence
[VideoNode
]]) – A dict mapping names to clips or simply a sequence of clips in a tuple or a list. If given a dict, the names will be overlaid on the clips usingVideoNode.text.Text
. If given a simple sequence of clips, the label_alignment parameter will have no effect and the clips will not be labeled. The order of the clips in either a dict or a sequence will be kept in the comparison.direction (
Direction
) – Determines the axis to split the clips on (Default:lvsfunc.comparison.Direction.HORIZONTAL
)label_alignment (
int
) – An integer from 1-9, corresponding to the positions of the keys on a numpad. Only used if clips is a dict. Determines where to place clip name usingVideoNode.text.Text
(Default: 7)
- class lvsfunc.comparison.Stack(clips, /, *, direction=Direction.HORIZONTAL, label_alignment=7)
Bases:
lvsfunc.comparison.Comparer
Stacks clips horizontally or vertically.
Acts as a convenience combination function of
vapoursynth.core.text.Text
and eithervapoursynth.core.std.StackHorizontal
orvapoursynth.core.std.StackVertical
.- Parameters
clips (
Union
[Dict
[str
,VideoNode
],Sequence
[VideoNode
]]) – A dict mapping names to clips or simply a sequence of clips in a tuple or a list. If given a dict, the names will be overlaid on the clips usingVideoNode.text.Text
. If given a simple sequence of clips, the label_alignment parameter will have no effect and the clips will not be labeled. The order of the clips in either a dict or a sequence will be kept in the comparison.direction (
Direction
) – Direction of the stack (Default:lvsfunc.comparison.Direction.HORIZONTAL
)label_alignment (
int
) – An integer from 1-9, corresponding to the positions of the keys on a numpad. Only used if clips is a dict. Determines where to place clip name usingVideoNode.text.Text
(Default: 7)
- class lvsfunc.comparison.Tile(clips, /, *, arrangement=None, label_alignment=7)
Bases:
lvsfunc.comparison.Comparer
Tiles clips in a mosaic manner, filling rows first left-to-right, then stacking.
The arrangement of the clips can be specified with the arrangement parameter. Rows are specified as lists of ints inside of a larger list specifying the order of the rows. Think of this as a 2-dimensional array of 0s and 1s with 0 representing an empty slot and 1 representing the next clip in the sequence.
If arrangement is not specified, the function will attempt to fill a square with dimensions n x n where n is equivalent to
math.ceil(math.sqrt(len(clips))
. The bottom rows will be dropped if empty.# For example, for 3 clips, the automatic arrangement becomes: [ [1, 1], [1, 0] ] # For 10 clips, the automatic arrangement becomes: [ [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 0, 0] ] # For custom arrangements, such as (for 4 clips): [ [0, 1, 0, 1], [1], [0, 1] ] # the rows will be auto-padded with 0's to be the same length.
- Parameters
clips (
Union
[Dict
[str
,VideoNode
],Sequence
[VideoNode
]]) – A dict mapping names to clips or simply a sequence of clips in a tuple or a list. If given a dict, the names will be overlaid on the clips usingVideoNode.text.Text
. If given a simple sequence of clips, the label_alignment parameter will have no effect and the clips will not be labeled. The order of the clips in either a dict or a sequence will be kept in the comparison.arrangement (
Optional
[List
[List
[int
]]]) – 2-dimension array (list of lists) of 0s and 1s representing a list of rows of clips(1) or blank spaces(0) (Default:None
)label_alignment (
int
) – An integer from 1-9, corresponding to the positions of the keys on a numpad. Only used if clips is a dict. Determines where to place clip name usingVideoNode.text.Text
(Default: 7)
- lvsfunc.comparison.compare(clip_a, clip_b, frames=None, rand_total=None, force_resample=True, print_frame=True, mismatch=False)
Allows for the same frames from two different clips to be compared by interleaving them into a single clip. Clips are automatically resampled to 8 bit YUV -> RGB24 to emulate how a monitor shows the frame. This can be disabled by setting force_resample to
False
.This is not recommended over setting multiple outputs and checking between those, but in the event that is unavailable to you, this function may be useful.
Alias for this function is lvsfunc.comp.
- Parameters
clip_a (
VideoNode
) – Clip to compareclip_b (
VideoNode
) – Second clip to compareframes (
Optional
[List
[int
]]) – List of frames to compare (Default:None
)rand_total (
Optional
[int
]) – Number of random frames to pick (Default:None
)force_resample (
bool
) – Forcibly resamples the clip to RGB24 (Default:True
)print_frame (
bool
) – Print frame numbers (Default:True
)mismatch (
bool
) – Allow for clips with different formats and dimensions to be compared (Default:False
)
- Return type
VideoNode
- Returns
Interleaved clip containing specified frames from clip_a and clip_b
- lvsfunc.comparison.diff(*clips: vapoursynth.VideoNode, thr: float = 72, height: int = 288, interleave: bool = False, return_ranges: typing.Literal[True] = 'True', exclusion_ranges: typing.Optional[typing.Sequence[typing.Union[int, typing.Tuple[int, int]]]] = None, diff_func: typing.Callable[[vapoursynth.VideoNode, vapoursynth.VideoNode], vapoursynth.VideoNode] = <function <lambda>>, **namedclips: vapoursynth.VideoNode) Tuple[vapoursynth.VideoNode, List[Tuple[int, int]]]
- lvsfunc.comparison.diff(*clips: vapoursynth.VideoNode, thr: float = 72, height: int = 288, interleave: bool = False, return_ranges: typing.Literal[False], exclusion_ranges: typing.Optional[typing.Sequence[typing.Union[int, typing.Tuple[int, int]]]] = None, diff_func: typing.Callable[[vapoursynth.VideoNode, vapoursynth.VideoNode], vapoursynth.VideoNode] = <function <lambda>>, **namedclips: vapoursynth.VideoNode) vapoursynth.VideoNode
Creates a standard
lvsfunc.comparison.Stack
between frames from two clips that have differences. Useful for making comparisons between TV and BD encodes, as well as clean and hardsubbed sources.There are two methods used here to find differences: If thr is below 1, PlaneStatsDiff is used to figure out the differences. Else, if thr is equal than or higher than 1, PlaneStatsMin/Max are used.
Recommended is PlaneStatsMin/Max, as those seem to catch more outrageous differences without returning too many starved frames.
Note that this might catch artifacting as differences! Make sure you verify every frame with your own eyes!
Alias for this function is lvsfunc.diff.
- Parameters
clips (
VideoNode
) – Clips for comparison (order is kept)namedclips (
VideoNode
) – Keyword arguments of name=clip for all clips in the comparison. Clips will be labeled at the top left with their name.thr (
float
) – Threshold, <= 1 uses PlaneStatsDiff, > 1 uses Max/Min. Higher values will catch more differences. Value must be lower than 128height (
int
) – Height in px to downscale clips to if interleave isFalse
(MakeDiff clip will be twice this resolution)interleave (
bool
) – Return clip as an interleaved comparison (usinglvsfunc.comparison.Interleave
). This will not return a diff clipreturn_ranges (
bool
) – Return a list of ranges in addition to the comparison clipexclusion_ranges (
Optional
[Sequence
[Union
[int
,Tuple
[int
,int
]]]]) – Excludes a list of frame ranges from difference checking output (but not processing)diff_func (
Callable
[[VideoNode
,VideoNode
],VideoNode
]) – Function for calculating diff in PlaneStatsMin/Max mode
- Return type
Union
[VideoNode
,Tuple
[VideoNode
,List
[Tuple
[int
,int
]]]]- Returns
Either an interleaved clip of the differences between the two clips or a stack of both input clips on top of MakeDiff clip. Furthermore, the function will print the ranges of all the diffs found.
- lvsfunc.comparison.diff_hardsub_mask(a, b, **kwargs)
Diff func for
lvsfunc.comparison.diff()
to use a hardsub mask. This is kinda slow.- Parameters
a (
VideoNode
) – Clip Ab (
VideoNode
) – Clip B
- Return type
VideoNode
- Returns
Diff masked with
lvsfunc.dehardsub.hardsub_mask()
- lvsfunc.comparison.interleave(*clips, **namedclips)
Small convenience function for interleaving clips.
- Parameters
clips (
VideoNode
) – Clips for comparison (order is kept)namedclips (
VideoNode
) – Keyword arguments of name=clip for all clips in the comparison. Clips will be labeled at the top left with their name.
- Return type
VideoNode
- Returns
An interleaved clip of all the clips/namedclips specified
- lvsfunc.comparison.split(*clips, **namedclips)
Small convenience function for splitting clips along the x-axis and then stacking. Accounts for odd-resolution clips by giving overflow columns to the last clip specified. All clips must have the same dimensions (width and height).
- Parameters
clips (
VideoNode
) – Clips for comparison (order is kept left to right)namedclips (
VideoNode
) – Keyword arguments of name=clip for all clips in the comparison. Clips will be labeled at the bottom with their name.
- Return type
VideoNode
- Returns
A clip with the same dimensions as any one of the input clips with all clips/namedclips represented as individual vertical slices.
- lvsfunc.comparison.stack_compare(*clips, make_diff=True, height=None)
A simple wrapper that allows you to compare two clips by stacking them.
Best to use when trying to match two sources frame-accurately. Alias for this function is lvsfunc.scomp.
When not using make_diff, Stack is heavily recommended instead.
- Parameters
clips (
VideoNode
) – Clips to comparemake_diff (
bool
) – Create and stack a diff (only works if two clips are given) (Default:True
)height (
Optional
[int
]) – Height in px to rescale clips to if make_diff isTrue
(MakeDiff clip will be twice this resolution). This function will not scale above the first clip’s height (Default: 288).
- Return type
VideoNode
- Returns
Clip with clips stacked
- lvsfunc.comparison.stack_horizontal(*clips, **namedclips)
Small convenience function for stacking clips horizontally.
- Parameters
clips (
VideoNode
) – Clips for comparison (order is kept left to right)namedclips (
VideoNode
) – Keyword arguments of name=clip for all clips in the comparison. Clips will be labeled at the top left with their name.
- Return type
VideoNode
- Returns
A horizontal stack of the clips/namedclips
- lvsfunc.comparison.stack_planes(clip, /, stack_vertical=False)
Stacks the planes of a clip. For 4:2:0 subsampled clips, the two half-sized planes will be stacked in the opposite direction specified (vertical by default), then stacked with the full-sized plane in the direction specified (horizontal by default).
- Parameters
clip (
VideoNode
) – Input clip (must be in YUV or RGB planar format)stack_vertical (
bool
) – Stack the planes vertically (Default:False
)
- Return type
VideoNode
- Returns
Clip with stacked planes
- lvsfunc.comparison.stack_vertical(*clips, **namedclips)
Small convenience function for stacking clips vertically.
- Parameters
clips (
VideoNode
) – Clips for comparison (order is kept top to bottom)namedclips (
VideoNode
) – Keyword arguments of name=clip for all clips in the comparison. Clips will be labeled at the top left with their name.
- Return type
VideoNode
- Returns
A vertical stack of the clips/namedclips
- lvsfunc.comparison.tile(*clips, **namedclips)
Small convenience function for tiling clips in a rectangular pattern. All clips must have the same dimensions (width and height). If 3 clips are given, a 2x2 square with one blank slot will be returned. If 6 clips are given, a 3x2 rectangle will be returned.
- Parameters
clips (
VideoNode
) – Clips for comparisonnamedclips (
VideoNode
) – Keyword arguments of name=clip for all clips in the comparison. Clips will be labeled at the top left with their name.
- Return type
VideoNode
- Returns
A clip with all input clips/namedclips automatically tiled most optimally into a rectangular arrrangement