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
- # 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/Support/libvs_placebo.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 dehalo
- import sharpen
- import validate
- # Source: 'C:\Users\Selur\Desktop\JYErNv_001_clip_1_deinterlaced-20s.mp4'
- # Current color space: YUV420P8, bit depth: 8, resolution: 768x576, frame rate: 22.969fps, scanorder: progressive, yuv luminance scale: limited, matrix: 709, format: AVC
- # Loading 'C:\Users\Selur\Desktop\JYErNv_001_clip_1_deinterlaced-20s.mp4' using DGSource
- clip = core.dgdecodenv.DGSource("J:/tmp/mp4_3e319b4cfb3d3c0a9a3f4916c3e6885a_853323747.dgi") # 22.969 fps, scanorder: progressive
- frame = clip.get_frame(0)
- # setting color matrix to 709.
- clip = core.std.SetFrameProps(clip, _Matrix=vs.MATRIX_BT709)
- # 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 22.969fps
- clip = core.std.AssumeFPS(clip=clip, fpsnum=22969, fpsden=1000)
- # making sure the detected scan type is set (detected: progressive)
- clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # scan type: progressive
- # sharpening using DetailSharpen
- clip = sharpen.DetailSharpen(clip)
- # applying dehalo using DeHalo_alpha
- clip = dehalo.DeHalo_alpha(clip, rx=3.00, ry=3.00, brightstr=0.00)
- ## Starting applying 'limit' masked filtering for vsBasicVSRPPFilter
- # Creating mask for clip
- clipMask = clip
- clipMask = core.resize.Bicubic(clip=clipMask, format=vs.GRAY16, range_in_s="limited", dither_type="error_diffusion")
- clipMask = core.std.BinarizeMask(clipMask, 7680)
- for i in range(2):
- clipMask = core.std.Maximum(clipMask)
- clipMask = core.std.InvertMask(clipMask)
- 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: 768x576 and clipFiltered: 768x576 and clipMask: 768x576
- # Merging: clip and clipFiltered based on clipMask
- clip = core.std.MaskedMerge(clip, clipFiltered, clipMask) # LimitMask
- ## Finished applying 'LimitMask' masked filtering for vsBasicVSRPPFilter
- # adjusting color space from RGBS to YUV444P16 for vsGLSLFilmGrain
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="709", range_in_s="full", range_s="limited") # additional resize to match target color sampling
- # Adding grain using GLSL AddGrain
- 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, 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)
- # set output frame rate to 22.969fps (progressive)
- clip = core.std.AssumeFPS(clip=clip, fpsnum=22969, fpsden=1000)
- # output
- clip.set_output()
- # script was created by Hybrid 2026.01.26.1
Advertisement
Add Comment
Please, Sign In to add comment