Advertisement
Guest User

Untitled

a guest
Aug 24th, 2024
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.04 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/libfftw3-3.dll")
  13. Dllref = ctypes.windll.LoadLibrary("F:/Hybrid/64bit/vsfilters/Support/libfftw3f-3.dll")
  14. # loading plugins
  15. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DebandFilter/Flash3kDeband/flash3kyuu_deband.dll")
  16. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SharpenFilter/AWarpSharp2/libawarpsharp2.dll")
  17. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/TCanny.dll")
  18. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/ZSmooth/zsmooth.dll")
  19. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/vcm.dll")
  20. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libmotionmask.dll")
  21. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/GrainFilter/RemoveGrain/RemoveGrainVS.dll")
  22. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/GrainFilter/AddGrain/AddGrain.dll")
  23. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/DFTTest/DFTTest.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/Support/EEDI3m_opencl.dll")# vsQTGMC
  26. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/ResizeFilter/nnedi3/NNEDI3CL.dll")
  27. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libmvtools.dll")
  28. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/scenechange.dll")
  29. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
  30. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/MiscFilter/MiscFilters/MiscFilters.dll")
  31. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DeinterlaceFilter/Bwdif/Bwdif.dll")
  32. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/BestSource/BestSource.dll")
  33. # Import scripts
  34. import mclean
  35. import mvsfunc
  36. import muvsfunc
  37. import havsfunc
  38. import validate
  39. # Source: 'C:\Users\Selur\Desktop\test2.mov'
  40. # Current color space: YUV444P12, bit depth: 12, resolution: 720x576, frame rate: 25fps, scanorder: top field first, yuv luminance scale: limited, matrix: 709, transfer: bt.709, primaries: bt.709
  41. # Loading C:\Users\Selur\Desktop\test2.mov using BestSource (NOT recommended and untested!)
  42. clip = core.bs.VideoSource(source="C:/Users/Selur/Desktop/test2.mov", cachepath="J:/tmp/test2.json", track=0)
  43. frame = clip.get_frame(0)
  44. # setting color matrix to 709.
  45. clip = core.std.SetFrameProps(clip, _Matrix=vs.MATRIX_BT709)
  46. # setting color transfer (vs.TRANSFER_BT709), if it is not set.
  47. if validate.transferIsInvalid(clip):
  48. clip = core.std.SetFrameProps(clip=clip, _Transfer=vs.TRANSFER_BT709)
  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 TV (limited) range.
  53. clip = core.std.SetFrameProps(clip=clip, _ColorRange=vs.RANGE_LIMITED)
  54. # making sure frame rate is set to 25fps
  55. clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
  56. # making sure the detected scan type is set (detected: top field first)
  57. clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_TOP) # tff
  58. # Deinterlacing using QTGMC
  59. clip = havsfunc.QTGMC(Input=clip, Preset="Fast", TFF=True, opencl=True) # new fps: 50
  60. # Making sure content is preceived as frame based
  61. clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # progressive
  62. clip = core.std.CropRel(clip=clip, left=12, right=12, top=2, bottom=2)# cropping to 696x572
  63. ## Starting applying 'MotionMask' masked filtering for vsBalanceBorders
  64. clipMask = clip
  65. clipMask = core.motionmask.MotionMask(clip=clipMask, th1=10, th2=10, tht=15)
  66. clipMask = core.std.Minimum(clipMask)
  67. clipMask = core.resize.Bicubic(clip=clipMask, format=vs.GRAY16, range_s="limited")
  68. clipMask = core.std.InvertMask(clipMask)
  69. clipFiltered = clip
  70. # Fix bright and dark line artifacts near the border of an image using BalanceBorders
  71. clipFiltered = havsfunc.bbmod(c=clipFiltered,cLeft=64,cTop=0,cRight=0,cBottom=0,thresh=30)
  72. clipMask = core.resize.Bicubic(clip=clipMask, format=vs.YUV444P12, range_s="limited", dither_type="error_diffusion")
  73. clip = core.std.MaskedMerge(clip, clipFiltered, clipMask) # MotionMask
  74. ## Finished applying 'MotionMask' masked filtering for vsBalanceBorders
  75. # denoising using mClean
  76. clip = mclean.mClean(clip=clip)
  77. # Resizing using 10 - bicubic spline
  78. clip = core.fmtc.resample(clip=clip, kernel="spline16", w=1280, h=964, interlaced=False, interlacedd=False) # resolution 1280x964 before YUV444P12 after YUV444P16
  79. # adjusting output color from: YUV444P16 to YUV420P10 for NVEncModel
  80. clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, range_s="limited", dither_type="error_diffusion")
  81. # set output frame rate to 50fps (progressive)
  82. clip = core.std.AssumeFPS(clip=clip, fpsnum=50, fpsden=1)
  83. # output
  84. clip.set_output()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement