Advertisement
Guest User

Untitled

a guest
Jan 8th, 2024
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.60 KB | None | 0 0
  1. # Imports
  2. import vapoursynth as vs
  3. # getting Vapoursynth core
  4. import site
  5. import ctypes
  6. import sys
  7. import os
  8. core = vs.core
  9. # Import scripts folder
  10. scriptPath = 'F:/Hybrid/64bit/vsscripts'
  11. sys.path.insert(0, os.path.abspath(scriptPath))
  12. # Loading Support Files
  13. Dllref = ctypes.windll.LoadLibrary("F:/Hybrid/64bit/vsfilters/Support/libfftw3f-3.dll")
  14. # Adding torch dependencies to PATH
  15. path = site.getsitepackages()[0]+'/torch_dependencies/bin/'
  16. ctypes.windll.kernel32.SetDllDirectoryW(path)
  17. path = path.replace('\\', '/')
  18. os.environ["PATH"] = path + os.pathsep + os.environ["PATH"]
  19. # Loading Plugins
  20. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/FFT3DFilter/fft3dfilter.dll")
  21. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/CTMF/CTMF.dll")
  22. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libmvtools_sf_em64t.dll")
  23. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/TCanny.dll")
  24. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/GrainFilter/RemoveGrain/RemoveGrainVS.dll")
  25. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/GrainFilter/AddGrain/AddGrain.dll")
  26. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/DFTTest/DFTTest.dll")
  27. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/NEO_FFT3DFilter/neo-fft3d.dll")
  28. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/EEDI3m.dll")
  29. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/ResizeFilter/nnedi3/vsznedi3.dll")
  30. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libmvtools.dll")
  31. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/scenechange.dll")
  32. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
  33. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/MiscFilter/MiscFilters/MiscFilters.dll")
  34. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DeinterlaceFilter/Bwdif/Bwdif.dll")
  35. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libdescale.dll")
  36. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/LSmashSource/vslsmashsource.dll")
  37. # Import scripts
  38. import G41Fun
  39. import havsfunc
  40. # source: 'C:\Users\Selur\Desktop\Interlaced Video.mov'
  41. # current color space: YUV422P10, bit depth: 10, resolution: 720x544, fps: 29.97, color matrix: 709, yuv luminance scale: limited, scanorder: top field first
  42. # Loading C:\Users\Selur\Desktop\Interlaced Video.mov using LibavSMASHSource
  43. clip = core.lsmas.LibavSMASHSource(source="C:/Users/Selur/Desktop/Interlaced Video.mov")
  44. frame = clip.get_frame(0)
  45. # Setting detected color matrix (709).
  46. clip = core.std.SetFrameProps(clip, _Matrix=1)
  47. # Setting color transfer (to 709), if it is not set.
  48. if '_Transfer' not in frame.props or not frame.props['_Transfer']:
  49. clip = core.std.SetFrameProps(clip, _Transfer=1)
  50. # Setting color primaries info (to 5), if it is not set.
  51. if '_Primaries' not in frame.props or not frame.props['_Primaries']:
  52. clip = core.std.SetFrameProps(clip, _Primaries=5)
  53. # Setting color range to TV (limited) range.
  54. clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
  55. # making sure frame rate is set to 29.97
  56. clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
  57. clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=2) # tff
  58. # converting interlaced to half-height progressive for filtering (vsVinverse) (separate fields)
  59. clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P10, range_s="limited")
  60. clip = core.std.SeparateFields(clip, tff=True)
  61. clipEven = clip[::2] # resolution 720x272
  62. clipEven = core.std.SetFrameProp(clip=clipEven, prop="_FieldBased", intval=0) # progressive
  63. clipOdd = clip[1::2] # resolution 720x272
  64. clipOdd = core.std.SetFrameProp(clip=clipOdd, prop="_FieldBased", intval=0) # progressive
  65. clipEven = havsfunc.Vinverse(clp=clipEven)
  66. clipOdd = havsfunc.Vinverse(clp=clipOdd)
  67. # converting half-height progressive to interlacedbefore deinterlacing
  68. clip = core.std.Interleave([clipOdd, clipEven])
  69. clip = core.std.DoubleWeave(clip=clip, tff=True) # resolution 720x544
  70. clip = core.std.SelectEvery(clip, 2, 0)
  71. clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=2) # tff
  72. # adjusting resolution before deinterlacing
  73. clip = core.descale.Debicubic(src=clip, width=720, height=160, b="0.00", c="0.50")
  74. # Deinterlacing using QTGMC
  75. clip = havsfunc.QTGMC(Input=clip, Preset="Fast", TFF=True) # new fps: 29.97
  76. # Making sure content is preceived as frame based
  77. clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=0) # progressive
  78. clip = clip[::2] # selecting previously even frames
  79. from vsdpir import dpir as DPIR
  80. # adjusting color space from YUV444P10 to RGBH for vsDPIRDeblock
  81. clip = core.resize.Bicubic(clip=clip, format=vs.RGBH, matrix_in_s="709", range_s="limited")
  82. # deblocking using DPIRDeblock
  83. clip = DPIR(clip=clip, strength=25.000, task="deblock", device_index=0)
  84. # adjusting color space from RGBH to YUV444P16 for vsTemporalDegrain2
  85. clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="709", range_s="limited")
  86. # removing grain using TemporalDegrain2
  87. clip = G41Fun.TemporalDegrain2(clip=clip, degrainPlane=4, meAlgPar=False, postFFT=0, fftThreads=1)
  88. # Resizing using 10 - bicubic spline
  89. clip = core.fmtc.resample(clip=clip, kernel="spline16", w=720, h=544, interlaced=False, interlacedd=False) # resolution 720x544 before YUV444P16 after YUV444P16
  90. # adjusting output color from: YUV444P16 to YUV420P8 for x264Model
  91. clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P8, range_s="limited", dither_type="error_diffusion")
  92. # set output frame rate to 29.97fps (progressive)
  93. clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
  94. # Output
  95. clip.set_output()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement