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/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/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
- from importlib.machinery import SourceFileLoader
- vsmlrt = SourceFileLoader('vsmlrt', 'F:/Hybrid/64bit/vs-mlrt/vsmlrt.py').load_module()
- import SpotLess
- import chromashift
- import havsfunc
- import validate
- # Source: 'C:\Users\Selur\Desktop\intermediate.demuxed.m2v'
- # Current color space: YUV422P8, bit depth: 8, resolution: 720x608, frame rate: 25fps, scanorder: top field first, yuv luminance scale: limited, matrix: 709, format: mpeg-2
- # Loading C:\Users\Selur\Desktop\intermediate.demuxed.m2v using LWLibavSource
- clip = core.lsmas.LWLibavSource(source="C:/Users/Selur/Desktop/intermediate.demuxed.m2v", format="YUV422P8", stream_index=0, cache=0, prefer_hw=0)
- frame = clip.get_frame(0)
- # setting color matrix to 709.
- clip = core.std.SetFrameProps(clip, _Matrix=vs.MATRIX_BT709)
- # setting color transfer (vs.TRANSFER_BT709), if it is not set.
- if validate.transferIsInvalid(clip):
- clip = core.std.SetFrameProps(clip=clip, _Transfer=vs.TRANSFER_BT709)
- # setting color primaries info (to vs.PRIMARIES_BT709), if it is not set.
- if validate.primariesIsInvalid(clip):
- clip = core.std.SetFrameProps(clip=clip, _Primaries=vs.PRIMARIES_BT709)
- # 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
- # Chroma adjustment using ChromaShiftSP
- clip = chromashift.ChromaShiftSP(clip=clip, X=2.00, Y=3.00)
- # Spot removal using SpotLess
- clip = SpotLess.SpotLess(clip=clip, radT=1, pel=1, smoother="zsmooth")
- from vsmlrt import Backend
- # adjusting color space from YUV422P8 to RGBH for vsDPIRmlrtDeblock
- clip = core.resize.Bicubic(clip=clip, format=vs.RGBH, matrix_in_s="709", range_s="limited")
- # adjusting deblocking using DPIR (mlrt)
- clip = vsmlrt.DPIR(clip, strength=50.000, overlap=16, model=3, 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=24, right=16, top=34, bottom=2)# cropping to 680x572
- clip = core.std.AddBorders(clip=clip, left=0, right=0, top=2, bottom=2) # add borders to archive mod 8 (vsDPIRmlrtDenoise) - 680x576
- # denosing using DPIR (mlrt)
- clip = vsmlrt.DPIR(clip, strength=7.000, overlap=16, model=1, 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=0, top=2, bottom=2) # removing borders (vsDPIRmlrtDenoise) - 680x572
- # changing range from limited to full range for VsVSGANFilter
- clip = core.resize.Bicubic(clip, range_in_s="limited", range_s="full")
- # filtering using VSGANFilter
- from vsgan import ESRGAN
- vsgan = ESRGAN(clip=clip,device="cuda")
- model = "F:/Hybrid/64bit/vsgan_models/1x_BleedOut_Compact_300k_net_g.pth"
- vsgan.load(model)
- vsgan.apply() # 680x572
- clip = vsgan.clip
- # changing range from full to limited range for VsVSGANFilter
- clip = core.resize.Bicubic(clip, range_in_s="full", range_s="limited")
- # Resizing using 10 - bicubic spline
- clip = core.resize.Bicubic(clip=clip, format=vs.RGBS, range_s="limited")
- clip = core.fmtc.resample(clip=clip, kernel="spline16", w=680, h=536, interlaced=False, interlacedd=False) # resolution 680x536
- # adjusting output color from: RGBS to YUV420P10 for NVEncModel
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, matrix_s="709", 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