def to_gray(clip: vs.VideoNode, ref: vs.VideoNode) -> vs.VideoNode: clip = core.std.AssumeFPS(clip, ref) return core.resize.Point(clip, format=vs.GRAY16, matrix_s=mvf.GetMatrix(ref))
def _resample(clip: vs.VideoNode) -> vs.VideoNode: # Resampling to 8bit and RGB to properly display how it appears on your screen return util.resampler( clip.resize.Point(format=vs.RGB24, matrix_in_s=mvf.GetMatrix(clip)), 8)
def source(file: str, ref: vs.VideoNode = None, force_lsmas: bool = False, mpls: bool = False, mpls_playlist: int = 0, mpls_angle: int = 0) -> vs.VideoNode: funcname = "source" """ 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'. :param file: str: OS absolute file location :param ref: vs.VideoNode: Use another clip as reference for the clip's format, resolution, and framerate :param force_lsmas: bool: Force files to be imported with L-SMASH :param mpls: bool: Load in a mpls file :param mpls_playlist: int: Playlist number, which is the number in mpls file name :param mpls_angle: int: Angle number to select in the mpls playlist """ # TODO: Consider adding kwargs for additional options, # find a way to NOT have to rely on a million elif's if file.startswith('file:///'): file = file[8::] # Error handling for some file types if file.endswith('.mpls') and mpls is False: return error(funcname, 'Please set \'mpls = True\' and give a path to the base Blu-ray directory when trying to load in mpls files') if file.endswith('.vob') or file.endswith('.ts'): return error(funcname, 'Please index VOB and TS files into d2v files before importing them') if force_lsmas: return core.lsmas.LWLibavSource(file) elif mpls: mpls = core.mpls.Read(file, mpls_playlist) clip = core.std.Splice([core.lsmas.LWLibavSource(mpls['clip'][i]) for i in range(mpls['count'])]) elif file.endswith('.d2v'): clip = core.d2v.Source(file) elif file.endswith('.dgi'): clip = core.dgdecodenv.DGSource(file) elif is_image(file): clip = core.imwri.Read(file) else: if file.endswith('.m2ts'): clip = core.lsmas.LWLibavSource(file) else: clip = core.ffms2.Source(file) if ref: clip = core.std.AssumeFPS(clip, fpsnum=ref.fps.numerator, fpsden=ref.fps.denominator) clip = core.resize.Bicubic(clip, width=ref.width, height=ref.height, format=ref.format, matrix_s=mvf.GetMatrix(ref)) if is_image(file): clip = clip*(ref.num_frames-1) return clip
def source(file: str, ref: Optional[vs.VideoNode] = None, force_lsmas: bool = False, mpls: bool = False, mpls_playlist: int = 0, mpls_angle: int = 0) -> vs.VideoNode: """ 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'. Dependencies: * d2vsource (optional: d2v sources) * dgdecodenv (optional: dgi sources) * mvsfunc (optional: reference clip mode) * vapoursynth-readmpls (optional: mpls sources) :param file: Input file :param ref: Use another clip as reference for the clip's format, resolution, and framerate (Default: None) :param force_lsmas: Force files to be imported with L-SMASH (Default: False) :param mpls: Load in a mpls file (Default: False) :param mpls_playlist: Playlist number, which is the number in mpls file name (Default: 0) :param mpls_angle: Angle number to select in the mpls playlist (Default: 0) :return: Vapoursynth clip representing input file """ # TODO: Consider adding kwargs for additional options, # find a way to NOT have to rely on a million elif's if file.startswith('file:///'): file = file[8::] # Error handling for some file types if file.endswith('.mpls') and mpls is False: raise ValueError( f"source: 'Please set \"mpls = True\" and give a path to the base Blu-ray directory when trying to load in mpls files'" ) if file.endswith('.vob') or file.endswith('.ts'): raise ValueError( f"source: 'Please index VOB and TS files with d2v before importing them'" ) if force_lsmas: return core.lsmas.LWLibavSource(file) elif mpls: mpls = core.mpls.Read(file, mpls_playlist) clip = core.std.Splice([ core.lsmas.LWLibavSource(mpls['clip'][i]) for i in range(mpls['count']) ]) elif file.endswith('.d2v'): clip = core.d2v.Source(file) elif file.endswith('.dgi'): clip = core.dgdecodenv.DGSource(file) elif is_image(file): clip = core.imwri.Read(file) else: if file.endswith('.m2ts'): clip = core.lsmas.LWLibavSource(file) else: clip = core.ffms2.Source(file) if ref: try: import mvsfunc as mvf except ModuleNotFoundError: raise ModuleNotFoundError("source: missing dependency 'mvsfunc'") clip = core.std.AssumeFPS(clip, fpsnum=ref.fps.numerator, fpsden=ref.fps.denominator) clip = core.resize.Bicubic(clip, width=ref.width, height=ref.height, format=ref.format, matrix_s=mvf.GetMatrix(ref)) if is_image(file): clip = clip * (ref.num_frames - 1) return clip