Guest User

Untitled

a guest
Dec 29th, 2025
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.08 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. # Limit frame cache to 48449MB
  11. core.max_cache_size = 48449
  12. # Import scripts folder
  13. scriptPath = 'F:/Hybrid/64bit/vsscripts'
  14. sys.path.insert(0, os.path.abspath(scriptPath))
  15. # Loading Support Files
  16. Dllref = ctypes.windll.LoadLibrary("F:/Hybrid/64bit/vsfilters/Support/libfftw3f-3.dll")
  17. os.environ["CUDA_MODULE_LOADING"] = "LAZY"
  18. # Force logging to std:err
  19. logging.StreamHandler(sys.stderr)
  20. # loading plugins
  21. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SharpenFilter/AWarpSharp2/libawarpsharp2.dll")
  22. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/CTMF/CTMF.dll")
  23. core.std.LoadPlugin(path="F:/Hybrid/64bit/vs-mlrt/vstrt.dll")
  24. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/MiscFilter/MiscFilters/MiscFilters.dll")
  25. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DeCrawlFilter/DeDot/libdedot.dll")
  26. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/GrainFilter/AddGrain/AddGrain.dll")
  27. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/NEO_FFT3DFilter/neo-fft3d.dll")
  28. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/DFTTest/DFTTest.dll")
  29. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/EEDI3m_opencl.dll") # vsQTGMC
  30. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/ResizeFilter/nnedi3/NNEDI3CL.dll")
  31. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libmvtools.dll")
  32. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
  33. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DeinterlaceFilter/Bwdif/Bwdif.dll")
  34. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/akarin.dll")
  35. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/ZSmooth/zsmooth.dll")
  36. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/BestSource/BestSource.dll")
  37. # Import scripts
  38. import dehalo
  39. from importlib.machinery import SourceFileLoader
  40. vsmlrt = SourceFileLoader('vsmlrt', 'F:/Hybrid/64bit/vs-mlrt/vsmlrt.py').load_module()
  41. from vsmlrt import Backend
  42. import artifacts
  43. import qtgmc
  44. import validate
  45. # Source: 'C:\Users\Selur\Desktop\1_edit.avi'
  46. # Current color space: YUV422P8, bit depth: 8, resolution: 720x576, frame rate: 25fps, scanorder: top field first, yuv luminance scale: limited, matrix: 470bg, format: HuffYUV
  47. # Loading 'C:\Users\Selur\Desktop\1_edit.avi' using BestSource
  48. clip = core.bs.VideoSource(source="C:/Users/Selur/Desktop/1_edit.avi", cachepath="J:/tmp/1_edit_bestSource", track=0, hwdevice="opencl")
  49. frame = clip.get_frame(0)
  50. # setting color matrix to 470bg.
  51. clip = core.std.SetFrameProps(clip, _Matrix=vs.MATRIX_BT470_BG)
  52. # setting color transfer (vs.TRANSFER_BT601), if it is not set.
  53. if validate.transferIsInvalid(clip):
  54. clip = core.std.SetFrameProps(clip=clip, _Transfer=vs.TRANSFER_BT601)
  55. # setting color primaries info (to vs.PRIMARIES_BT470_BG), if it is not set.
  56. if validate.primariesIsInvalid(clip):
  57. clip = core.std.SetFrameProps(clip=clip, _Primaries=vs.PRIMARIES_BT470_BG)
  58. # setting color range to TV (limited) range.
  59. clip = core.std.SetFrameProps(clip=clip, _ColorRange=vs.RANGE_LIMITED)
  60. # making sure frame rate is set to 25fps
  61. clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
  62. # making sure the detected scan type is set (detected: top field first)
  63. clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_TOP) # scan type: top field first
  64. # Deinterlacing using QTGMC
  65. clip = qtgmc.QTGMC(clip, Preset="Fast", TFF=True, opencl=True) # new fps: 50
  66. # Making sure content is preceived as frame based
  67. clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # scan type: progressive
  68. clip = core.dedot.Dedot(clip)
  69. # adjusting color space from YUV422P8 to RGBH for vsBasicVSRPPFilter
  70. clip = core.resize.Bicubic(clip=clip, format=vs.RGBH, matrix_in_s="470bg", range_in_s="limited", range_s="full")
  71. # Quality enhancement using BasicVSR++
  72. from vsbasicvsrpp import basicvsrpp as BasicVSRPP
  73. clip = BasicVSRPP(clip, model=9)
  74. # rotating 90Β° clock wise for vsQTGMCFilterGimmick
  75. clip = core.std.FlipVertical(clip=clip)
  76. clip = core.std.Transpose(clip=clip)
  77. # adjusting color space from RGBH to YUV444P16 for vsQTGMCFilter
  78. 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
  79. # Denoising using QTGMC
  80. clip = qtgmc.QTGMC(clip, Preset="Fast", InputType=3, TR2=1, TFF=False, SourceMatch=0, Lossless=0, opencl=True)
  81. # rotating 90Β° counter clock wise after vsQTGMCFilterGimmick
  82. clip = core.std.FlipHorizontal(clip=clip)
  83. clip = core.std.Transpose(clip=clip)
  84. # changing range from limited to full range for vsSCUNetmlrt
  85. clip = core.resize.Bicubic(clip, format=vs.YUV444P16, range_in_s="limited", range_s="full")
  86. # setting color range to PC (full) range.
  87. clip = core.std.SetFrameProps(clip=clip, _ColorRange=vs.RANGE_FULL)
  88. # adjusting color space from YUV444P16 to RGBH for vsSCUNetmlrt
  89. clip = core.resize.Bicubic(clip=clip, format=vs.RGBH, matrix_in_s="470bg", range_in_s="full", range_s="full")
  90. # denoising using SCUNet (mlrt)
  91. 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"))
  92. # changing range from full to limited range for vsSCUNetmlrt
  93. clip = core.resize.Bicubic(clip, format=vs.RGBH,range_in_s="full", range_s="limited")
  94. # adjusting color space from RGBH to YUV444P16 for vsYAHR
  95. 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
  96. # applying dehalo using YAHR
  97. clip = dehalo.YAHR(clip, depth=16) # call: 0
  98. # adjusting output color from YUV444P16 to YUV420P10 for NVEncModel
  99. clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, dither_type="error_diffusion")
  100. # set output frame rate to 50fps (progressive)
  101. clip = core.std.AssumeFPS(clip=clip, fpsnum=50, fpsden=1)
  102. # output
  103. clip.set_output()
  104. # script was created by Hybrid 2025.12.29.1
Advertisement
Add Comment
Please, Sign In to add comment