Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 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/TCanny.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/ColorFilter/Retinex/Retinex.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libsangnom.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/EEDI2.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/EEDI3m_opencl.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/ResizeFilter/nnedi3/NNEDI3CL.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DeinterlaceFilter/TIVTC/libtivtc.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/SourceFilter/LSmashSource/LSMASHSource.dll")
- # Import scripts
- import mvsfunc as mvf
- import masked
- import antiAliasing
- import SpotLess
- import validate
- # Source: 'C:\Users\Selur\Desktop\defect.avi'
- # Current color space: YUV420P8, bit depth: 8, resolution: 720x576, frame rate: 30fps, scanorder: telecine, yuv luminance scale: limited, matrix: 470bg, format: ULH0
- # Loading C:\Users\Selur\Desktop\defect.avi using LWLibavSource
- clip = core.lsmas.LWLibavSource(source="C:/Users/Selur/Desktop/defect.avi", format="YUV420P8", stream_index=0, cache=0, prefer_hw=0)
- 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_BT601), if it is not set.
- if validate.transferIsInvalid(clip):
- clip = core.std.SetFrameProps(clip=clip, _Transfer=vs.TRANSFER_BT601)
- # 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 30fps
- clip = core.std.AssumeFPS(clip=clip, fpsnum=30, fpsden=1)
- # making sure the detected scan type is set (detected: telecine)
- clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_TOP) # tff
- # converting interlaced to half-height progressive for filtering (vsSpotLess) (separate fields)
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P8, range_s="limited")
- clip = core.std.SeparateFields(clip, tff=False)
- clipEven = clip[::2] # resolution 720x288
- clipEven = core.std.SetFrameProps(clip=clipEven, _FieldBased=vs.FIELD_PROGRESSIVE) # progressive
- clipOdd = clip[1::2] # resolution 720x288
- clipOdd = core.std.SetFrameProps(clip=clipOdd, _FieldBased=vs.FIELD_PROGRESSIVE) # progressive
- # Spot removal using SpotLess
- clipEven = SpotLess.SpotLess(clip=clipEven, radT=3, pel=1, smoother="zsmooth")
- # Spot removal using SpotLess
- clipOdd = SpotLess.SpotLess(clip=clipOdd, radT=3, pel=1, smoother="zsmooth")
- # converting half-height progressive to interlacedbefore deinterlacing
- clip = core.std.Interleave([clipOdd, clipEven])
- clip = core.std.DoubleWeave(clip=clip, tff=False) # resolution 720x576
- clip = core.std.SelectEvery(clip, 2, 0)
- clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_TOP) # tff
- # Deinterlacing using TIVTC
- clip = core.tivtc.TFM(clip=clip, chroma=True)
- clip = core.tivtc.TDecimate(clip=clip, mode=7, rate=23.9760, dupThresh=0.04, vidThresh=3.50, sceneThresh=15.00)# new fps: 23.976
- # Making sure content is preceived as frame based
- clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # progressive
- # applying anti aliasing using santiag
- clip = antiAliasing.santiag(c=clip, strh=3, strv=3, nns=2, qual=2, pscrn=2, opencl=True)
- ## Starting applying 'EdgeMask (Retinex)' masked filtering for vsBasicVSRPPFilter
- clipMask = clip
- clipMask = core.resize.Bicubic(clip=clipMask, format=vs.RGBH, matrix_in_s="470bg", range_s="limited")
- clipMask = masked.retinex_edgemask(src=clipMask, sigma=1)
- clipMask = core.std.Maximum(clipMask)
- clipMask = core.std.BinarizeMask(clip=clipMask,threshold=30080)
- clipFiltered = clip
- # adjusting color space from YUV444P8 to RGBH for vsBasicVSRPPFilter
- clipFiltered = core.resize.Bicubic(clip=clipFiltered, format=vs.RGBH, matrix_in_s="470bg", range_s="limited")
- # Quality enhancement using BasicVSR++
- from vsbasicvsrpp import basicvsrpp as BasicVSRPP
- clipFiltered = BasicVSRPP(clip=clipFiltered, model=4)
- clipMask = core.std.BinarizeMask(clip=clipMask,threshold=30080)
- clipFiltered = core.resize.Bicubic(clip=clipFiltered, format=vs.RGBS, range_s="limited")
- clip = core.resize.Bicubic(clip=clip, format=vs.RGBS, matrix_in_s="470bg", range_s="limited")
- clipMask = core.resize.Bicubic(clip=clipMask, format=vs.GRAYS, range_s="limited")
- clip = core.std.MaskedMerge(clip, clipFiltered, clipMask) # RetinexEdgeMask
- ## Finished applying 'RetinexEdgeMask' masked filtering for vsBasicVSRPPFilter
- # adjusting output color from: RGBS to YUV420P10 for NVEncModel
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, matrix_s="470bg", 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()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement