Advertisement
Guest User

Untitled

a guest
Apr 28th, 2025
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.47 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/MiscFilter/MiscFilters/MiscFilters.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/Deblock/Deblock.dll")
  19. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DebandFilter/Flash3kDeband/flash3kyuu_deband.dll")
  20. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/ZSmooth/zsmooth.dll")
  21. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/GrainFilter/AddGrain/AddGrain.dll")
  22. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/NEO_FFT3DFilter/neo-fft3d.dll")
  23. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/DFTTest/DFTTest.dll")
  24. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/EEDI3m_opencl.dll")# vsQTGMC
  25. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/ResizeFilter/nnedi3/NNEDI3CL.dll")
  26. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libmvtools.dll")
  27. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
  28. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DeinterlaceFilter/Bwdif/Bwdif.dll")
  29. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/LSmashSource/LSMASHSource.dll")
  30. # defining beforeDeCross-function - START
  31. def beforeDeCross(clip):
  32. clip = core.std.Expr(clip, expr=["x 180 > x 0.8 * 40 + x ?"])
  33. return clip
  34. # defining beforeDeCross-function - END
  35.  
  36. # Import scripts
  37. import denoise
  38. import artifacts
  39. import color
  40. import qtgmc
  41. import validate
  42. # Source: 'C:\Users\Selur\Desktop\OriginalVideoSample.avi'
  43. # Current color space: YUV422P8, bit depth: 8, resolution: 720x480, frame rate: 29.97fps, scanorder: top field first, yuv luminance scale: limited, matrix: 470bg, format: Lagarith
  44. # Loading C:\Users\Selur\Desktop\OriginalVideoSample.avi using LWLibavSource
  45. clip = core.lsmas.LWLibavSource(source="C:/Users/Selur/Desktop/OriginalVideoSample.avi", format="YUV422P8", stream_index=0, cache=0, prefer_hw=0)
  46. frame = clip.get_frame(0)
  47. # setting color matrix to 470bg.
  48. clip = core.std.SetFrameProps(clip, _Matrix=vs.MATRIX_BT470_BG)
  49. # setting color transfer (vs.TRANSFER_BT601), if it is not set.
  50. if validate.transferIsInvalid(clip):
  51. clip = core.std.SetFrameProps(clip=clip, _Transfer=vs.TRANSFER_BT601)
  52. # setting color primaries info (to vs.PRIMARIES_BT470_BG), if it is not set.
  53. if validate.primariesIsInvalid(clip):
  54. clip = core.std.SetFrameProps(clip=clip, _Primaries=vs.PRIMARIES_BT470_BG)
  55. # setting color range to TV (limited) range.
  56. clip = core.std.SetFrameProps(clip=clip, _ColorRange=vs.RANGE_LIMITED)
  57. # making sure frame rate is set to 29.97fps
  58. clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
  59. # making sure the detected scan type is set (detected: top field first)
  60. clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_TOP) # tff
  61. clip = beforeDeCross(clip)
  62. # Deinterlacing using QTGMC
  63. clip = qtgmc.QTGMC(Input=clip, Preset="Fast", TFF=True, opencl=True) # new fps: 59.94
  64. # Making sure content is preceived as frame based
  65. clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # progressive
  66. # adjusting color space from YUV422P8 to RGB24 for vsLevels
  67. clip = core.resize.Bicubic(clip=clip, format=vs.RGB24, matrix_in_s="470bg", range_s="limited")
  68. # adjusting color using Levels on RGB24 (8 bit)
  69. clip = core.std.Levels(clip=clip, min_in=32, max_in=235, min_out=16, max_out=235)
  70. # adjusting color space from RGB24 to YUV444PS for vsTweak
  71. clip = core.resize.Bicubic(clip=clip, format=vs.YUV444PS, matrix_s="470bg", range_s="limited")
  72. # adjusting color using Tweak
  73. clip = color.Tweak(clip=clip, hue=0.00, sat=0.90, cont=1.00, bright=-0.0392157, coring=True)
  74. # adjusting color space from YUV444PS to YUV444P16 for vsSmoothLevels
  75. clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, range_s="limited", dither_type="error_diffusion")
  76. # adjusting color using SmoothLevels
  77. clip = color.SmoothLevels(input=clip, input_low=4096, input_high=60160, output_low=4096, output_high=60160, gamma=0.80, Ecurve=0)
  78. clip = artifacts.DeSpot(o=clip)
  79. clip = core.std.Crop(clip=clip, left=8, right=14, top=4, bottom=4)# cropping to 698x472
  80. clip = core.std.AddBorders(clip=clip, left=0, right=2, top=0, bottom=0) # add borders to archive mod 4 (vsMCTemporalDenoise) - 700x472
  81. # denoising using MCTemporalDenoise
  82. clip = denoise.MCTemporalDenoise(i=clip, settings="very high", ncpu=10)
  83. clip = core.std.Crop(clip=clip, left=0, right=2, top=0, bottom=0) # removing borders (vsMCTemporalDenoise) - 698x472
  84. # Resizing using 10 - bicubic spline
  85. clip = core.fmtc.resample(clip=clip, kernel="spline16", w=1280, h=866, interlaced=False, interlacedd=False) # resolution 1280x866 before YUV444P16 after YUV444P16
  86. clip = core.std.AddBorders(clip=clip, left=0, right=0, top=2, bottom=4) # add borders to archive mod 8 (vsBasicVSRPPFilter) - 1280x872
  87. # adjusting color space from YUV444P16 to RGBH for vsBasicVSRPPFilter
  88. clip = core.resize.Bicubic(clip=clip, format=vs.RGBH, matrix_in_s="470bg", range_s="limited")
  89. # Quality enhancement using BasicVSR++
  90. from vsbasicvsrpp import basicvsrpp as BasicVSRPP
  91. clip = BasicVSRPP(clip=clip, model=4)
  92. clip = core.std.Crop(clip=clip, left=0, right=0, top=2, bottom=4) # removing borders (vsBasicVSRPPFilter) - 1280x866
  93. # adjusting color space from RGBH to YUV444P16 for vsGLSLFilmGrain
  94. clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="470bg", range_s="limited")
  95. with open("F:/Hybrid/64bit/vsfilters/GLSL/parameterized/filmgrain.glsl") as glslf:
  96. glsl = glslf.read()
  97. glsl = glsl.replace('#define INTENSITY 0.05', '#define INTENSITY 0.03')
  98. clip = core.placebo.Shader(clip=clip, shader_s=glsl, width=clip.width, height=clip.height)
  99. # adjusting output color from: YUV444P16 to YUV420P10 for NVEncModel
  100. clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, range_s="limited", dither_type="error_diffusion")
  101. # set output frame rate to 59.94fps (progressive)
  102. clip = core.std.AssumeFPS(clip=clip, fpsnum=60000, fpsden=1001)
  103. # output
  104. clip.set_output()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement