Advertisement
Guest User

CleanUp

a guest
Jan 6th, 2023
13
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.42 KB | None | 0 0
  1. # Imports
  2. import vapoursynth as vs
  3. import os
  4. import ctypes
  5. # Loading Support Files
  6. Dllref = ctypes.windll.LoadLibrary("i:/Hybrid/64bit/vsfilters/Support/libfftw3f-3.dll")
  7. import sys
  8. # getting Vapoursynth core
  9. core = vs.core
  10. # Import scripts folder
  11. scriptPath = 'i:/Hybrid/64bit/vsscripts'
  12. sys.path.insert(0, os.path.abspath(scriptPath))
  13. # Loading Plugins
  14. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/Support/TCanny.dll")
  15. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/DeblockFilter/DeblockPP7/DeblockPP7.dll")
  16. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/GrainFilter/RemoveGrain/RemoveGrainVS.dll")
  17. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/GrainFilter/AddGrain/AddGrain.dll")
  18. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/DenoiseFilter/FFT3DFilter/fft3dfilter.dll")
  19. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/DenoiseFilter/DFTTest/DFTTest.dll")
  20. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/Support/EEDI3m_opencl.dll")
  21. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/ResizeFilter/nnedi3/NNEDI3CL.dll")
  22. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/Support/libmvtools.dll")
  23. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/Support/scenechange.dll")
  24. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
  25. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/MiscFilter/MiscFilters/MiscFilters.dll")
  26. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/DeinterlaceFilter/Bwdif/Bwdif.dll")
  27. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/SourceFilter/LSmashSource/vslsmashsource.dll")
  28. # defining beforeVFM-function - START
  29. def beforeVFM(clip):
  30. [Y, U, V] = core.std.SplitPlanes(clip)
  31. U = core.resize.Bilinear(U, height=clip.height/2.5)
  32. U = core.resize.Bilinear(U, height=clip.height)
  33. V = core.resize.Bilinear(V, height=clip.height/2.5)
  34. V = core.resize.Bilinear(V, height=clip.height)
  35. clip = core.std.ShufflePlanes(clips=[Y, U, V], planes=[0, 0, 0], colorfamily=vs.YUV)
  36. return clip
  37. # defining beforeVFM-function - END
  38.  
  39. # Import scripts
  40. import mcdegrainsharp
  41. import lostfunc
  42. import havsfunc
  43. # source: 'C:\Users\Selur\Desktop\sample-clip.mov.mov'
  44. # current color space: YUV422P10, bit depth: 10, resolution: 720x576, fps: 25, color matrix: 170m, yuv luminance scale: limited, scanorder: top field first
  45. # Loading C:\Users\Selur\Desktop\sample-clip.mov.mov using LibavSMASHSource
  46. clip = core.lsmas.LibavSMASHSource(source="C:/Users/Selur/Desktop/sample-clip.mov.mov")
  47. # Setting color matrix to 170m.
  48. clip = core.std.SetFrameProps(clip, _Matrix=6)
  49. clip = clip if not core.text.FrameProps(clip,'_Transfer') else core.std.SetFrameProps(clip, _Transfer=6)
  50. clip = clip if not core.text.FrameProps(clip,'_Primaries') else core.std.SetFrameProps(clip, _Primaries=5)
  51. # Setting color range to TV (limited) range.
  52. clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
  53. # making sure frame rate is set to 25
  54. clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
  55. clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=2)
  56. # setting field order to what QTGMC should assume (top field first)
  57. clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=2)
  58. # Deinterlacing using QTGMC
  59. clip = havsfunc.QTGMC(Input=clip, Preset="Fast", TFF=True, opencl=True) # new fps: 50
  60. # make sure content is preceived as frame based
  61. clip = core.std.SetFieldBased(clip, 0)
  62. clip = beforeVFM(clip)
  63. # applying deblocking using DeblockPP7
  64. clip = core.pp7.DeblockPP7(clip=clip, qp=4.00, mode=2)
  65. # adjusting color space from YUV422P10 to YUV444P16 for vsDeSpot
  66. clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, range_s="limited")
  67. clip = lostfunc.DeSpot(o=clip)
  68. # cropping the video to 696x572
  69. clip = core.std.CropRel(clip=clip, left=12, right=12, top=2, bottom=2)
  70. # Fix bright and dark line artifacts near the border of an image using BalanceBorders
  71. clip = havsfunc.bbmod(c=clip,cLeft=16,cTop=0,cRight=8,cBottom=16)
  72. # removing grain using MCDegrain
  73. clip = mcdegrainsharp.mcdegrainsharp(clip=clip)
  74. # Resizing using 10 - bicubic spline
  75. clip = core.fmtc.resample(clip=clip, kernel="spline16", w=1440, h=1080, interlaced=False, interlacedd=False) # resolution 1440x1080
  76. # adjusting output color from: YUV444P16 to YUV420P10 for x265Model
  77. clip = core.resize.Bicubic(clip=clip, dither_type="none", format=vs.YUV420P10, range_s="limited")
  78. # set output frame rate to 50fps
  79. clip = core.std.AssumeFPS(clip=clip, fpsnum=50, fpsden=1)
  80. # Output
  81. clip.set_output()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement