Advertisement
Guest User

Untitled

a guest
Jul 20th, 2024
20
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.54 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/CTMF/CTMF.dll")
  17. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/KNLMeansCL/KNLMeansCL.dll")
  18. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/DCTFilter.dll")
  19. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DeblockFilter/Deblock/Deblock.dll")
  20. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/GrainFilter/RemoveGrain/RemoveGrainVS.dll")
  21. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/GrainFilter/AddGrain/AddGrain.dll")
  22. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/DFTTest/DFTTest.dll")
  23. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/NEO_FFT3DFilter/neo-fft3d.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/scenechange.dll")
  28. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
  29. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/MiscFilter/MiscFilters/MiscFilters.dll")
  30. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DeinterlaceFilter/Bwdif/Bwdif.dll")
  31. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/LSmashSource/LSMASHSource.dll")
  32. # Import scripts
  33. import masked
  34. import chromashift
  35. import autowhite
  36. import havsfunc
  37. import validate
  38. # Source: 'C:\Users\Selur\Desktop\NewNaughty-sample.mov'
  39. # Current color space: YUV422P10, bit depth: 10, resolution: 720x576, frame rate: 25fps, scanorder: bottom field first, yuv luminance scale: limited, matrix: 470bg, transfer: bt.709, primaries: bt.601 pal
  40. # Loading C:\Users\Selur\Desktop\NewNaughty-sample.mov using LibavSMASHSource
  41. clip = core.lsmas.LibavSMASHSource(source="C:/Users/Selur/Desktop/NewNaughty-sample.mov")
  42. frame = clip.get_frame(0)
  43. # Setting detected color matrix (470bg).
  44. clip = core.std.SetFrameProps(clip=clip, _Matrix=5)
  45. # setting color transfer (709), if it is not set.
  46. if validate.transferIsInvalid(clip):
  47. clip = core.std.SetFrameProps(clip=clip, _Transfer=1)
  48. # setting color primaries info (to 470), if it is not set.
  49. if validate.primariesIsInvalid(clip):
  50. clip = core.std.SetFrameProps(clip=clip, _Primaries=5)
  51. # setting color range to TV (limited) range.
  52. clip = core.std.SetFrameProps(clip=clip, _ColorRange=1)
  53. # making sure frame rate is set to 25fps
  54. clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
  55. # making sure the detected scan type is set (detected: bottom field first)
  56. clip = core.std.SetFrameProps(clip=clip, _FieldBased=1) # bff
  57. # Deinterlacing using QTGMC
  58. clip = havsfunc.QTGMC(Input=clip, Preset="Fast", InputType=0, TFF=False, TR2=0, SourceMatch=0, Lossless=0, EZDenoise=4.00, NoisePreset="Fast", opencl=True) # new fps: 50
  59. # Making sure content is preceived as frame based
  60. clip = core.std.SetFrameProps(clip=clip, _FieldBased=0) # progressive
  61. # adjusting color space from YUV422P10 to RGB30 for vsAutoWhite
  62. clip = core.resize.Bicubic(clip=clip, format=vs.RGB30, matrix_in_s="470bg", range_s="limited")
  63. # adjustint colors using AutoWhite
  64. clip = autowhite.AutoWhite(clip=clip)
  65. # adjusting color space from RGB30 to YUV444P10 for vsChromaShiftSP
  66. clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P10, matrix_s="470bg", range_s="limited")
  67. # Chroma adjustment using ChromaShiftSP
  68. clip = chromashift.ChromaShiftSP(clip=clip, X=0.50)
  69. # applying deblocking using DeBlock QED
  70. clip = havsfunc.Deblock_QED(clip)
  71. clip = core.std.CropRel(clip=clip, left=20, right=24, top=8, bottom=4)# cropping to 676x564
  72. # denoising using KNLMeansCL
  73. ## Starting applying 'limit' masked filtering for vsKNLMeansCL
  74. clipMask = clip
  75. clipMask = core.resize.Bicubic(clip=clipMask, format=vs.GRAY16, range_s="limited")
  76. clipMask = core.std.BinarizeMask(clipMask, 25600)
  77. clipFiltered = clip
  78. clipFiltered = havsfunc.KNLMeansCL(clip=clipFiltered, d=3)
  79. clipMask = core.resize.Bicubic(clip=clipMask, format=vs.YUV444P10, range_s="limited", dither_type="error_diffusion")
  80. clip = core.std.MaskedMerge(clip, clipFiltered, clipMask) # LimitMask
  81. ## Finished applying 'LimitMask' masked filtering for vsKNLMeansCL
  82. # applying dehalo using YAHR
  83. clip = havsfunc.YAHR(clip, blur=1)
  84. clip = havsfunc.EdgeCleaner(c=clip)
  85. # adjusting color space from YUV444P10 to YUV444P16 for vsGLSLFilmGrain
  86. clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, range_s="limited")
  87. with open("F:/Hybrid/64bit/vsfilters/GLSL/parameterized/filmgrain.glsl") as glslf:
  88. glsl = glslf.read()
  89. glsl = glsl.replace('#define INTENSITY 0.05', '#define INTENSITY 0.02')
  90. clip = core.placebo.Shader(clip=clip, shader_s=glsl, width=clip.width, height=clip.height)
  91. # adjusting output color from: YUV444P16 to YUV420P10 for NVEncModel
  92. clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, range_s="limited", dither_type="error_diffusion")
  93. # set output frame rate to 50fps (progressive)
  94. clip = core.std.AssumeFPS(clip=clip, fpsnum=50, fpsden=1)
  95. # output
  96. clip.set_output()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement