Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Imports
- import vapoursynth as vs
- # getting Vapoursynth core
- import logging
- import site
- import ctypes
- import sys
- import os
- core = vs.core
- # Limit frame cache to 48449MB
- core.max_cache_size = 48449
- # 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"
- # Force logging to std:err
- logging.StreamHandler(sys.stderr)
- # loading plugins
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SharpenFilter/AWarpSharp2/libawarpsharp2.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/CTMF/CTMF.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vs-mlrt/vstrt.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/MiscFilter/MiscFilters/MiscFilters.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DeCrawlFilter/DeDot/libdedot.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") # 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/DeinterlaceFilter/Bwdif/Bwdif.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/akarin.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/ZSmooth/zsmooth.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/BestSource/BestSource.dll")
- # Import scripts
- import dehalo
- from importlib.machinery import SourceFileLoader
- vsmlrt = SourceFileLoader('vsmlrt', 'F:/Hybrid/64bit/vs-mlrt/vsmlrt.py').load_module()
- from vsmlrt import Backend
- import artifacts
- import qtgmc
- import validate
- # Source: 'C:\Users\Selur\Desktop\1_edit.avi'
- # Current color space: YUV422P8, bit depth: 8, resolution: 720x576, frame rate: 25fps, scanorder: top field first, yuv luminance scale: limited, matrix: 470bg, format: HuffYUV
- # Loading 'C:\Users\Selur\Desktop\1_edit.avi' using BestSource
- clip = core.bs.VideoSource(source="C:/Users/Selur/Desktop/1_edit.avi", cachepath="J:/tmp/1_edit_bestSource", track=0, hwdevice="opencl")
- 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 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) # scan type: top field first
- # Deinterlacing using QTGMC
- clip = qtgmc.QTGMC(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) # scan type: progressive
- clip = core.dedot.Dedot(clip)
- # adjusting color space from YUV422P8 to RGBH for vsBasicVSRPPFilter
- clip = core.resize.Bicubic(clip=clip, format=vs.RGBH, matrix_in_s="470bg", range_in_s="limited", range_s="full")
- # Quality enhancement using BasicVSR++
- from vsbasicvsrpp import basicvsrpp as BasicVSRPP
- clip = BasicVSRPP(clip, model=9)
- # rotating 90Β° clock wise for vsQTGMCFilterGimmick
- clip = core.std.FlipVertical(clip=clip)
- clip = core.std.Transpose(clip=clip)
- # adjusting color space from RGBH to YUV444P16 for vsQTGMCFilter
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="470bg", range_in_s="full", range_s="limited") # additional resize to match target color sampling
- # Denoising using QTGMC
- clip = qtgmc.QTGMC(clip, Preset="Fast", InputType=3, TR2=1, TFF=False, SourceMatch=0, Lossless=0, opencl=True)
- # rotating 90Β° counter clock wise after vsQTGMCFilterGimmick
- clip = core.std.FlipHorizontal(clip=clip)
- clip = core.std.Transpose(clip=clip)
- # changing range from limited to full range for vsSCUNetmlrt
- clip = core.resize.Bicubic(clip, format=vs.YUV444P16, 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_in_s="full", range_s="full")
- # denoising using SCUNet (mlrt)
- clip = vsmlrt.SCUNet(clip, model=4, overlap=16, backend=Backend.TRT(fp16=True,device_id=0,bf16=False,verbose=True,use_cuda_graph=False,num_streams=3,builder_optimization_level=3,engine_folder="J:/TRT"))
- # changing range from full to limited range for vsSCUNetmlrt
- clip = core.resize.Bicubic(clip, format=vs.RGBH,range_in_s="full", range_s="limited")
- # adjusting color space from RGBH to YUV444P16 for vsYAHR
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="470bg", range_in_s="full", range_s="limited") # additional resize to match target color sampling
- # applying dehalo using YAHR
- clip = dehalo.YAHR(clip, depth=16) # call: 0
- # 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 50fps (progressive)
- clip = core.std.AssumeFPS(clip=clip, fpsnum=50, fpsden=1)
- # output
- clip.set_output()
- # script was created by Hybrid 2025.12.29.1
Advertisement
Add Comment
Please, Sign In to add comment