Guest User

Untitled

a guest
Jan 27th, 2026
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.54 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. # Limit frame cache to 48449MB
  8. core.max_cache_size = 48449
  9. # Import scripts folder
  10. scriptPath = 'F:/Hybrid/64bit/vsscripts'
  11. sys.path.insert(0, os.path.abspath(scriptPath))
  12. # loading plugins
  13. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libvs_placebo.dll")
  14. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/akarin.dll")
  15. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/ZSmooth/zsmooth.dll")
  16. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV_AVX2.dll")
  17. # Import scripts
  18. import masked
  19. import dehalo
  20. import sharpen
  21. import validate
  22. # Source: 'C:\Users\Selur\Desktop\JYErNv_001_clip_1_deinterlaced-20s.mp4'
  23. # Current color space: YUV420P8, bit depth: 8, resolution: 768x576, frame rate: 22.969fps, scanorder: progressive, yuv luminance scale: limited, matrix: 709, format: AVC
  24. # Loading 'C:\Users\Selur\Desktop\JYErNv_001_clip_1_deinterlaced-20s.mp4' using DGSource
  25. clip = core.dgdecodenv.DGSource("J:/tmp/mp4_3e319b4cfb3d3c0a9a3f4916c3e6885a_853323747.dgi") # 22.969 fps, scanorder: progressive
  26. frame = clip.get_frame(0)
  27. # setting color matrix to 709.
  28. clip = core.std.SetFrameProps(clip, _Matrix=vs.MATRIX_BT709)
  29. # setting color transfer (vs.TRANSFER_BT601), if it is not set.
  30. if validate.transferIsInvalid(clip):
  31. clip = core.std.SetFrameProps(clip=clip, _Transfer=vs.TRANSFER_BT601)
  32. # setting color primaries info (to vs.PRIMARIES_BT470_BG), if it is not set.
  33. if validate.primariesIsInvalid(clip):
  34. clip = core.std.SetFrameProps(clip=clip, _Primaries=vs.PRIMARIES_BT470_BG)
  35. # setting color range to TV (limited) range.
  36. clip = core.std.SetFrameProps(clip=clip, _ColorRange=vs.RANGE_LIMITED)
  37. # making sure frame rate is set to 22.969fps
  38. clip = core.std.AssumeFPS(clip=clip, fpsnum=22969, fpsden=1000)
  39. # making sure the detected scan type is set (detected: progressive)
  40. clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # scan type: progressive
  41. # sharpening using DetailSharpen
  42. clip = sharpen.DetailSharpen(clip)
  43. # applying dehalo using DeHalo_alpha
  44. clip = dehalo.DeHalo_alpha(clip, rx=3.00, ry=3.00, brightstr=0.00)
  45. ## Starting applying 'limit' masked filtering for vsBasicVSRPPFilter
  46. # Creating mask for clip
  47. clipMask = clip
  48. clipMask = core.resize.Bicubic(clip=clipMask, format=vs.GRAY16, range_in_s="limited", dither_type="error_diffusion")
  49. clipMask = core.std.BinarizeMask(clipMask, 7680)
  50. for i in range(2):
  51. clipMask = core.std.Maximum(clipMask)
  52. clipMask = core.std.InvertMask(clipMask)
  53. clipFiltered = clip
  54. # adjusting color space from YUV420P8 to RGBH for vsBasicVSRPPFilter
  55. clipFiltered = core.resize.Bicubic(clip=clipFiltered, format=vs.RGBH, matrix_in_s="709", range_in_s="limited", range_s="full", dither_type="error_diffusion")
  56. # Quality enhancement using BasicVSR++
  57. from vsbasicvsrpp import basicvsrpp as BasicVSRPP
  58. clipFiltered = BasicVSRPP(clipFiltered, model=4)
  59. # adjusting clipFiltered color before mask merge
  60. clipFiltered = core.resize.Bicubic(clip=clipFiltered, format=vs.RGBS, dither_type="error_diffusion")
  61. # adjusting clip color before mask merge
  62. clip = core.resize.Bicubic(clip=clip, format=vs.RGBS, matrix_in_s="709", range_in_s="limited", range_s="full", dither_type="error_diffusion")
  63. # adjusting mask before mask merge
  64. clipMask = core.resize.Bicubic(clip=clipMask, format=vs.GRAYS, range_in_s="limited", dither_type="error_diffusion")
  65. # Resolution: clip: 768x576 and clipFiltered: 768x576 and clipMask: 768x576
  66. # Merging: clip and clipFiltered based on clipMask
  67. clip = core.std.MaskedMerge(clip, clipFiltered, clipMask) # LimitMask
  68. ## Finished applying 'LimitMask' masked filtering for vsBasicVSRPPFilter
  69. # adjusting color space from RGBS to YUV444P16 for vsGLSLFilmGrain
  70. clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="709", range_in_s="full", range_s="limited") # additional resize to match target color sampling
  71. # Adding grain using GLSL AddGrain
  72. with open("F:/Hybrid/64bit/vsfilters/GLSL/parameterized/filmgrain.glsl") as glslf:
  73. glsl = glslf.read()
  74. glsl = glsl.replace('#define INTENSITY 0.05', '#define INTENSITY 0.01')
  75. clip = core.placebo.Shader(clip, shader_s=glsl, width=clip.width, height=clip.height)
  76. # adjusting output color from YUV444P16 to YUV420P10 for NVEncModel
  77. clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10)
  78. # set output frame rate to 22.969fps (progressive)
  79. clip = core.std.AssumeFPS(clip=clip, fpsnum=22969, fpsden=1000)
  80. # output
  81. clip.set_output()
  82. # script was created by Hybrid 2026.01.26.1
Advertisement
Add Comment
Please, Sign In to add comment