Advertisement
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")
- # Adding torch dependencies to PATH
- path = site.getsitepackages()[0]+'/torch_dependencies/bin/'
- ctypes.windll.kernel32.SetDllDirectoryW(path)
- path = path.replace('\\', '/')
- os.environ["PATH"] = path + os.pathsep + os.environ["PATH"]
- # Loading Plugins
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/FrameFilter/ReduceFlicker/ReduceFlicker.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libtemporalmedian.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")
- 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/LSmashSource/LSMASHSource.dll")
- # Import scripts
- import edi_rpow2
- import SpotLess
- import chromashift
- import havsfunc
- # source: 'C:\Users\Selur\Desktop\example.avi'
- # current color space: YUV420P8, bit depth: 8, resolution: 720x576, fps: 25, scanorder: top field first, yuv luminance scale: limited, matrix: 470bg
- # Loading C:\Users\Selur\Desktop\example.avi using LWLibavSource
- clip = core.lsmas.LWLibavSource(source="C:/Users/Selur/Desktop/example.avi", format="YUV420P8", stream_index=0, cache=0, prefer_hw=3)
- frame = clip.get_frame(0)
- # Setting detected color matrix (470bg).
- clip = core.std.SetFrameProps(clip, _Matrix=5)
- # Setting color transfer (170), if it is not set.
- if '_Transfer' not in frame.props or not frame.props['_Transfer']:
- clip = core.std.SetFrameProps(clip, _Transfer=6)
- # Setting color primaries info (to 470), if it is not set.
- if '_Primaries' not in frame.props or not frame.props['_Primaries']:
- clip = core.std.SetFrameProps(clip, _Primaries=5)
- # Setting color range to TV (limited) range.
- clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
- # making sure frame rate is set to 25
- clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
- clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=2) # tff
- # Deinterlacing using QTGMC
- clip = havsfunc.QTGMC(Input=clip, Preset="Fast", TFF=False, opencl=True) # new fps: 50
- # Making sure content is preceived as frame based
- clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=0) # progressive
- # adjusting color space from YUV420P8 to RGB24 for vsLevels
- clip = core.resize.Bicubic(clip=clip, format=vs.RGB24, matrix_in_s="470bg", range_s="limited")
- # Color Adjustment using Levels on RGB24 (8 bit)
- clip = core.std.Levels(clip=clip, min_in=0, max_in=255, min_out=16, max_out=235, gamma=0.90)
- # adjusting color space from RGB24 to YUV444P16 for vsChromaShiftSP
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="470bg", range_s="limited")
- # Chroma adjustment using ChromaShiftSP
- clip = chromashift.ChromaShiftSP(clip=clip, X=-4.00, Y=-1.00)
- # Spot removal using SpotLess
- clip = SpotLess.SpotLess(clip=clip, radT=3, pel=1)
- from vsdpir import dpir as DPIR
- # adjusting color space from YUV444P16 to RGBH for vsDPIRDeblock
- clip = core.resize.Bicubic(clip=clip, format=vs.RGBH, matrix_in_s="470bg", range_s="limited")
- # deblocking using DPIRDeblock
- clip = DPIR(clip=clip, strength=50.000, task="deblock", device_index=0)
- # adjusting color space from RGBH to YUV444P16 for vsReduceFlicker
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="470bg", range_s="limited")
- # removing flickering using ReduceFlicker
- clip = core.rdfl.ReduceFlicker(clip=clip, strength=3, aggressive=1)
- clip = core.std.CropRel(clip=clip, left=10, right=14, top=0, bottom=14)# cropping to 696x562
- # Fix bright and dark line artifacts near the border of an image using BalanceBorders
- clip = havsfunc.bbmod(c=clip,cLeft=18,cTop=0,cRight=0,cBottom=0)
- clip = core.std.AddBorders(clip=clip, left=0, right=0, top=2, bottom=4) # add borders to archive mod 8 (vsBasicVSRPPFilter) - 696x568
- # adjusting color space from YUV444P16 to RGBH for vsBasicVSRPPFilter
- clip = core.resize.Bicubic(clip=clip, format=vs.RGBH, matrix_in_s="470bg", range_s="limited")
- # Quality enhancement using BasicVSR++
- from vsbasicvsrpp import basicvsrpp as BasicVSRPP
- clip = BasicVSRPP(clip=clip, model=6)
- clip = core.std.CropRel(clip=clip, left=0, right=0, top=2, bottom=4) # removing borders (vsBasicVSRPPFilter) - 696x562
- clip = core.std.AddBorders(clip=clip, left=0, right=0, top=0, bottom=2) # add borders to archive mod 4 (NNEDI3(CL)) - 696x564
- # 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: 696x564 target: 1280x970 -> pow: 2
- clip = edi_rpow2.nnedi3cl_rpow2(clip=clip, rfactor=2) # 1392x1128
- clip = core.std.CropRel(clip=clip, left=0, right=0, top=0, bottom=4) # removing borders (NNEDI3(CL)) - 1392x1124
- # adjusting resizing
- clip = core.fmtc.resample(clip=clip, w=1280, h=970, 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
Advertisement