Advertisement
Guest User

Untitled

a guest
Feb 7th, 2025
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.62 KB | None | 0 0
  1. # Imports
  2. import vapoursynth as vs
  3. # getting Vapoursynth core
  4. import sys
  5. import os
  6. core = vs.core
  7. # Import scripts folder
  8. scriptPath = 'F:/Hybrid/64bit/vsscripts'
  9. sys.path.insert(0, os.path.abspath(scriptPath))
  10. # loading plugins
  11. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SharpenFilter/AWarpSharp2/libawarpsharp2.dll")
  12. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/CTMF/CTMF.dll")
  13. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libvs_placebo.dll")
  14. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
  15. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/MiscFilter/MiscFilters/MiscFilters.dll")
  16. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libmvtools.dll")
  17. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/GrainFilter/RemoveGrain/RemoveGrainVS.dll")
  18. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV.dll")
  19. # Import scripts
  20. import lostfunc
  21. import havsfunc
  22. import validate
  23. # Source: 'C:\Users\Selur\Desktop\test.mkv'
  24. # Current color space: YUV420P8, bit depth: 8, resolution: 640x480, frame rate: 29.97fps, scanorder: progressive, yuv luminance scale: limited, matrix: 470bg, format: AVC
  25. # Loading C:\Users\Selur\Desktop\test.mkv using DGSource
  26. clip = core.dgdecodenv.DGSource("J:/tmp/mkv_aaf47d044f0319abfb06280a337316d9_853323747.dgi")# 29.97 fps, scanorder: progressive
  27. frame = clip.get_frame(0)
  28. # setting color matrix to 470bg.
  29. clip = core.std.SetFrameProps(clip, _Matrix=vs.MATRIX_BT470_BG)
  30. # setting color transfer (vs.TRANSFER_BT601), if it is not set.
  31. if validate.transferIsInvalid(clip):
  32. clip = core.std.SetFrameProps(clip=clip, _Transfer=vs.TRANSFER_BT601)
  33. # setting color primaries info (to vs.PRIMARIES_BT470_BG), if it is not set.
  34. if validate.primariesIsInvalid(clip):
  35. clip = core.std.SetFrameProps(clip=clip, _Primaries=vs.PRIMARIES_BT470_BG)
  36. # setting color range to TV (limited) range.
  37. clip = core.std.SetFrameProps(clip=clip, _ColorRange=vs.RANGE_LIMITED)
  38. # making sure frame rate is set to 29.97fps
  39. clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
  40. # making sure the detected scan type is set (detected: progressive)
  41. clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # progressive
  42. # Fix bright and dark line artifacts near the border of an image using BalanceBorders
  43. clip = havsfunc.bbmod(c=clip,cLeft=0,cTop=4,cRight=0,cBottom=0)
  44. clip = lostfunc.DeSpot(o=clip)
  45. # changing color matrix from '470bg' to '709' for vsProPainter
  46. clip = core.resize.Bicubic(clip, matrix_in_s="470bg", matrix_s="709")
  47. # changing range from limited to full range for vsProPainter
  48. clip = core.resize.Bicubic(clip, range_in_s="limited", range_s="full")
  49. # setting color range to PC (full) range.
  50. clip = core.std.SetFrameProps(clip=clip, _ColorRange=vs.RANGE_FULL)
  51. # adjusting color space from YUV420P8 to RGB24 for vsProPainter
  52. clip = core.resize.Bicubic(clip=clip, format=vs.RGB24, matrix_in_s="709", range_s="full")
  53. # Inpainting using ProPainter
  54. from vspropainter import propainter as ProPainter
  55. clip = ProPainter(clip=clip, img_mask_path="C:/Users/Selur/Desktop/mask.png", length=500, mask_region=(256,256,380,0))
  56. # internally changing color matrix for YUV<>RGB to '470bg' undoing color matrix change for vsProPainter
  57. # changing range from full to limited range for vsProPainter
  58. clip = core.resize.Bicubic(clip, range_in_s="full", range_s="limited")
  59. clip = core.std.Crop(clip=clip, left=2, right=4, top=0, bottom=0)# cropping to 634x480
  60. # adjusting color space from RGB24 to YUV444P16 for vsDeHalo_Alpha
  61. clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="470bg", range_s="limited")
  62. # applying dehalo using DeHalo_alpha
  63. clip = havsfunc.DeHalo_alpha(clip, rx=3.00, ry=3.00)
  64. clip = core.std.AddBorders(clip=clip, left=2, right=4, top=0, bottom=0) # add borders to archive mod 8 (vsBasicVSRPPFilter) - 640x480
  65. # adjusting color space from YUV444P16 to RGBH for vsBasicVSRPPFilter
  66. clip = core.resize.Bicubic(clip=clip, format=vs.RGBH, matrix_in_s="470bg", range_s="limited")
  67. # Quality enhancement using BasicVSR++
  68. from vsbasicvsrpp import basicvsrpp as BasicVSRPP
  69. clip = BasicVSRPP(clip=clip, model=4)
  70. clip = core.std.Crop(clip=clip, left=2, right=4, top=0, bottom=0) # removing borders (vsBasicVSRPPFilter) - 634x480
  71. # adjusting color space from RGBH to YUV444P16 for vsGLSLLumaSharpen
  72. clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="470bg", range_s="limited")
  73. with open("F:/Hybrid/64bit/vsfilters/GLSL/parameterized/LumaSharpenHook.glsl") as glslf:
  74. glsl = glslf.read()
  75. glsl = glsl.replace('#define sharp_strength 0.30', '#define sharp_strength 1.5000')
  76. glsl = glsl.replace('#define sharp_clamp 0.035', '#define sharp_clamp 0.0350')
  77. glsl = glsl.replace('#define pattern 2', '#define pattern 1')
  78. glsl = glsl.replace('#define offset_bias 1.0', '#define offset_bias 1.0000')
  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, depth=16)
  82. # Using Anime4k Darken GLSL filter for line darkening
  83. with open("F:/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 2.5')
  86. clip = core.placebo.Shader(clip=clip, shader_s=glsl, width=clip.width, height=clip.height)
  87. # adjusting output color from: YUV444P16 to YUV420P10 for NVEncModel
  88. clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, range_s="limited", dither_type="error_diffusion")
  89. # set output frame rate to 29.97fps (progressive)
  90. clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
  91. # output
  92. clip.set_output()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement