Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Imports
- import vapoursynth as vs
- # getting Vapoursynth core
- import ctypes
- import sys
- import os
- core = vs.core
- # Limit frame cache to 48473MB
- core.max_cache_size = 48473
- # 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/SharpenFilter/AWarpSharp2/libawarpsharp2.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libvs_placebo.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/vszip.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/ZSmooth/zsmooth.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DeinterlaceFilter/Support/libftf.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DeinterlaceFilter/TIVTC/libtivtc.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/MiscFilter/MiscFilters/MiscFilters.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")# DeinterlaceFilter-Selector
- 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/Support/akarin.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV_AVX2.dll")
- # Import scripts
- import linedarken
- import edi_rpow2
- import dehalo
- import SpotLess
- import qtgmc
- import validate
- # Source: 'C:\Users\Selur\Desktop\clip2.mkv'
- # Current color space: YUV420P8, bit depth: 8, resolution: 640x480, frame rate: 29.97fps, scanorder: telecine, yuv luminance scale: full, matrix: 470bg, format: AVC
- # Loading C:\Users\Selur\Desktop\clip2.mkv using DGSource
- clip = core.dgdecodenv.DGSource("J:/tmp/mkv_c04bb5d2fe0a9d0ab6f7847f59780117_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_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 PC (full) range.
- clip = core.std.SetFrameProps(clip=clip, _ColorRange=vs.RANGE_FULL)
- # 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
- # changing range from full to limited range for
- clip = core.resize.Bicubic(clip, format=vs.YUV420P8, matrix_s="470bg",range_in_s="full", range_s="limited")
- # setting color range to TV (limited) range.
- clip = core.std.SetFrameProps(clip=clip, _ColorRange=vs.RANGE_LIMITED)
- clip2clip = clip
- clip2clip = qtgmc.QTGMC(Input=clip2clip, Preset="fast", opencl=True, TFF=False, FPSDivisor=2)
- # Deinterlacing using TIVTC
- clip = core.tivtc.TFM(clip=clip, mode=5, blockx=32, blocky=32, chroma=True, MI=16, clip2=clip2clip)
- clip = core.tivtc.TDecimate(clip=clip, mode=1, blockx=16, blocky=16)# new fps: 23.976
- # Making sure content is preceived as frame based
- clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # progressive
- # adjusting bit depth to 32bit
- clip = core.fmtc.bitdepth(clip=clip, bits=32)
- # Fix telecined fades
- clip = core.ftf.FixFades(clip=clip)
- # adjusting bit depth back to 8bit
- clip = core.fmtc.bitdepth(clip=clip, bits=8)
- # Spot removal using SpotLess
- clip = SpotLess.SpotLess(clip=clip, radT=3, rec=True, pel=1, smoother="zsmooth")
- # applying dehalo using DeHalo_alpha
- clip = dehalo.DeHalo_alpha(clip)
- # adjusting color space from YUV420P8 to YUV444P16 for vsGLSLLumaSharpen
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16)
- with open("F:/Hybrid/64bit/vsfilters/GLSL/parameterized/LumaSharpenHook.glsl") as glslf:
- glsl = glslf.read()
- glsl = glsl.replace('#define sharp_strength 0.30', '#define sharp_strength 1.5000')
- glsl = glsl.replace('#define sharp_clamp 0.035', '#define sharp_clamp 0.0350')
- glsl = glsl.replace('#define pattern 2', '#define pattern 4')
- glsl = glsl.replace('#define offset_bias 1.0', '#define offset_bias 1.0000')
- clip = core.placebo.Shader(clip=clip, shader_s=glsl, width=clip.width, height=clip.height)
- # resizing using NNEDI3CL
- # current: 640x480 target: 1280x960 -> pow: 2
- clip = edi_rpow2.nnedi3cl_rpow2(clip=clip, rfactor=2, nsize=3, nns=4) # 1280x960
- # adjusting color space from YUV444P16 to RGBH for vsBasicVSRPPFilter
- clip = core.resize.Bicubic(clip=clip, format=vs.RGBH, matrix_in_s="470bg", range_in_s="limited", range_s="limited")
- # Quality enhancement using BasicVSR++
- from vsbasicvsrpp import basicvsrpp as BasicVSRPP
- clip = BasicVSRPP(clip=clip, model=4)
- # adjusting color space from RGBH to YUV444P16 for vsToon
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="470bg", range_in_s="full", range_s="limited") # additional resize to allow target color sampling
- # line darkening using Toon
- clip = linedarken.Toon(input=clip)
- # adjusting output color from: YUV444P16 to YUV420P10 for NVEncModel
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, 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