Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Imports
- import vapoursynth as vs
- # getting Vapoursynth core
- import site
- import ctypes
- import sys
- import os
- core = vs.core
- # 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")
- os.environ["CUDA_MODULE_LOADING"] = "LAZY"
- # loading plugins
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vs-mlrt/vstrt.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/ZSmooth/zsmooth.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libvs_placebo.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SharpenFilter/AWarpSharp2/libawarpsharp2.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/GrainFilter/RemoveGrain/RemoveGrainVS.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/GrainFilter/AddGrain/AddGrain.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/DFTTest/DFTTest.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/NEO_FFT3DFilter/neo-fft3d.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/scenechange.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/MiscFilter/MiscFilters/MiscFilters.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DeinterlaceFilter/Bwdif/Bwdif.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV.dll")
- # Import scripts
- import edi_rpow2
- from importlib.machinery import SourceFileLoader
- vsmlrt = SourceFileLoader('vsmlrt', 'F:/Hybrid/64bit/vs-mlrt/vsmlrt.py').load_module()
- import G41Fun
- import SpotLess
- import havsfunc
- import validate
- # Source: 'C:\Users\Selur\Desktop\Kaskito part.mpg'
- # Current color space: YUV420P8, bit depth: 8, resolution: 720x576, frame rate: 25fps, scanorder: top field first, yuv luminance scale: limited, matrix: 470bg, transfer: bt.470 system b/g, primaries: bt.601 pal, format: mpeg-2
- # Loading C:\Users\Selur\Desktop\Kaskito part.mpg using DGSource
- clip = core.dgdecodenv.DGSource("J:/tmp/mpg_a0561860d3e94768ed280117ab3e6f3b_853323747.dgi",fieldop=0)# 25 fps, scanorder: top field first
- 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_BT470_BG), if it is not set.
- if validate.transferIsInvalid(clip):
- clip = core.std.SetFrameProps(clip=clip, _Transfer=vs.TRANSFER_BT470_BG)
- # 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 25fps
- clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
- # making sure the detected scan type is set (detected: top field first)
- clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_TOP) # tff
- # Deinterlacing using QTGMC
- clip = havsfunc.QTGMC(Input=clip, Preset="Fast", TFF=True, opencl=True) # new fps: 50
- # Making sure content is preceived as frame based
- clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # progressive
- # sharpening using AWarpSharp2
- clip = core.warp.AWarpSharp2(clip=clip, blur=2, depth=48, chroma=True, planes=[1,2])
- # changing range from limited to full range for VsVSGANFilter
- clip = core.resize.Bicubic(clip, range_in_s="limited", range_s="full")
- # setting color range to PC (full) range.
- clip = core.std.SetFrameProps(clip=clip, _ColorRange=vs.RANGE_FULL)
- # adjusting color space from YUV420P8 to RGBH for VsVSGANFilter
- clip = core.resize.Bicubic(clip=clip, format=vs.RGBH, matrix_in_s="470bg", range_s="full")
- # filtering using VSGANFilter
- from vsgan import ESRGAN
- vsgan = ESRGAN(clip=clip,device="cuda")
- model = "C:/Users/Selur/Desktop/testing/1x_OverExposureCorrection_compact.pth"
- vsgan.load(model)
- vsgan.apply() # 720x576
- clip = vsgan.clip
- # changing range from full to limited range for VsVSGANFilter
- clip = core.resize.Bicubic(clip, range_in_s="full", range_s="limited")
- # adjusting color space from RGBH to YUV444P16 for vsGLSLSaturation
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="470bg", range_s="limited")
- with open("F:/Hybrid/64bit/vsfilters/GLSL/parameterized/bSat.hook.glsl") as glslf:
- glsl = glslf.read()
- glsl = glsl.replace('#define SatFactor 2.43', '#define SatFactor 0.75')
- clip = core.placebo.Shader(clip=clip, shader_s=glsl, width=clip.width, height=clip.height)
- # Spot removal using SpotLess
- clip = SpotLess.SpotLess(clip=clip, radT=3, pel=1, smoother="zsmooth")
- clip = core.std.Crop(clip=clip, left=4, right=14, top=0, bottom=4)# cropping to 702x572
- # sharpening using FineSharp
- clip = G41Fun.FineSharp(clip=clip, mode=3)
- from vsmlrt import Backend
- clip = core.std.AddBorders(clip=clip, left=0, right=2, top=2, bottom=2) # add borders to archive mod 8 (vsSCUNetmlrt) - 704x576
- # changing range from limited to full range for vsSCUNetmlrt
- clip = core.resize.Bicubic(clip, range_in_s="limited", range_s="full")
- # setting color range to PC (full) range.
- clip = core.std.SetFrameProps(clip=clip, _ColorRange=vs.RANGE_FULL)
- # adjusting color space from YUV444P16 to RGBH for vsSCUNetmlrt
- clip = core.resize.Bicubic(clip=clip, format=vs.RGBH, matrix_in_s="470bg", range_s="full")
- # denosing using SCUNet (mlrt)
- clip = vsmlrt.SCUNet(clip, model=4, overlap=16, backend=Backend.TRT(fp16=True,device_id=0,verbose=True,use_cuda_graph=False, num_streams=3,builder_optimization_level=3,engine_folder="J:/TRT"))
- clip = core.std.Crop(clip=clip, left=0, right=2, top=2, bottom=2) # removing borders (vsSCUNetmlrt) - 702x572
- # changing range from full to limited range for vsSCUNetmlrt
- clip = core.resize.Bicubic(clip, range_in_s="full", range_s="limited")
- clip = core.std.AddBorders(clip=clip, left=0, right=2, top=0, bottom=0) # add borders to archive mod 4 (NNEDI3(CL)) - 704x572
- # adjusting color space from RGBH to RGB48 for NNEDI3(CL)
- clip = core.resize.Bicubic(clip=clip, format=vs.RGB48, range_s="limited")
- # resizing using NNEDI3CL
- # current: 704x572 target: 1920x1468 -> pow: 4
- clip = edi_rpow2.nnedi3cl_rpow2(clip=clip, rfactor=4, nsize=1, nns=4) # 2816x2288
- clip = core.std.Crop(clip=clip, left=0, right=8, top=0, bottom=0) # removing borders (NNEDI3(CL)) - 2808x2288
- # adjusting resizing
- clip = core.fmtc.resample(clip=clip, w=1920, h=1468, kernel="spline64", interlaced=False, interlacedd=False)# before RGB48 after RGB48
- # adjusting output color from: RGB48 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 50fps (progressive)
- clip = core.std.AssumeFPS(clip=clip, fpsnum=50, fpsden=1)
- # output
- clip.set_output()
Advertisement
Add Comment
Please, Sign In to add comment