Guest User

Untitled

a guest
Sep 12th, 2024
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.25 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. # loading plugins
  14. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libvs_placebo.dll")
  15. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/GrainFilter/RemoveGrain/RemoveGrainVS.dll")
  16. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DebandFilter/Flash3kDeband/flash3kyuu_deband.dll")
  17. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SharpenFilter/AWarpSharp2/libawarpsharp2.dll")
  18. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/TCanny.dll")
  19. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
  20. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/ZSmooth/zsmooth.dll")
  21. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/vcm.dll")
  22. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libmvtools.dll")
  23. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/BestSource/BestSource.dll")
  24. # Import scripts
  25. import mclean
  26. import mvsfunc
  27. import muvsfunc
  28. import validate
  29. # Source: 'C:\Users\Selur\Desktop\00008.mkv'
  30. # Current color space: YUV420P10, bit depth: 10, resolution: 1920x1080, frame rate: 23.976fps, scanorder: progressive, yuv luminance scale: limited, matrix: 709, format: AVC
  31. # Loading C:\Users\Selur\Desktop\00008.mkv using BestSource)
  32. clip = core.bs.VideoSource(source="C:/Users/Selur/Desktop/00008.mkv", cachepath="J:/tmp/00008.json", track=0)
  33. frame = clip.get_frame(0)
  34. # setting color matrix to 709.
  35. clip = core.std.SetFrameProps(clip, _Matrix=vs.MATRIX_BT709)
  36. # setting color transfer (vs.TRANSFER_BT709), if it is not set.
  37. if validate.transferIsInvalid(clip):
  38. clip = core.std.SetFrameProps(clip=clip, _Transfer=vs.TRANSFER_BT709)
  39. # setting color primaries info (to vs.PRIMARIES_BT709), if it is not set.
  40. if validate.primariesIsInvalid(clip):
  41. clip = core.std.SetFrameProps(clip=clip, _Primaries=vs.PRIMARIES_BT709)
  42. # setting color range to TV (limited) range.
  43. clip = core.std.SetFrameProps(clip=clip, _ColorRange=vs.RANGE_LIMITED)
  44. # making sure frame rate is set to 23.976fps
  45. clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001)
  46. # making sure the detected scan type is set (detected: progressive)
  47. clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # progressive
  48. clip = core.std.CropRel(clip=clip, left=240, right=240, top=0, bottom=0)# cropping to 1440x1080
  49. # denoising using mClean
  50. clip = mclean.mClean(clip=clip)
  51. # adjusting color space from YUV420P10 to RGBH for vsBasicVSRPPFilter
  52. clip = core.resize.Bicubic(clip=clip, format=vs.RGBH, matrix_in_s="709", range_s="limited")
  53. # Quality enhancement using BasicVSR++
  54. from vsbasicvsrpp import basicvsrpp as BasicVSRPP
  55. clip = BasicVSRPP(clip=clip, model=4)
  56. # changing range from limited to full range for VsVSGANFilter
  57. clip = core.resize.Bicubic(clip, range_in_s="limited", range_s="full")
  58. # filtering using VSGANFilter
  59. from vsgan import ESRGAN
  60. vsgan = ESRGAN(clip=clip,device="cuda")
  61. model = "F:/Hybrid/64bit/vsgan_models/1x_BleedOut_Compact_300k_net_g.pth"
  62. vsgan.load(model)
  63. vsgan.apply() # 1440x1080
  64. clip = vsgan.clip
  65. # changing range from full to limited range for VsVSGANFilter
  66. clip = core.resize.Bicubic(clip, range_in_s="full", range_s="limited")
  67. # adjusting color space from RGBH to YUV444P16 for vsGLSLDarken
  68. clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="709", range_s="limited")
  69. # Using Anime4k Darken GLSL filter for line darkening
  70. with open("F:/Hybrid/64bit/vsfilters/GLSL/parameterized/Anime4K_Darken_HQ.glsl") as glslf:
  71. glsl = glslf.read()
  72. glsl = glsl.replace('#define STRENGTH 1.5', '#define STRENGTH 1.5')
  73. clip = core.placebo.Shader(clip=clip, shader_s=glsl, width=clip.width, height=clip.height)
  74. # adjusting output color from: YUV444P16 to YUV420P10 for NVEncModel
  75. clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, range_s="limited", dither_type="error_diffusion")
  76. # set output frame rate to 23.976fps (progressive)
  77. clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001)
  78. # output
  79. clip.set_output()
Advertisement
Add Comment
Please, Sign In to add comment