DVD-specific Magic


Automatically fixes chroma shifts, at the very least by approximation.


Conversion from DVD squeeze to glorious 4:3 by vertically resizing.


Conversion from DVD squeeze to glorious 4:3 by horizontally resizing.

Functions written specifically for issues common or exclusive to DVDs.

DVDs, ancient as the specs and carriers are, come with their fair share of typical issues. Some of the more well-known problems are things like getting telecined before editing, chroma shifts that change from scene to scene and other grievances that stem from processing the things in several steps or by several subcontractors. They’re generally a pain in the ass and this module exists to alleviate some of that pain.

class rvsfunc.dvd.Region(value)

Bases: Enum

An enum for specifying regional coding standards.

This enum specifies the regional standards used for TV and DVD material. The PAL and SECAM systems do not have any notable difference with regards to (inverse) telecining, cropping, resizing and other size ratios, but they do follow different standards for analog processing and it _might_ mean slightly different primaries and an alternate white point as defined in BT.407/601 (BG).

Will be expanded upon to include variations of the standards like PAL-M and NTSC-J at some point. Will also be moved to a utility package at some point.

NTSC = 1
PAL = 2
rvsfunc.dvd.chromashifter(clip, wthresh=31, vertical=False, maskfunc=eoe_convolution, mask_kwargs={}, shifter=core.resize.Bicubic)

Automatically fixes chroma shifts, at the very least by approximation.

This function takes in a clip and scales it to a 4x larger YUV444P clip. It then generates edgemasks over all of the planes to be used in distance calculations to figure out the proper value to shift chroma with. The shift is applied to the otherwise untouched input clip. Assumes the shift is the same for the U and V planes. Actually fast now thanks to EoE :eoehead:

  • clip (VideoNode) – vs.VideoNode: The clip to process. This may take a while.

  • wthresh (int) – int: The threshold for white values to use in the calculations for proper shifting. Valid values are 1 through 255.

  • vertical (bool) – bool: Whether or not to perform the shift vertically. This internally calls core.std.Transpose so that horizontal logic can be applied for speed.

  • maskfunc (Callable[[VideoNode], VideoNode]) – Callable A custom function or plugin to call for the edgemask. Default core.std.Prewitt.

  • mask_kwargs (Dict) – Dict A dictionary of kwargs to be expanded for mask_func. If defaults are used, this will be padded with Prewitt’s planes arg to ensure all planes get a mask generated over them.

  • shifter (Callable[[VideoNode, Any], VideoNode]) – Callable: The function to perform the chromashift with, defaults to core.resize.Point. This MUST take the clip as its first positional argument and a kwarg named src_left. Wrap your callable if it doesn’t meet these requirements to prevent errors.

Return type



vs.VideoNode: The input clip, but without chroma shift.

rvsfunc.dvd.square43PAR(clip, region=Region.UNKNOWN, scaler=None, ntsc_down=False)

A function to resize non-square PAR to square PAR in the cleanest way possible.

Fixing PAR is hell and doing so is NEVER recommended! Unless a project has constraints that require you to, in which case having a function that follows the proper standards is a very nice thing to have.

This function expects IVTC’d or deinterlaced video that has no other resizing or modification applied to it. As such, it does not yet handle input resolutions other than 704x480, 720x480, 704x486, 720x486, 768x576, or 720x576. Support for arbitrary resolutions will be added soon!

Resamples video to make sure the resulting PAR is 1:1 again, or as close as possible given the circumstances. It does this through stretching the undersampled dimension rather than squeezing the other, in an attempt to prevent loss of data. For NTSC with 640x480 resolutions, a boolean flag is available to downsample the width instead, although this is not recommended. For reference, media players don’t honor these resolutions either, they stretch as well. If the resulting resolution is fractional, it will be rounded to the nearest legal integer value, which means there will never be more than 1px difference between a perfect 1:1 PAR and the result. If the input video has subsampling applied, odd values are considered the same as fractional, and it will be resized to Res - 1 instead.

  • clip (VideoNode) – Input video node that needs its PAR corrected.

  • region (Region) – The coding standards region to use, one of the values available in the Region enum.

  • scaler (Optional[Callable[[VideoNode, int, int], VideoNode]]) –

    Optional scaling function to use. Defaults to Catmull-Rom (Bicubic, b=0, c=0.5) and no custom arguments are supported, so it’s recommended to use a wrapped callable. Called as scaler(clip, width, height) where:

    • clip: vs.VideoNode

    • width: int

    • height: int

    • returning vs.VideoNode

Return type