Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Imports
- import sys
- import os
- 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 plugins
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/ZSmooth/zsmooth.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/akarin.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DeinterlaceFilter/TIVTC/libtivtc.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV_AVX2.dll")
- # Import scripts
- import masked
- import validate
- # Source: 'C:\Users\Selur\Desktop\OPBox2.mkv'
- # Current color space: YUV420P8, bit depth: 8, resolution: 1920x1080, frame rate: 29.97fps, scanorder: telecine, 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: telecine
- 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: telecine)
- clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_TOP) # scan type: top field first
- # Deinterlacing using TIVTC
- clip = core.tivtc.TFM(clip)
- clip = core.tivtc.TDecimate(clip) # new fps: 23.976
- # Making sure content is preceived as frame based
- clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # scan type: progressive
- clipMask = clip
- ## Starting applying 'BloatedEdgeMask' masked filtering for vsBasicVSRPPFilter
- # Creating mask for clip
- clipMask = core.resize.Bicubic(clip=clipMask, format=vs.GRAY16, range_in_s="limited", dither_type="error_diffusion")
- clipMask = masked.bloated_edgemask(src=clipMask)
- for i in range(3):
- clipMask = core.std.Maximum(clipMask)
- clipMask = core.std.ShufflePlanes(clips=[clipMask], planes=[0], colorfamily=vs.GRAY)
- clipFiltered = clip
- # adjusting color space from YUV420P8 to RGBH for vsBasicVSRPPFilter
- clipFiltered = core.resize.Bicubic(clip=clipFiltered, format=vs.RGBH, matrix_in_s="709", range_in_s="limited", range_s="full", dither_type="error_diffusion")
- # 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 clip color before mask merge
- clip = core.resize.Bicubic(clip=clip, format=vs.RGBS, matrix_in_s="709", range_in_s="limited", range_s="full", 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
- # chroma denoising using CCD
- clip = core.zsmooth.CCD(clip, threshold=60.00, points=[True,True,False])
- # 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 23.976fps (progressive)
- clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001)
- # output
- clip.set_output()
- # script was created by Hybrid 2026.04.07.1
Advertisement
Add Comment
Please, Sign In to add comment