lvsfunc.misc

Miscellaneous functions and wrappers that don’t really have a place elsewhere.

lvsfunc.misc.edgefixer(clip[, left, right, ...])

A wrapper for ContinuityFixer (https://github.com/MonoS/VS-ContinuityFixer).

lvsfunc.misc.limit_dark(clip, filtered[, ...])

Replaces frames in a clip with a filtered clip when the frame's darkness exceeds the threshold.

lvsfunc.misc.overlay_sign(clip, overlay[, ...])

Wrapper to overlay a logo or sign onto another clip.

lvsfunc.misc.shift_tint(clip[, values])

A function for forcibly adding pixel values to a clip.

lvsfunc.misc.source(file[, ref, ...])

Generic clip import function.

lvsfunc.misc.unsharpen(clip[, strength, ...])

Diff'd unsharpening function.

lvsfunc.misc.wipe_row(clip[, ref, pos, ...])

Simple function to wipe a row or column with a blank clip.

lvsfunc.misc.edgefixer(clip, left=None, right=None, top=None, bottom=None, radius=None, full_range=False)

A wrapper for ContinuityFixer (https://github.com/MonoS/VS-ContinuityFixer).

Fixes the issues with over- and undershoot that it may create when fixing the edges, and adds what are in my opinion “more sane” ways of handling the parameters and given values.

…If possible, you should be using bbmod instead, though.

Alias for this function is lvsfunc.ef.

Warning

This function may be rewritten in the future, and functionality may change!

Dependencies:

  • VS-ContinuityFixer

Parameters
  • clip (VideoNode) – Input clip

  • left (Union[int, List[int], None]) – Number of pixels to fix on the left (Default: None)

  • right (Union[int, List[int], None]) – Number of pixels to fix on the right (Default: None)

  • top (Union[int, List[int], None]) – Number of pixels to fix on the top (Default: None)

  • bottom (Union[int, List[int], None]) – Number of pixels to fix on the bottom (Default: None)

  • radius (Optional[List[int]]) – Radius for edgefixing (Default: None)

  • full_range (bool) – Does not run the expression over the clip to fix over/undershoot (Default: False)

Return type

VideoNode

Returns

Clip with fixed edges

lvsfunc.misc.limit_dark(clip, filtered, threshold=0.25, threshold_range=None)

Replaces frames in a clip with a filtered clip when the frame’s darkness exceeds the threshold. This way you can run lighter (or heavier) filtering on scenes that are almost entirely dark.

There is one caveat, however: You can get scenes where every other frame is filtered rather than the entire scene. Please do take care to avoid that if possible.

Parameters
  • clip (VideoNode) – Input clip

  • filtered (VideoNode) – Filtered clip

  • threshold (float) – Threshold for frame averages to be filtered (Default: 0.25)

  • threshold_range (Optional[int]) – Threshold for a range of frame averages to be filtered (Default: None)

Return type

VideoNode

Returns

Conditionally filtered clip

lvsfunc.misc.overlay_sign(clip, overlay, frame_ranges=None, fade_length=0, matrix=None)

Wrapper to overlay a logo or sign onto another clip. Rewrite of fvsfunc.InsertSign. This wrapper also allows you to set fades to fade a logo in and out.

Dependencies:

  • vs-imwri

Optional Dependencies:

  • kagefunc

Parameters
  • clip (vs.VideoNode) – Input clip.

  • overlay (vs.VideoNode | str) – Sign or logo to overlay. Must be the png loaded in through imwri.Read() or a path string to the image file, and MUST be the same dimensions as the input clip.

  • frame_ranges (Range | List[Range] | None) – Frame ranges or starting frame to apply the overlay to. See types.Range for more info. If None, overlays the entire clip. If a Range is passed, the overlaid clip will only show up inside that range. If only a single integer is given, it will start on that frame and stay until the end of the clip. Note that this function only accepts a single Range! You can’t pass a list of them!

  • fade_length (int) – Length to fade the clips into each other. The fade will start and end on the frames given in frame_ranges. If set to 0, it won’t fade and the sign will simply pop in.

  • matrix (Matrix | int | None) – Enum for the matrix of the input clip. See types.Matrix for more info. If not specified, gets matrix from the “_Matrix” prop of the clip unless it’s an RGB clip, in which case it stays as None.

Return type

vs.VideoNode

Returns

Clip with a logo or sign overlaid on top for the given frame ranges, either with or without a fade.

lvsfunc.misc.shift_tint(clip, values=16)

A function for forcibly adding pixel values to a clip. Can be used to fix green tints in Crunchyroll sources, for example. Only use this if you know what you’re doing!

This function accepts a single integer or a list of integers. Values passed should mimic those of an 8bit clip. If your clip is not 8bit, they will be scaled accordingly.

If you only pass 1 value, it will copied to every plane. If you pass 2, the 2nd one will be copied over to the 3rd. Don’t pass more than three.

Parameters
  • clip (VideoNode) – Input clip

  • values (Union[int, Sequence[int]]) – Value added to every pixel, scales accordingly to your clip’s depth (Default: 16)

Return type

VideoNode

Returns

Clip with pixel values added

lvsfunc.misc.source(file, ref=None, force_lsmas=False, mpls=False, mpls_playlist=0, mpls_angle=0, **index_args)

Generic clip import function. Automatically determines if ffms2 or L-SMASH should be used to import a clip, but L-SMASH can be forced. It also automatically determines if an image has been imported. You can set its fps using ‘fpsnum’ and ‘fpsden’, or using a reference clip with ‘ref’.

Alias for this function is lvsfunc.src.

Warning

WARNING: This function will be rewritten in the future, and functionality may change!
No warning is currently printed for this in your terminal to avoid spam.

Dependencies:

  • ffms2

  • L-SMASH-Works (optional: m2ts sources or when forcing lsmas)

  • d2vsource (optional: d2v sources)

  • dgdecodenv (optional: dgi sources)

  • VapourSynth-ReadMpls (optional: mpls sources)

Parameters
  • file (str) – Input file. This MUST have an extension.

  • ref (vs.VideoNode | None) – Use another clip as reference for the clip’s format, resolution, and framerate (Default: None).

  • force_lsmas (bool) – Force files to be imported with L-SMASH (Default: False)

  • mpls (bool) – Load in a mpls file (Default: False).

  • mpls_playlist (int) – Playlist number, which is the number in mpls file name (Default: 0).

  • mpls_angle (int) – Angle number to select in the mpls playlist (Default: 0).

  • kwargs – Arguments passed to the indexing filter.

Return type

vs.VideoNode

Returns

Vapoursynth clip representing input file.

lvsfunc.misc.unsharpen(clip, strength=1.0, sigma=1.5, prefilter=True, prefilter_sigma=0.75)

Diff’d unsharpening function. Performs one-dimensional sharpening as such: “Original + (Original - blurred) * Strength” It then merges back noise and detail that was prefiltered away,

Negative values will blur instead. This can be useful for trying to undo sharpening.

This function is not recommended for normal use, but may be useful as prefiltering for detail- or edgemasks.

Parameters
  • clip (VideoNode) – Input clip.

  • strength (float) – Amount to multiply blurred clip with original clip by. Negative values will blur the clip instead.

  • sigma (float) – Sigma for the gaussian blur.

  • prefilter (bool) – Pre-denoising to prevent the unsharpening from picking up random noise.

  • prefilter_sigma (float) – Strength for the pre-denoising.

  • show_mask – Show halo mask.

Return type

VideoNode

Returns

Unsharpened clip

lvsfunc.misc.wipe_row(clip, ref=None, pos=(1, 1), size=None, show_mask=False)

Simple function to wipe a row or column with a blank clip. You can also give it a different clip to replace a row with.

Parameters
  • clip (vs.VideoNode) – Input clip

  • secondary – Clip to replace wiped rows with (Default: None)

  • width – Width of row (Default: 1)

  • height – Height of row (Default: 1)

  • offset_x – X-offset of row (Default: 0)

  • offset_y – Y-offset of row (Default: 0)

Return type

vs.VideoNode

Returns

Clip with given rows or columns wiped