Guest User

Untitled

a guest
Aug 21st, 2025
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.41 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 48473MB
  11. core.max_cache_size = 48473
  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/MiscFilter/MiscFilters/MiscFilters.dll")
  22. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/FrameFilter/RIFE/librife.dll")
  23. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/MiscFilter/LGhost/LGhost.dll")
  24. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SharpenFilter/CAS/CAS.dll")
  25. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DerainbowFilter/SSIQ/libssiq.dll")
  26. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/vszip.dll")
  27. core.std.LoadPlugin(path="F:/Hybrid/64bit/vs-mlrt/vstrt.dll")
  28. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/ZSmooth/zsmooth.dll")
  29. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/GrainFilter/AddGrain/AddGrain.dll")
  30. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/NEO_FFT3DFilter/neo-fft3d.dll")
  31. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/DFTTest/DFTTest.dll")
  32. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/EEDI3m_opencl.dll")# vsQTGMC
  33. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/ResizeFilter/nnedi3/NNEDI3CL.dll")
  34. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libmvtools.dll")
  35. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
  36. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DeinterlaceFilter/Bwdif/Bwdif.dll")
  37. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/akarin.dll")
  38. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/BestSource/BestSource.dll")
  39. # Import scripts
  40. import edi_rpow2
  41. import linedarken
  42. import dehalo
  43. from importlib.machinery import SourceFileLoader
  44. vsmlrt = SourceFileLoader('vsmlrt', 'F:/Hybrid/64bit/vs-mlrt/vsmlrt.py').load_module()
  45. from vsmlrt import Backend
  46. import chromashift
  47. import qtgmc
  48. import validate
  49. # Source: 'C:\Users\Selur\Desktop\Monroe7.mov'
  50. # Current color space: YUV422P10, bit depth: 10, resolution: 720x486, frame rate: 29.97fps, scanorder: bottom field first, yuv luminance scale: limited, matrix: 470bg, format: prores
  51. # Loading C:\Users\Selur\Desktop\Monroe7.mov using BestSource)
  52. clip = core.bs.VideoSource(source="C:/Users/Selur/Desktop/Monroe7.mov", cachepath="J:/tmp/Monroe7_bestSource", track=0, hwdevice="opencl")
  53. frame = clip.get_frame(0)
  54. # setting color matrix to 470bg.
  55. clip = core.std.SetFrameProps(clip, _Matrix=vs.MATRIX_BT470_BG)
  56. # setting color transfer (vs.TRANSFER_BT601), if it is not set.
  57. if validate.transferIsInvalid(clip):
  58. clip = core.std.SetFrameProps(clip=clip, _Transfer=vs.TRANSFER_BT601)
  59. # setting color primaries info (to vs.PRIMARIES_BT470_BG), if it is not set.
  60. if validate.primariesIsInvalid(clip):
  61. clip = core.std.SetFrameProps(clip=clip, _Primaries=vs.PRIMARIES_BT470_BG)
  62. # setting color range to TV (limited) range.
  63. clip = core.std.SetFrameProps(clip=clip, _ColorRange=vs.RANGE_LIMITED)
  64. # making sure frame rate is set to 29.97fps
  65. clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
  66. # making sure the detected scan type is set (detected: bottom field first)
  67. clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_BOTTOM) # bff
  68. clip = core.std.AddBorders(clip=clip, left=0, right=0, top=0, bottom=2) # add borders to archive mod 4 (vsQTGMC) - 720x488
  69. # Deinterlacing using QTGMC
  70. clip = qtgmc.QTGMC(Input=clip, Preset="Fast", InputType=0, TFF=False, TR2=2, SourceMatch=0, Lossless=0, EZDenoise=10.00, NoisePreset="Fast", opencl=True, TR0=2, TR1=2, Rep0=1, Rep1=0, Rep2=4, DCT=5, ThSCD1=300, ThSCD2=110, Sbb=0, NoiseProcess=2, GrainRestore=0.0, NoiseDeint="bob") # new fps: 29.97
  71. clip = core.std.Crop(clip=clip, left=0, right=0, top=0, bottom=2) # removing added borders from mod requirement (vsQTGMC) - 720x486
  72. # Making sure content is preceived as frame based
  73. clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # progressive
  74. clip = clip[::2] # selecting previously even frames
  75. # adjusting frame with SelectEvery
  76. clip = core.std.SelectEvery(clip=clip, cycle=5, offsets=[0, 1, 4])
  77. clip = core.std.AssumeFPS(clip=clip,fpsnum=8991, fpsden=500)# new fps: 17.982
  78. # Chroma adjustment using ChromaShiftSP
  79. clip = chromashift.ChromaShiftSP(clip=clip, X=4.00)
  80. # changing range from limited to full range for vsVSMLRTFilter
  81. clip = core.resize.Bicubic(clip, range_in_s="limited", range_s="full")
  82. # setting color range to PC (full) range.
  83. clip = core.std.SetFrameProps(clip=clip, _ColorRange=vs.RANGE_FULL)
  84. # adjusting color space from YUV422P10 to RGBH for vsVSMLRTFilter
  85. clip = core.resize.Bicubic(clip=clip, format=vs.RGBH, matrix_in_s="470bg", range_s="full")
  86. # filtering using VSMLRT
  87. clip = vsmlrt.inference([clip],network_path="F:/Hybrid/64bit/onnx_models/1x_BleedOut_Compact_300k_net_g.onnx", backend=Backend.TRT(fp16=True,device_id=0,bf16=False,num_streams=1,verbose=True,use_cuda_graph=False,workspace=1073741824,builder_optimization_level=3,engine_folder="J:/TRT")) # 720x486
  88. # changing range from full to limited range for vsVSMLRTFilter
  89. clip = core.resize.Bicubic(clip, range_in_s="full", range_s="limited")
  90. # making sure 0-1 limits are respected
  91. clip = core.vszip.Limiter(clip=clip, min=[0,0,0], max=[1,1,1])
  92. # adjusting color space from RGBH to RGB24 for vsSSIQ
  93. clip = core.resize.Bicubic(clip=clip, format=vs.RGB24, dither_type="error_diffusion")
  94. # rainbow removal using SSIQ
  95. clip = core.ssiq.SSIQ(clip=clip, strength=300, interlaced=0)
  96. clip = core.std.Crop(clip=clip, left=6, right=14, top=4, bottom=8)# cropping to 700x474
  97. # contrast sharpening using CAS
  98. clip = core.cas.CAS(clip=clip, sharpness=0.700)
  99. clip = core.lghost.LGhost(clip, mode=[1,1,1], shift=[2,4,6], intensity=[10,10,10], planes=[0])
  100. # adjusting color space from RGB24 to YUV444P16 for vsDeHalo_Alpha
  101. clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="470bg", range_in_s="limited")
  102. # applying dehalo using DeHalo_alpha
  103. clip = dehalo.DeHalo_alpha(clip, rx=3.00, ry=3.00)
  104. clip = core.std.AddBorders(clip=clip, left=2, right=2, top=2, bottom=4) # add borders to archive mod 8 (vsBasicVSRPPFilter) - 704x480
  105. # adjusting color space from YUV444P16 to RGBH for vsBasicVSRPPFilter
  106. clip = core.resize.Bicubic(clip=clip, format=vs.RGBH, matrix_in_s="470bg", range_s="limited")
  107. # Quality enhancement using BasicVSR++
  108. from vsbasicvsrpp import basicvsrpp as BasicVSRPP
  109. clip = BasicVSRPP(clip=clip, model=4, length=16)
  110. clip = core.std.Crop(clip=clip, left=2, right=2, top=2, bottom=4) # removing added borders from mod requirement (vsBasicVSRPPFilter) - 700x474
  111. # adjusting color space from RGBH to YUV444P16 for vsFastLineDarken
  112. clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="470bg", range_in_s="limited")
  113. # Using FastLineDarkenMOD for line darkening
  114. clip = linedarken.FastLineDarkenMOD(c=clip,strength=60)
  115. clip = core.misc.SCDetect(clip=clip,threshold=0.100)
  116. # adjusting color space from YUV444P16 to RGBS for vsRIFE
  117. clip = core.resize.Bicubic(clip=clip, format=vs.RGBS, matrix_in_s="470bg", range_s="limited")
  118. # adjusting frame count&rate with RIFE, target fps: 23.976fps
  119. clip = core.rife.RIFE(clip, model=58, fps_num=24000, fps_den=1001, sc=True) # new fps: 23.976
  120. clip = core.std.AddBorders(clip=clip, left=0, right=0, top=1, bottom=1) # add borders to archive mod 4 (NNEDI3(CL)) - 700x476
  121. # resizing using NNEDI3CL
  122. # current: 700x476 target: 1920x1300 -> pow: 4
  123. clip = edi_rpow2.nnedi3cl_rpow2(clip=clip, rfactor=4, nsize=3, nns=4) # 2800x1904
  124. clip = core.std.Crop(clip=clip, left=0, right=0, top=4, bottom=4) # removing added borders from mod requirement (NNEDI3(CL)) - 2800x1896
  125. # resizing 2800x1896 to 1920x1300
  126. clip = core.fmtc.resample(clip=clip, w=1920, h=1300, kernel="spline64", interlaced=False, interlacedd=False)
  127. # adjusting output color from: RGBS to YUV420P10 for NVEncModel
  128. clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, matrix_s="470bg", range_in_s="limited", dither_type="error_diffusion")
  129. # set output frame rate to 23.976fps (progressive)
  130. clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001)
  131. # output
  132. clip.set_output()
Advertisement
Add Comment
Please, Sign In to add comment