Guest User

Untitled

a guest
Mar 9th, 2023
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.22 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. import site
  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. os.environ["CUDA_MODULE_LOADING"] = "LAZY"
  20. # Loading Plugins
  21. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/Support/VMAF.dll")
  22. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/FrameFilter/RIFE/librife.dll")
  23. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/Support/libsangnom.dll")
  24. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/Support/EEDI2.dll")
  25. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/SharpenFilter/AWarpSharp2/libawarpsharp2.dll")
  26. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/DenoiseFilter/CTMF/CTMF.dll")
  27. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/Support/libvs_placebo.dll")
  28. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/GrainFilter/RemoveGrain/RemoveGrainVS.dll")
  29. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/GrainFilter/AddGrain/AddGrain.dll")
  30. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/DenoiseFilter/FFT3DFilter/fft3dfilter.dll")
  31. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/DenoiseFilter/DFTTest/DFTTest.dll")
  32. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/Support/EEDI3m_opencl.dll")
  33. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/ResizeFilter/nnedi3/NNEDI3CL.dll")
  34. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/Support/libmvtools.dll")
  35. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/Support/scenechange.dll")
  36. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
  37. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/MiscFilter/MiscFilters/MiscFilters.dll")
  38. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/DeinterlaceFilter/Bwdif/Bwdif.dll")
  39. core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV.dll")
  40. # Import scripts
  41. import mvsfunc
  42. import havsfunc
  43. # source: 'C:\Users\Selur\Desktop\VTS_01_4.demuxed.m2v'
  44. # current color space: YUV420P8, bit depth: 8, resolution: 720x480, fps: 29.97, color matrix: 470bg, yuv luminance scale: limited, scanorder: top field first
  45. # Loading C:\Users\Selur\Desktop\VTS_01_4.demuxed.m2v using DGSource
  46. clip = core.dgdecodenv.DGSource("J:/tmp/m2v_b4d1244b659afd8791eccc7b9231e389_853323747.dgi",fieldop=0)# 29.97 fps, scanorder: top field first
  47. # Setting detected color matrix (470bg).
  48. clip = core.std.SetFrameProps(clip, _Matrix=5)
  49. # Setting color transfer info (470bg), when it is not set
  50. clip = clip if not core.text.FrameProps(clip,'_Transfer') else core.std.SetFrameProps(clip, _Transfer=5)
  51. # Setting color primaries info (), when it is not set
  52. clip = clip if not core.text.FrameProps(clip,'_Primaries') else 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. # Deinterlacing using QTGMC
  59. clip = havsfunc.QTGMC(Input=clip, Preset="Slow", TFF=True, opencl=True) # new fps: 59.94
  60. # Making sure content is preceived as frame based
  61. clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=0) # progressive
  62. clip = havsfunc.DeHalo_alpha(clip, brightstr=1.22)
  63. # adjusting frame with SelectEvery
  64. clip = core.std.SelectEvery(clip=clip, cycle=10, offsets=[0, 5])
  65. clip = core.std.AssumeFPS(clip=clip,fpsnum=12000, fpsden=1001)# new fps: 11.988
  66. from vsdpir import dpir as DPIR
  67. # adjusting color space from YUV420P8 to RGBH for vsDPIRDenoise
  68. clip = core.resize.Bicubic(clip=clip, format=vs.RGBH, matrix_in_s="470bg", range_s="limited")
  69. # denoising using DPIRDenoise
  70. clip = DPIR(clip=clip, strength=5.000, task="denoise", device_index=0, trt=True, trt_cache_path="J:/tmp")
  71. # adjusting color space from RGBH to YUV444P16 for vsGLSLAdaptiveSharpen
  72. clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="470bg", range_s="limited")
  73. with open("i:/Hybrid/64bit/vsfilters/GLSL/parameterized/adaptive-sharpen.glsl") as glslf:
  74. glsl = glslf.read()
  75. glsl = glsl.replace('#define curve_height 1.0', '#define curve_height 1.0000')
  76. glsl = glsl.replace('#define anime_mode false', '#define anime_mode true')
  77. glsl = glsl.replace('#define overshoot_ctrl false', '#define overshoot_ctrl false')
  78. glsl = glsl.replace('#define video_level_out false', '#define video_level_out true')
  79. clip = core.placebo.Shader(clip=clip, shader_s=glsl, width=clip.width, height=clip.height)
  80. # applying dehalo using YAHR
  81. clip = havsfunc.YAHR(clip)
  82. # Using Anime4k Darken GLSL filter for line darkening
  83. with open("i:/Hybrid/64bit/vsfilters/GLSL/parameterized/Anime4K_Darken_HQ.glsl") as glslf:
  84. glsl = glslf.read()
  85. glsl = glsl.replace('#define STRENGTH 1.5', '#define STRENGTH 1.5')
  86. clip = core.placebo.Shader(clip=clip, shader_s=glsl, width=clip.width, height=clip.height)
  87. # applying anti aliasing using santiag
  88. clip = havsfunc.santiag(c=clip, pscrn=2, opencl=True)
  89. clip = core.misc.SCDetect(clip=clip,threshold=0.010)
  90. # adjusting color space from YUV444P16 to RGBS for vsRIFE
  91. clip = core.resize.Bicubic(clip=clip, format=vs.RGBS, matrix_in_s="470bg", range_s="limited")
  92. # adjusting frame count&rate with RIFE, target fps: 23.976fps
  93. clip = core.rife.RIFE(clip, model=3, sc=True, skip=True, skip_threshold=20.00) # new fps: 23.976
  94. # Resizing using 10 - bicubic spline
  95. clip = core.fmtc.resample(clip=clip, kernel="spline16", w=1280, h=960, interlaced=False, interlacedd=False) # resolution 1280x960
  96. # adjusting output color from: RGBS to YUV420P10 for x265Model
  97. clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, matrix_s="470bg", range_s="limited", dither_type="error_diffusion")
  98. # set output frame rate to 23.976fps
  99. clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001)
  100. # Output
  101. clip.set_output()
Advertisement
Add Comment
Please, Sign In to add comment