Advertisement
Guest User

Untitled

a guest
May 9th, 2025
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.55 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. # Import scripts folder
  9. scriptPath = 'F:/Hybrid/64bit/vsscripts'
  10. sys.path.insert(0, os.path.abspath(scriptPath))
  11. # Loading Support Files
  12. Dllref = ctypes.windll.LoadLibrary("F:/Hybrid/64bit/vsfilters/Support/libfftw3f-3.dll")
  13. # loading plugins
  14. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libvs_placebo.dll")
  15. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SharpenFilter/AWarpSharp2/libawarpsharp2.dll")
  16. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/TTempSmooth/TTempSmooth.dll")
  17. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/DCTFilter.dll")
  18. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DeblockFilter/DeblockPP7/DeblockPP7.dll")
  19. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DeblockFilter/Deblock/Deblock.dll")
  20. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/EEDI3m_opencl.dll")
  21. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/ResizeFilter/nnedi3/NNEDI3CL.dll")
  22. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/MiscFilter/MiscFilters/MiscFilters.dll")
  23. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/ZSmooth/zsmooth.dll")
  24. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/GrainFilter/AddGrain/AddGrain.dll")
  25. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/NEO_FFT3DFilter/neo-fft3d.dll")
  26. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/DFTTest/DFTTest.dll")
  27. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libmvtools.dll")
  28. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
  29. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/akarin.dll")
  30. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/LSmashSource/LSMASHSource.dll")
  31. # Import scripts
  32. import antiAliasing
  33. import denoise
  34. import qtgmc
  35. import validate
  36. # Source: 'C:\Users\Selur\Desktop\sample.mov'
  37. # Current color space: YUV422P10, bit depth: 10, resolution: 720x486, frame rate: 59.94fps, scanorder: progressive, yuv luminance scale: limited, matrix: 470bg, transfer: bt.601, primaries: bt.601 ntsc, format: prores
  38. # Loading C:\Users\Selur\Desktop\sample.mov using LibavSMASHSource
  39. clip = core.lsmas.LibavSMASHSource(source="C:/Users/Selur/Desktop/sample.mov")
  40. frame = clip.get_frame(0)
  41. # setting color matrix to 470bg.
  42. clip = core.std.SetFrameProps(clip, _Matrix=vs.MATRIX_BT470_BG)
  43. # setting color transfer (vs.TRANSFER_BT601), if it is not set.
  44. if validate.transferIsInvalid(clip):
  45. clip = core.std.SetFrameProps(clip=clip, _Transfer=vs.TRANSFER_BT601)
  46. # setting color primaries info (to vs.PRIMARIES_BT470_BG), if it is not set.
  47. if validate.primariesIsInvalid(clip):
  48. clip = core.std.SetFrameProps(clip=clip, _Primaries=vs.PRIMARIES_BT470_BG)
  49. # setting color range to TV (limited) range.
  50. clip = core.std.SetFrameProps(clip=clip, _ColorRange=vs.RANGE_LIMITED)
  51. # making sure frame rate is set to 59.94fps
  52. clip = core.std.AssumeFPS(clip=clip, fpsnum=60000, fpsden=1001)
  53. # making sure the detected scan type is set (detected: progressive)
  54. clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # progressive
  55. # adjusting frame with SelectEvery
  56. clip = core.std.SelectEvery(clip=clip, cycle=2, offsets=[0])
  57. clip = core.std.AssumeFPS(clip=clip,fpsnum=30000, fpsden=1001)# new fps: 29.97
  58. clip = core.std.AddBorders(clip=clip, left=0, right=0, top=0, bottom=2) # add borders to archive mod 4 (vsQTGMCFilter) - 720x488
  59. # Denoising using QTGMC
  60. clip = qtgmc.QTGMC(Input=clip, Preset="Fast", InputType=3, TR2=1, TFF=False, SourceMatch=0, Lossless=0, opencl=True)
  61. clip = core.std.Crop(clip=clip, left=0, right=0, top=0, bottom=2) # removing borders (vsQTGMCFilter) - 720x486
  62. # applying delocking using Deblock
  63. clip = core.deblock.Deblock(clip=clip)
  64. # applying deblocking using DeblockPP7
  65. clip = core.pp7.DeblockPP7(clip=clip, qp=25.00)
  66. clip = core.std.Crop(clip=clip, left=2, right=12, top=6, bottom=6)# cropping to 706x474
  67. clip = core.std.AddBorders(clip=clip, left=0, right=2, top=0, bottom=2) # add borders to archive mod 4 (vsMCTemporalDenoise) - 708x476
  68. # denoising using MCTemporalDenoise
  69. clip = denoise.MCTemporalDenoise(i=clip, settings="very high", radius=6, sigma=16.00, twopass=True, limit=0, limit2=0, post=0.00, chroma=True, ncpu=10)
  70. clip = core.std.Crop(clip=clip, left=0, right=2, top=0, bottom=2) # removing borders (vsMCTemporalDenoise) - 706x474
  71. # sharpening using AWarpSharp2
  72. clip = core.warp.AWarpSharp2(clip=clip, blur=2, depth=24, chroma=True)
  73. # adjusting color space from YUV422P10 to YUV444P16 for vsGLSLDarken
  74. clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, range_s="limited")
  75. # Using Anime4k Darken GLSL filter for line darkening
  76. with open("F:/Hybrid/64bit/vsfilters/GLSL/parameterized/Anime4K_Darken_HQ.glsl") as glslf:
  77. glsl = glslf.read()
  78. glsl = glsl.replace('#define STRENGTH 1.5', '#define STRENGTH 5')
  79. clip = core.placebo.Shader(clip=clip, shader_s=glsl, width=clip.width, height=clip.height)
  80. # Resizing using 10 - bicubic spline
  81. clip = core.fmtc.resample(clip=clip, kernel="spline16", w=704, h=520, interlaced=False, interlacedd=False) # resolution 704x520 before YUV444P16 after YUV444P16
  82. # Anti Aliasing using DAA
  83. clip = antiAliasing.daa(c=clip, opencl=True)
  84. # adjusting output color from: YUV444P16 to YUV420P10 for NVEncModel
  85. clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, range_s="limited", dither_type="error_diffusion")
  86. # set output frame rate to 29.97fps (progressive)
  87. clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
  88. # output
  89. clip.set_output()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement