Guest User

Untitled

a guest
May 2nd, 2026
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.35 KB | None | 0 0
  1. # Imports
  2. import vapoursynth as vs
  3. # getting Vapoursynth core
  4. import logging
  5. import site
  6. import ctypes
  7. import sys
  8. import os
  9. core = vs.core
  10. # Import scripts folder
  11. scriptPath = 'G:/Apps/Hybrid/64bit/vsscripts'
  12. sys.path.insert(0, os.path.abspath(scriptPath))
  13. # Loading Support Files
  14. Dllref = ctypes.windll.LoadLibrary("G:/Apps/Hybrid/64bit/vsfilters/Support/libfftw3f-3.dll")
  15. os.environ["CUDA_MODULE_LOADING"] = "LAZY"
  16. # Force logging to std:err
  17. logging.StreamHandler(sys.stderr)
  18. # loading plugins
  19. core.std.LoadPlugin(path="G:/Apps/Hybrid/64bit/vsfilters/Support/DCTFilter.dll")
  20. core.std.LoadPlugin(path="G:/Apps/Hybrid/64bit/vsfilters/DeblockFilter/Deblock/Deblock.dll")
  21. core.std.LoadPlugin(path="G:/Apps/Hybrid/64bit/vsfilters/Support/vszip.dll")
  22. core.std.LoadPlugin(path="G:/Apps/Hybrid/64bit/vs-mlrt/vstrt_rtx.dll")
  23. core.std.LoadPlugin(path="G:/Apps/Hybrid/64bit/vs-mlrt/vstrt.dll")
  24. core.std.LoadPlugin(path="G:/Apps/Hybrid/64bit/vs-mlrt/vsort.dll")
  25. core.std.LoadPlugin(path="G:/Apps/Hybrid/64bit/vsfilters/DeinterlaceFilter/TIVTC/libtivtc.dll")
  26. core.std.LoadPlugin(path="G:/Apps/Hybrid/64bit/vsfilters/MiscFilter/MiscFilters/MiscFilters.dll")
  27. core.std.LoadPlugin(path="G:/Apps/Hybrid/64bit/vsfilters/GrainFilter/AddGrain/AddGrain.dll")
  28. core.std.LoadPlugin(path="G:/Apps/Hybrid/64bit/vsfilters/DenoiseFilter/NEO_FFT3DFilter/neo-fft3d.dll")
  29. core.std.LoadPlugin(path="G:/Apps/Hybrid/64bit/vsfilters/DenoiseFilter/DFTTest/DFTTest.dll")
  30. core.std.LoadPlugin(path="G:/Apps/Hybrid/64bit/vsfilters/Support/EEDI3m_opencl.dll") # DeinterlaceFilter-Selector
  31. core.std.LoadPlugin(path="G:/Apps/Hybrid/64bit/vsfilters/ResizeFilter/nnedi3/NNEDI3CL.dll")
  32. core.std.LoadPlugin(path="G:/Apps/Hybrid/64bit/vsfilters/Support/libmvtools.dll")
  33. core.std.LoadPlugin(path="G:/Apps/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
  34. core.std.LoadPlugin(path="G:/Apps/Hybrid/64bit/vsfilters/Support/akarin.dll")
  35. core.std.LoadPlugin(path="G:/Apps/Hybrid/64bit/vsfilters/DenoiseFilter/ZSmooth/zsmooth.dll")
  36. core.std.LoadPlugin(path="G:/Apps/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV_AVX2.dll")
  37. # Import scripts
  38. import denoise
  39. from importlib.machinery import SourceFileLoader
  40. vsmlrt = SourceFileLoader('vsmlrt', 'G:/Apps/Hybrid/64bit/vs-mlrt/vsmlrt.py').load_module()
  41. from vsmlrt import Backend
  42. import qtgmc
  43. import validate
  44. # Source: 'G:\A1_test.mkv'
  45. # 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
  46. # Loading 'G:\A1_test.mkv' using DGSource
  47. clip = core.dgdecodenv.DGSource("C:/Users/Titant/AppData/Local/Temp/mkv_9e15e2b35915a6b3dc3ddd134d0cb1d5_853323747.dgi",fieldop=0) # 29.97 fps, scanorder: top field first
  48. frame = clip.get_frame(0)
  49. # setting color matrix to 470bg.
  50. clip = core.std.SetFrameProps(clip, _Matrix=vs.MATRIX_BT470_BG)
  51. # setting color transfer (vs.TRANSFER_BT601), if it is not set.
  52. if validate.transferIsInvalid(clip):
  53. clip = core.std.SetFrameProps(clip=clip, _Transfer=vs.TRANSFER_BT601)
  54. # setting color primaries info (to vs.PRIMARIES_BT470_BG), if it is not set.
  55. if validate.primariesIsInvalid(clip):
  56. clip = core.std.SetFrameProps(clip=clip, _Primaries=vs.PRIMARIES_BT470_BG)
  57. # setting color range to TV (limited) range.
  58. clip = core.std.SetFrameProps(clip=clip, _ColorRange=vs.RANGE_LIMITED)
  59. # making sure frame rate is set to 29.97fps
  60. clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
  61. # making sure the detected scan type is set (detected: top field first)
  62. clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_TOP) # scan type: top field first
  63. clip2clip = clip
  64. clip2clip = qtgmc.QTGMC(Input=clip2clip, Preset="fast", opencl=True, TFF=False, FPSDivisor=2)
  65. # Deinterlacing using TIVTC
  66. clip = core.tivtc.TFM(clip, clip2=clip2clip)
  67. clip = core.tivtc.TDecimate(clip, noblend=False) # new fps: 23.976
  68. # Making sure content is preceived as frame based
  69. clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # scan type: progressive
  70. clip = core.std.Crop(clip, left=2, right=10, top=0, bottom=0) # cropping to 708x480
  71. clip = core.std.AddBorders(clip=clip, left=2, right=2, top=0, bottom=0) # add borders to archive mod 8 (vsVSMLRTFilter) - 712x480
  72. # changing range from limited to full range for vsVSMLRTFilter
  73. clip = core.resize.Bicubic(clip, format=vs.YUV420P8, range_in_s="limited", range_s="full")
  74. # setting color range to PC (full) range.
  75. clip = core.std.SetFrameProps(clip=clip, _ColorRange=vs.RANGE_FULL)
  76. # adjusting color space from YUV420P8 to RGBS for vsVSMLRTFilter
  77. clip = core.resize.Bicubic(clip=clip, format=vs.RGBS, matrix_in_s="470bg", range_in_s="full", range_s="full", dither_type="error_diffusion")
  78. # filtering using VSMLRT
  79. 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
  80. clip = core.std.Crop(clip=clip, left=2, right=2, top=0, bottom=0) # removing added borders from mod requirement (vsVSMLRTFilter) - 708x480
  81. # making sure 0-1 limits are respected
  82. clip = core.vszip.Limiter(clip=clip, min=[0,0,0], max=[1,1,1])
  83. # adjusting color space from RGBS to YUV444P16 for vsMCTemporalDenoise
  84. 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
  85. # denoising using MCTemporalDenoise
  86. clip = denoise.MCTemporalDenoise(clip, settings="very low", ncpu=1)
  87. # Resizing using 10 - bicubic spline
  88. clip = core.fmtc.resample(clip, kernel="spline16", w=640, h=488, interlaced=False, interlacedd=False) # resolution 640x488 before YUV444P16 after YUV444P16
  89. # adjusting output color from YUV444P16 to YUV420P10 for x265Model
  90. clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10)
  91. # changing range from full to limited range for to match intended output luma scale
  92. clip = core.resize.Bicubic(clip, format=vs.YUV420P10,range_in_s="full", range_s="limited")
  93. # setting color range to TV (limited) range.
  94. clip = core.std.SetFrameProps(clip=clip, _ColorRange=vs.RANGE_LIMITED)
  95. # set output frame rate to 23.976fps (progressive)
  96. clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001)
  97. # output
  98. clip.set_output()
  99. # script was created by Hybrid 2026.03.21.1
Advertisement
Add Comment
Please, Sign In to add comment