Guest User

Untitled

a guest
Sep 7th, 2025
10
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.96 KB | None | 0 0
  1. # Imports
  2. import vapoursynth as vs
  3. # getting Vapoursynth core
  4. import ctypes
  5. import sys
  6. import os
  7. core = vs.core
  8. # Limit frame cache to 48473MB
  9. core.max_cache_size = 48473
  10. # Import scripts folder
  11. scriptPath = 'F:/Hybrid/64bit/vsscripts'
  12. sys.path.insert(0, os.path.abspath(scriptPath))
  13. # Loading Support Files
  14. Dllref = ctypes.windll.LoadLibrary("F:/Hybrid/64bit/vsfilters/Support/libfftw3f-3.dll")
  15. # loading plugins
  16. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SharpenFilter/AWarpSharp2/libawarpsharp2.dll")
  17. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libvs_placebo.dll")
  18. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/vszip.dll")
  19. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/ZSmooth/zsmooth.dll")
  20. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DeinterlaceFilter/Support/libftf.dll")
  21. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DeinterlaceFilter/TIVTC/libtivtc.dll")
  22. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/MiscFilter/MiscFilters/MiscFilters.dll")
  23. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/GrainFilter/AddGrain/AddGrain.dll")
  24. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/NEO_FFT3DFilter/neo-fft3d.dll")
  25. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/DFTTest/DFTTest.dll")
  26. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/EEDI3m_opencl.dll")# DeinterlaceFilter-Selector
  27. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/ResizeFilter/nnedi3/NNEDI3CL.dll")
  28. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libmvtools.dll")
  29. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
  30. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/akarin.dll")
  31. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV_AVX2.dll")
  32. # Import scripts
  33. import linedarken
  34. import edi_rpow2
  35. import dehalo
  36. import SpotLess
  37. import qtgmc
  38. import validate
  39. # Source: 'C:\Users\Selur\Desktop\clip2.mkv'
  40. # Current color space: YUV420P8, bit depth: 8, resolution: 640x480, frame rate: 29.97fps, scanorder: telecine, yuv luminance scale: full, matrix: 470bg, format: AVC
  41. # Loading C:\Users\Selur\Desktop\clip2.mkv using DGSource
  42. clip = core.dgdecodenv.DGSource("J:/tmp/mkv_c04bb5d2fe0a9d0ab6f7847f59780117_853323747.dgi",fieldop=0)# 29.97 fps, scanorder: telecine
  43. frame = clip.get_frame(0)
  44. # setting color matrix to 470bg.
  45. clip = core.std.SetFrameProps(clip, _Matrix=vs.MATRIX_BT470_BG)
  46. # setting color transfer (vs.TRANSFER_BT601), if it is not set.
  47. if validate.transferIsInvalid(clip):
  48. clip = core.std.SetFrameProps(clip=clip, _Transfer=vs.TRANSFER_BT601)
  49. # setting color primaries info (to vs.PRIMARIES_BT470_BG), if it is not set.
  50. if validate.primariesIsInvalid(clip):
  51. clip = core.std.SetFrameProps(clip=clip, _Primaries=vs.PRIMARIES_BT470_BG)
  52. # setting color range to PC (full) range.
  53. clip = core.std.SetFrameProps(clip=clip, _ColorRange=vs.RANGE_FULL)
  54. # making sure frame rate is set to 29.97fps
  55. clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
  56. # making sure the detected scan type is set (detected: telecine)
  57. clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_TOP) # tff
  58. # changing range from full to limited range for
  59. clip = core.resize.Bicubic(clip, format=vs.YUV420P8, matrix_s="470bg",range_in_s="full", range_s="limited")
  60. # setting color range to TV (limited) range.
  61. clip = core.std.SetFrameProps(clip=clip, _ColorRange=vs.RANGE_LIMITED)
  62. clip2clip = clip
  63. clip2clip = qtgmc.QTGMC(Input=clip2clip, Preset="fast", opencl=True, TFF=False, FPSDivisor=2)
  64. # Deinterlacing using TIVTC
  65. clip = core.tivtc.TFM(clip=clip, mode=5, blockx=32, blocky=32, chroma=True, MI=16, clip2=clip2clip)
  66. clip = core.tivtc.TDecimate(clip=clip, mode=1, blockx=16, blocky=16)# new fps: 23.976
  67. # Making sure content is preceived as frame based
  68. clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # progressive
  69. # adjusting bit depth to 32bit
  70. clip = core.fmtc.bitdepth(clip=clip, bits=32)
  71. # Fix telecined fades
  72. clip = core.ftf.FixFades(clip=clip)
  73. # adjusting bit depth back to 8bit
  74. clip = core.fmtc.bitdepth(clip=clip, bits=8)
  75. # Spot removal using SpotLess
  76. clip = SpotLess.SpotLess(clip=clip, radT=3, rec=True, pel=1, smoother="zsmooth")
  77. # applying dehalo using DeHalo_alpha
  78. clip = dehalo.DeHalo_alpha(clip)
  79. # adjusting color space from YUV420P8 to YUV444P16 for vsGLSLLumaSharpen
  80. clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16)
  81. with open("F:/Hybrid/64bit/vsfilters/GLSL/parameterized/LumaSharpenHook.glsl") as glslf:
  82. glsl = glslf.read()
  83. glsl = glsl.replace('#define sharp_strength 0.30', '#define sharp_strength 1.5000')
  84. glsl = glsl.replace('#define sharp_clamp 0.035', '#define sharp_clamp 0.0350')
  85. glsl = glsl.replace('#define pattern 2', '#define pattern 4')
  86. glsl = glsl.replace('#define offset_bias 1.0', '#define offset_bias 1.0000')
  87. clip = core.placebo.Shader(clip=clip, shader_s=glsl, width=clip.width, height=clip.height)
  88. # resizing using NNEDI3CL
  89. # current: 640x480 target: 1280x960 -> pow: 2
  90. clip = edi_rpow2.nnedi3cl_rpow2(clip=clip, rfactor=2, nsize=3, nns=4) # 1280x960
  91. # adjusting color space from YUV444P16 to RGBH for vsBasicVSRPPFilter
  92. clip = core.resize.Bicubic(clip=clip, format=vs.RGBH, matrix_in_s="470bg", range_in_s="limited", range_s="limited")
  93. # Quality enhancement using BasicVSR++
  94. from vsbasicvsrpp import basicvsrpp as BasicVSRPP
  95. clip = BasicVSRPP(clip=clip, model=4)
  96. # adjusting color space from RGBH to YUV444P16 for vsToon
  97. clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="470bg", range_in_s="full", range_s="limited") # additional resize to allow target color sampling
  98. # line darkening using Toon
  99. clip = linedarken.Toon(input=clip)
  100. # adjusting output color from: YUV444P16 to YUV420P10 for NVEncModel
  101. clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, dither_type="error_diffusion")
  102. # set output frame rate to 23.976fps (progressive)
  103. clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001)
  104. # output
  105. clip.set_output()
Advertisement
Add Comment
Please, Sign In to add comment