Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Imports
- import ctypes
- import os
- import sys
- # Import site-packages
- sys.path.append("F:/Hybrid/64bit/Vapoursynth/Lib/site-packages")
- import vapoursynth as vs
- # getting Vapoursynth core
- core = vs.core
- # Limit frame cache to 48449MB
- core.max_cache_size = 48449
- # Import scripts folder
- scriptPath = 'F:/Hybrid/64bit/vsscripts'
- sys.path.insert(0, os.path.abspath(scriptPath))
- # Loading Support Files
- Dllref = ctypes.windll.LoadLibrary("F:/Hybrid/64bit/vsfilters/Support/libfftw3f-3.dll")
- # loading plugins
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/ResizeFilter/RealCUGAN/realcugannv.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DerainbowFilter/SmoothUV/libsmoothuv.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/GrainFilter/AddGrain/AddGrain.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/NEO_FFT3DFilter/neo-fft3d.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/DFTTest/DFTTest.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/EEDI3m_opencl.dll") # vsQTGMC
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/ResizeFilter/nnedi3/NNEDI3CL.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libmvtools.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DeinterlaceFilter/Bwdif/Bwdif.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/akarin.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/ZSmooth/zsmooth.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV_AVX2.dll")
- # Import scripts
- import masked
- import RainbowSmooth
- import qtgmc
- import validate
- # Source: 'C:\Users\Selur\Desktop\OPBox2.mkv'
- # Current color space: YUV420P8, bit depth: 8, resolution: 1920x1080, frame rate: 29.97fps, scanorder: top field first, yuv luminance scale: limited, matrix: 709, format: AVC
- # Loading 'C:\Users\Selur\Desktop\OPBox2.mkv' using DGSource
- clip = core.dgdecodenv.DGSource("J:/tmp/mkv_0604cae322f9fbe00040844b856ac3a4_853323747.dgi",fieldop=0) # 29.97 fps, scanorder: top field first
- frame = clip.get_frame(0)
- # setting color matrix to 709.
- clip = core.std.SetFrameProps(clip, _Matrix=vs.MATRIX_BT709)
- # 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_BT709), if it is not set.
- if validate.primariesIsInvalid(clip):
- clip = core.std.SetFrameProps(clip=clip, _Primaries=vs.PRIMARIES_BT709)
- # setting color range to TV (limited) range.
- prop_name = '_Range' if core.core_version.release_major >= 74 else '_ColorRange'
- clip = core.std.SetFrameProps(clip=clip, prop_name=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: top field first)
- clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_TOP) # scan type: top field first
- # Deinterlacing using QTGMC
- clip = qtgmc.QTGMC(clip, Preset="Fast", TFF=True, opencl=True) # new fps: 59.94
- # Making sure content is preceived as frame based
- clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # scan type: progressive
- clip = core.std.AddBorders(clip=clip, left=0, right=0, top=4, bottom=4) # add borders to archive mod 16 (vsRainbowSmooth) - 1920x1088
- # rainbow removal using RainbowSmooth
- clip = RainbowSmooth.RainbowSmooth(clip)
- clip = core.std.Crop(clip=clip, left=0, right=0, top=4, bottom=4) # removing added borders from mod requirement (vsRainbowSmooth) - 1920x1080
- # adjusting color space from YUV420P8 to RGBS for vsRealCUGAN
- clip = core.resize.Bicubic(clip=clip, format=vs.RGBS, matrix_in_s="709", range_in_s="limited", range_s="full", dither_type="error_diffusion")
- # resizing using RealCUGAN
- clip = core.rcnv.RealCUGAN(clip, noise=0, model=0, syncgap=2) # 3840x2160
- # resizing 3840x2160 to 1920x1080
- clip = core.fmtc.resample(clip, w=1920, h=1080, kernel="spline64", interlaced=False, interlacedd=False)
- clipMask = clip
- ## Starting applying 'BloatedEdgeMask' masked filtering for vsBasicVSRPPFilter
- # Creating mask for clip
- clipMask = core.resize.Bicubic(clip=clipMask, format=vs.GRAY16, matrix_s="709", range_in_s="full", range_s="limited") # additional resize to match target color sampling
- clipMask = masked.bloated_edgemask(src=clipMask)
- for i in range(3):
- clipMask = core.std.Maximum(clipMask)
- clipFiltered = clip
- # adjusting color space from RGBS to RGBH for vsBasicVSRPPFilter
- clipFiltered = core.resize.Bicubic(clip=clipFiltered, format=vs.RGBH)
- # Quality enhancement using BasicVSR++
- from vsbasicvsrpp import basicvsrpp as BasicVSRPP
- clipFiltered = BasicVSRPP(clipFiltered, model=4)
- # adjusting clipFiltered color before mask merge
- clipFiltered = core.resize.Bicubic(clip=clipFiltered, format=vs.RGBS, dither_type="error_diffusion")
- # adjusting mask before mask merge
- clipMask = core.resize.Bicubic(clip=clipMask, format=vs.GRAYS, range_in_s="limited", dither_type="error_diffusion")
- # Resolution: clip: 1920x1080 and clipFiltered: 1920x1080 and clipMask: 1920x1080
- # Merging: clip and clipFiltered based on clipMask
- clip = core.std.MaskedMerge(clip, clipFiltered, clipMask) # BloatedEdgeMask
- ## Finished applying 'BloatedEdgeMask' masked filtering for vsBasicVSRPPFilter
- # adjusting output color from RGBS to YUV420P10 for NVEncModel
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, matrix_s="709", range_in_s="full", range_s="limited") # additional resize to match target color sampling
- # set output frame rate to 59.94fps (progressive)
- clip = core.std.AssumeFPS(clip=clip, fpsnum=60000, fpsden=1001)
- # output
- clip.set_output()
- # script was created by Hybrid 2026.04.06.1
Advertisement
Add Comment
Please, Sign In to add comment