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
- # Import scripts folder
- scriptPath = 'G:/Apps/Hybrid/64bit/vsscripts'
- sys.path.insert(0, os.path.abspath(scriptPath))
- # Loading Support Files
- Dllref = ctypes.windll.LoadLibrary("G:/Apps/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="G:/Apps/Hybrid/64bit/vsfilters/Support/DCTFilter.dll")
- core.std.LoadPlugin(path="G:/Apps/Hybrid/64bit/vsfilters/DeblockFilter/Deblock/Deblock.dll")
- core.std.LoadPlugin(path="G:/Apps/Hybrid/64bit/vsfilters/Support/vszip.dll")
- core.std.LoadPlugin(path="G:/Apps/Hybrid/64bit/vs-mlrt/vstrt_rtx.dll")
- core.std.LoadPlugin(path="G:/Apps/Hybrid/64bit/vs-mlrt/vstrt.dll")
- core.std.LoadPlugin(path="G:/Apps/Hybrid/64bit/vs-mlrt/vsort.dll")
- core.std.LoadPlugin(path="G:/Apps/Hybrid/64bit/vsfilters/DeinterlaceFilter/TIVTC/libtivtc.dll")
- core.std.LoadPlugin(path="G:/Apps/Hybrid/64bit/vsfilters/MiscFilter/MiscFilters/MiscFilters.dll")
- core.std.LoadPlugin(path="G:/Apps/Hybrid/64bit/vsfilters/GrainFilter/AddGrain/AddGrain.dll")
- core.std.LoadPlugin(path="G:/Apps/Hybrid/64bit/vsfilters/DenoiseFilter/NEO_FFT3DFilter/neo-fft3d.dll")
- core.std.LoadPlugin(path="G:/Apps/Hybrid/64bit/vsfilters/DenoiseFilter/DFTTest/DFTTest.dll")
- core.std.LoadPlugin(path="G:/Apps/Hybrid/64bit/vsfilters/Support/EEDI3m_opencl.dll") # DeinterlaceFilter-Selector
- core.std.LoadPlugin(path="G:/Apps/Hybrid/64bit/vsfilters/ResizeFilter/nnedi3/NNEDI3CL.dll")
- core.std.LoadPlugin(path="G:/Apps/Hybrid/64bit/vsfilters/Support/libmvtools.dll")
- core.std.LoadPlugin(path="G:/Apps/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
- core.std.LoadPlugin(path="G:/Apps/Hybrid/64bit/vsfilters/Support/akarin.dll")
- core.std.LoadPlugin(path="G:/Apps/Hybrid/64bit/vsfilters/DenoiseFilter/ZSmooth/zsmooth.dll")
- core.std.LoadPlugin(path="G:/Apps/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV_AVX2.dll")
- # Import scripts
- import denoise
- from importlib.machinery import SourceFileLoader
- vsmlrt = SourceFileLoader('vsmlrt', 'G:/Apps/Hybrid/64bit/vs-mlrt/vsmlrt.py').load_module()
- from vsmlrt import Backend
- import qtgmc
- import validate
- # Source: 'G:\A1_test.mkv'
- # Current color space: YUV420P8, bit depth: 8, resolution: 720x480, frame rate: 29.97fps, scanorder: top field first, yuv luminance scale: limited, matrix: 470bg, format: mpeg-2
- # Loading 'G:\A1_test.mkv' using DGSource
- clip = core.dgdecodenv.DGSource("C:/Users/Titant/AppData/Local/Temp/mkv_9e15e2b35915a6b3dc3ddd134d0cb1d5_853323747.dgi",fieldop=0) # 29.97 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_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 29.97fps
- clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
- # 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
- clip2clip = clip
- clip2clip = qtgmc.QTGMC(Input=clip2clip, Preset="fast", opencl=True, TFF=False, FPSDivisor=2)
- # Deinterlacing using TIVTC
- clip = core.tivtc.TFM(clip, clip2=clip2clip)
- clip = core.tivtc.TDecimate(clip, noblend=False) # new fps: 23.976
- # Making sure content is preceived as frame based
- clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # scan type: progressive
- clip = core.std.Crop(clip, left=2, right=10, top=0, bottom=0) # cropping to 708x480
- clip = core.std.AddBorders(clip=clip, left=2, right=2, top=0, bottom=0) # add borders to archive mod 8 (vsVSMLRTFilter) - 712x480
- # changing range from limited to full range for vsVSMLRTFilter
- clip = core.resize.Bicubic(clip, format=vs.YUV420P8, 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 RGBS for vsVSMLRTFilter
- clip = core.resize.Bicubic(clip=clip, format=vs.RGBS, matrix_in_s="470bg", range_in_s="full", range_s="full", dither_type="error_diffusion")
- # filtering using VSMLRT
- clip = vsmlrt.inference([clip],network_path="G:/Apps/Hybrid/64bit/onnx_models/1x_Dotzilla_Compact_80k_net_g.onnx", backend=Backend.TRT_RTX(fp16=False,device_id=0,num_streams=1,verbose=True,use_cuda_graph=True,workspace=1073741824,builder_optimization_level=3,engine_folder="C:/Users/Titant/AppData/Local/Temp")) # 712x480
- clip = core.std.Crop(clip=clip, left=2, right=2, top=0, bottom=0) # removing added borders from mod requirement (vsVSMLRTFilter) - 708x480
- # making sure 0-1 limits are respected
- clip = core.vszip.Limiter(clip=clip, min=[0,0,0], max=[1,1,1])
- # adjusting color space from RGBS to YUV444P16 for vsMCTemporalDenoise
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="470bg", range_in_s="full", range_s="full") # additional resize to match target color sampling
- # denoising using MCTemporalDenoise
- clip = denoise.MCTemporalDenoise(clip, settings="very low", ncpu=1)
- # Resizing using 10 - bicubic spline
- clip = core.fmtc.resample(clip, kernel="spline16", w=640, h=488, interlaced=False, interlacedd=False) # resolution 640x488 before YUV444P16 after YUV444P16
- # adjusting output color from YUV444P16 to YUV420P10 for x265Model
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10)
- # changing range from full to limited range for to match intended output luma scale
- clip = core.resize.Bicubic(clip, format=vs.YUV420P10,range_in_s="full", range_s="limited")
- # setting color range to TV (limited) range.
- clip = core.std.SetFrameProps(clip=clip, _ColorRange=vs.RANGE_LIMITED)
- # set output frame rate to 23.976fps (progressive)
- clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001)
- # output
- clip.set_output()
- # script was created by Hybrid 2026.03.21.1
Advertisement
Add Comment
Please, Sign In to add comment