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
- # 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/Support/EEDI3m_opencl.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/ResizeFilter/nnedi3/NNEDI3CL.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/MiscFilter/MiscFilters/MiscFilters.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/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/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/ColorFilter/TimeCube/vscube.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/ChromaNR/chromanrcuda.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/ColorFilter/Softlight/CUDA 12.4/SoftLight.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/LSmashSource/LSMASHSource.dll")
- # Import scripts
- import havsfunc
- import autowhite
- import validate
- # Source: 'C:\Users\Selur\Desktop\Sample2.avi'
- # Current color space: YUV422P8, bit depth: 8, resolution: 720x576, frame rate: 50fps, scanorder: progressive, yuv luminance scale: limited, matrix: 470bg
- # Loading C:\Users\Selur\Desktop\Sample2.avi using LWLibavSource
- clip = core.lsmas.LWLibavSource(source="C:/Users/Selur/Desktop/Sample2.avi", format="YUV422P8", stream_index=0, cache=0, prefer_hw=0)
- frame = clip.get_frame(0)
- # Setting detected color matrix (470bg).
- clip = core.std.SetFrameProps(clip=clip, _Matrix=5)
- # setting color transfer (170), if it is not set.
- if validate.transferIsInvalid(clip):
- clip = core.std.SetFrameProps(clip=clip, _Transfer=6)
- # setting color primaries info (to 470), if it is not set.
- if validate.primariesIsInvalid(clip):
- clip = core.std.SetFrameProps(clip=clip, _Primaries=5)
- # setting color range to TV (limited) range.
- clip = core.std.SetFrameProps(clip=clip, _ColorRange=1)
- # making sure frame rate is set to 50fps
- clip = core.std.AssumeFPS(clip=clip, fpsnum=50, fpsden=1)
- # making sure the detected scan type is set (detected: progressive)
- clip = core.std.SetFrameProps(clip=clip, _FieldBased=0)# progressive
- # adjusting color space from YUV422P8 to RGB24 for vsAutoWhite
- clip = core.resize.Bicubic(clip=clip, format=vs.RGB24, matrix_in_s="470bg", range_s="limited")
- # adjustint colors using AutoWhite
- clip = autowhite.AutoWhite(clip=clip)
- # color adjustment using SoftLight
- clip = core.Argaricolm.Softlight(clip, mode=6, formula=2)
- clip = core.std.CropRel(clip=clip, left=14, right=10, top=2, bottom=12)# cropping to 696x562
- # adjusting color space from RGB24 to YUV444PS for vsChromaNR
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV444PS, matrix_s="470bg", range_s="limited")
- # chroma denoising using ChromaNR
- clip = core.chromanrcuda.CNR(clip=clip, thres=50, threy=20, threu=20, threv=20, sizew=15, sizeh=15)
- clipMerge = clip
- clipMerge = core.std.AddBorders(clip=clipMerge, left=0, right=0, top=2, bottom=4)# add borders to archive mod 8 (vsBasicVSRPPFilter) - 696x568
- # adjusting color space from YUV444PS to RGBH for vsBasicVSRPPFilter
- clipMerge = core.resize.Bicubic(clip=clipMerge, format=vs.RGBH, matrix_in_s="470bg", range_s="limited", dither_type="error_diffusion")
- # Quality enhancement using BasicVSR++
- from vsbasicvsrpp import basicvsrpp as BasicVSRPP
- clipMerge = BasicVSRPP(clip=clipMerge, model=4, length=50)
- clipMerge = core.std.CropRel(clip=clipMerge, left=0, right=0, top=2, bottom=4)# removing borders (vsBasicVSRPPFilter) - 696x562
- clipMerge = core.resize.Bicubic(clip=clipMerge, format=vs.YUV444P16, matrix_s="470bg", range_s="limited")
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, range_s="limited", dither_type="error_diffusion")
- clip = core.std.Merge(clip,clipMerge,[0, 1, 1])# merge filtered and unfiltered by plane
- # adjusting color space from YUV444P16 to RGB48 for vsTimeCube
- clip = core.resize.Bicubic(clip=clip, format=vs.RGB48, matrix_in_s="470bg", range_s="limited")
- # color adjustment using TimeCube
- clip = core.timecube.Cube(clip=clip, cube="F:/Hybrid/64bit/vsfilters/ColorFilter/TimeCube/BT2020_HLG_BT601_PAL.cube")
- clip = core.std.AddBorders(clip=clip, left=0, right=0, top=0, bottom=2)# add borders to archive mod 4 (vsQTGMCFilter) - 696x564
- # adjusting color space from RGB48 to YUV444P16 for vsQTGMCFilter
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="470bg", range_s="limited")
- # Denoising using QTGMC
- clip = havsfunc.QTGMC(Input=clip, Preset="Fast", InputType=3, TR2=1, TFF=False, SourceMatch=3, Lossless=2, opencl=True)
- clip = core.std.CropRel(clip=clip, left=0, right=0, top=0, bottom=2)# removing borders (vsQTGMCFilter) - 696x562
- # adjusting output color from: YUV444P16 to YUV420P10 for NVEncModel
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, 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