# Imports import vapoursynth as vs # getting Vapoursynth core import sys import os core = vs.core # Import scripts folder scriptPath = 'F:/Hybrid/64bit/vsscripts' sys.path.insert(0, os.path.abspath(scriptPath)) # loading plugins core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libvs_placebo.dll") core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/fmtconv.dll") core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/ZSmooth/zsmooth.dll") core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libmvtools.dll") core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DeinterlaceFilter/TIVTC/libtivtc.dll") core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV.dll") # Import scripts import SpotLess import chromashift import validate # Source: 'C:\Users\Selur\Desktop\sample_trl.mkv' # Current color space: YUV420P8, bit depth: 8, resolution: 710x478, frame rate: 29.97fps, scanorder: telecine, yuv luminance scale: limited, matrix: 470bg, transfer: bt.709, primaries: bt.601 ntsc, format: AVC # Loading C:\Users\Selur\Desktop\sample_trl.mkv using DGSource clip = core.dgdecodenv.DGSource("J:/tmp/mkv_cd34fe4da5196d637036f10fbbe5a14b_853323747.dgi",fieldop=0)# 29.97 fps, scanorder: telecine frame = clip.get_frame(0) # setting color matrix to 470bg. clip = core.std.SetFrameProps(clip, _Matrix=vs.MATRIX_BT470_BG) # setting color transfer (vs.TRANSFER_BT709), if it is not set. if validate.transferIsInvalid(clip): clip = core.std.SetFrameProps(clip=clip, _Transfer=vs.TRANSFER_BT709) # setting color primaries info (to vs.PRIMARIES_BT470_BG), if it is not set. if validate.primariesIsInvalid(clip): clip = core.std.SetFrameProps(clip=clip, _Primaries=vs.PRIMARIES_BT470_BG) # setting color range to TV (limited) range. clip = core.std.SetFrameProps(clip=clip, _ColorRange=vs.RANGE_LIMITED) # making sure frame rate is set to 29.97fps clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001) # making sure the detected scan type is set (detected: telecine) clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_TOP) # tff # Deinterlacing using TIVTC clip = core.tivtc.TFM(clip=clip) clip = core.tivtc.TDecimate(clip=clip)# new fps: 23.976 # Making sure content is preceived as frame based clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # progressive # Chroma adjustment using ChromaShiftSP clip = chromashift.ChromaShiftSP(clip=clip, X=2.50, jeh=False) # Spot removal using SpotLess clip = SpotLess.SpotLess(clip=clip, radT=3, pel=1, smoother="zsmooth") clip = core.std.Crop(clip=clip, left=2, right=4, top=0, bottom=0)# cropping to 704x478 clip = core.std.AddBorders(clip=clip, left=0, right=0, top=0, bottom=2) # add borders to archive mod 8 (vsBasicVSRPPFilter) - 704x480 # adjusting color space from YUV420P8 to RGBH for vsBasicVSRPPFilter clip = core.resize.Bicubic(clip=clip, format=vs.RGBH, matrix_in_s="470bg", range_s="limited") # Quality enhancement using BasicVSR++ from vsbasicvsrpp import basicvsrpp as BasicVSRPP clip = BasicVSRPP(clip=clip, model=4) clip = core.std.Crop(clip=clip, left=0, right=0, top=0, bottom=2) # removing borders (vsBasicVSRPPFilter) - 704x478 # Resizing using 10 - bicubic spline clip = core.resize.Bicubic(clip=clip, format=vs.RGBS, range_s="limited") clip = core.fmtc.resample(clip=clip, kernel="spline16", w=720, h=550, interlaced=False, interlacedd=False) # resolution 720x550 # adjusting color space from RGBS to YUV444P16 for vsGLSLFilmGrain clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="470bg", range_s="limited", dither_type="error_diffusion") with open("F:/Hybrid/64bit/vsfilters/GLSL/parameterized/filmgrain.glsl") as glslf: glsl = glslf.read() glsl = glsl.replace('#define INTENSITY 0.05', '#define INTENSITY 0.01') clip = core.placebo.Shader(clip=clip, shader_s=glsl, width=clip.width, height=clip.height) # adjusting output color from: YUV444P16 to YUV420P10 for NVEncModel clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, range_s="limited", dither_type="error_diffusion") # set output frame rate to 23.976fps (progressive) clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001) # output clip.set_output()