Guest User

Untitled

a guest
Apr 20th, 2025
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.92 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/FrameFilter/RIFE/librife.dll")
  15. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/DePan.dll")
  16. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/RemoveDirt/RemoveDirt.dll")
  17. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/CTMF/CTMF.dll")
  18. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/RemapFramesVapoursynth.dll")
  19. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DeinterlaceFilter/TIVTC/libtivtc.dll")
  20. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/MiscFilter/MiscFilters/MiscFilters.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")# DeinterlaceFilter-Selector
  25. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/ResizeFilter/nnedi3/NNEDI3CL.dll")
  26. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/ZSmooth/zsmooth.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/SourceFilter/LSmashSource/LSMASHSource.dll")
  30. # Import scripts
  31. import stabilize
  32. import removeDirt
  33. import nnedi3_resample
  34. import smdegrain
  35. import SpotLess
  36. import qtgmc
  37. import validate
  38. # Source: 'C:\Users\Selur\Desktop\1985 Golden Book Video - Mercer Mayer's 3 Stories - TRIMMED for testing - A.avi'
  39. # Current color space: YUV422P8, bit depth: 8, resolution: 720x480, frame rate: 29.97fps, scanorder: telecine, yuv luminance scale: limited, matrix: 470bg, format: HuffYUV
  40. # Loading C:\Users\Selur\Desktop\1985 Golden Book Video - Mercer Mayer's 3 Stories - TRIMMED for testing - A.avi using LWLibavSource
  41. clip = core.lsmas.LWLibavSource(source="C:/Users/Selur/Desktop/1985 Golden Book Video - Mercer Mayer's 3 Stories - TRIMMED for testing - A.avi", format="YUV422P8", stream_index=0, cache=0, prefer_hw=0)
  42. frame = clip.get_frame(0)
  43. # setting color matrix to 470bg.
  44. clip = core.std.SetFrameProps(clip, _Matrix=vs.MATRIX_BT470_BG)
  45. # setting color transfer (vs.TRANSFER_BT601), if it is not set.
  46. if validate.transferIsInvalid(clip):
  47. clip = core.std.SetFrameProps(clip=clip, _Transfer=vs.TRANSFER_BT601)
  48. # setting color primaries info (to vs.PRIMARIES_BT470_BG), if it is not set.
  49. if validate.primariesIsInvalid(clip):
  50. clip = core.std.SetFrameProps(clip=clip, _Primaries=vs.PRIMARIES_BT470_BG)
  51. # setting color range to TV (limited) range.
  52. clip = core.std.SetFrameProps(clip=clip, _ColorRange=vs.RANGE_LIMITED)
  53. # making sure frame rate is set to 29.97fps
  54. clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
  55. # making sure the detected scan type is set (detected: telecine)
  56. clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_TOP) # tff
  57. clip2clip = clip
  58. clip2clip = qtgmc.QTGMC(Input=clip2clip, Preset="fast", opencl=True, TFF=False, FPSDivisor=2)
  59. # Deinterlacing using TIVTC
  60. clip = core.tivtc.TFM(clip=clip, clip2=clip2clip)
  61. clip = core.tivtc.TDecimate(clip=clip)# new fps: 23.976
  62. # Making sure content is preceived as frame based
  63. clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # progressive
  64. # Spot removal using SpotLess
  65. clip = core.remap.Rfs(baseclip=clip, sourceclip=SpotLess.SpotLess(clip=clip, radT=3, truemotion=False, pel=4, smoother="zsmooth", rfilter=0, mStart=True, mEnd=True), mappings="[960 975]")
  66. # removing grain using SMDegrain
  67. clip = smdegrain.SMDegrain(input=clip, tr=3, thSAD=800, thSADC=4000, contrasharp=50, interlaced=False, dct=4, opencl=True, device=-1)
  68. # denoising using VsRemoveDirt
  69. clip = core.remap.Rfs(baseclip=clip, sourceclip=removeDirt.RemoveDirt(input=clip, repmode=2, remgrainmode=2, limit=255), mappings="[0 113][543 573]")
  70. # Denoising using QTGMC
  71. clip = qtgmc.QTGMC(Input=clip, Preset="Fast", InputType=3, TR2=1, TFF=False, SourceMatch=0, Lossless=0, opencl=True)
  72. # adjusting color space from YUV422P8 to RGBH for vsBasicVSRPPFilter
  73. clip = core.resize.Bicubic(clip=clip, format=vs.RGBH, matrix_in_s="470bg", range_s="limited")
  74. # Quality enhancement using BasicVSR++
  75. from vsbasicvsrpp import basicvsrpp as BasicVSRPP
  76. clip = BasicVSRPP(clip=clip, model=4, length=50)
  77. # adjusting color space from RGBH to YUV444P16 for vsStab
  78. clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="470bg", range_s="limited")
  79. # stabilizing using Stab
  80. clip = stabilize.Stab(clp=clip,range=3,mirror=0)
  81. clip = core.std.Crop(clip=clip, left=16, right=8, top=4, bottom=4)# cropping to 696x472
  82. # adjusting color space from YUV444P16 to RGBS for vsFillDuplicateFrames
  83. clip = core.resize.Bicubic(clip=clip, format=vs.RGBS, matrix_in_s="470bg", range_s="limited")
  84. from FillDuplicateFrames import FillDuplicateFrames
  85. fdf = FillDuplicateFrames(clip=clip, method="RIFE", thresh=0.030000, rifeModel=58)
  86. clip = core.remap.Rfs(baseclip=clip, sourceclip=fdf.out, mappings="[160 1188]")
  87. # Resizing using 10 - bicubic spline
  88. clip = core.fmtc.resample(clip=clip, kernel="spline16", w=1594, h=1080, interlaced=False, interlacedd=False) # resolution 1594x1080
  89. # adjusting output color from: RGBS to YUV420P10 for NVEncModel
  90. clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, matrix_s="470bg", range_s="limited", dither_type="error_diffusion")
  91. # set output frame rate to 23.976fps (progressive)
  92. clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001)
  93. # output
  94. clip.set_output()
Advertisement
Add Comment
Please, Sign In to add comment