Guest User

Untitled

a guest
Apr 7th, 2026
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.36 KB | None | 0 0
  1. # Imports
  2. import sys
  3. import os
  4. import vapoursynth as vs
  5. # getting Vapoursynth core
  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/DenoiseFilter/ZSmooth/zsmooth.dll")
  14. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/akarin.dll")
  15. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DeinterlaceFilter/TIVTC/libtivtc.dll")
  16. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV_AVX2.dll")
  17. # Import scripts
  18. import masked
  19. import validate
  20. # Source: 'C:\Users\Selur\Desktop\OPBox2.mkv'
  21. # Current color space: YUV420P8, bit depth: 8, resolution: 1920x1080, frame rate: 29.97fps, scanorder: telecine, yuv luminance scale: limited, matrix: 709, format: AVC
  22. # Loading 'C:\Users\Selur\Desktop\OPBox2.mkv' using DGSource
  23. clip = core.dgdecodenv.DGSource("J:/tmp/mkv_0604cae322f9fbe00040844b856ac3a4_853323747.dgi",fieldop=0) # 29.97 fps, scanorder: telecine
  24. frame = clip.get_frame(0)
  25. # setting color matrix to 709.
  26. clip = core.std.SetFrameProps(clip, _Matrix=vs.MATRIX_BT709)
  27. # setting color transfer (vs.TRANSFER_BT709), if it is not set.
  28. if validate.transferIsInvalid(clip):
  29. clip = core.std.SetFrameProps(clip=clip, _Transfer=vs.TRANSFER_BT709)
  30. # setting color primaries info (to vs.PRIMARIES_BT709), if it is not set.
  31. if validate.primariesIsInvalid(clip):
  32. clip = core.std.SetFrameProps(clip=clip, _Primaries=vs.PRIMARIES_BT709)
  33. # setting color range to TV (limited) range.
  34. prop_name = '_Range' if core.core_version.release_major >= 74 else '_ColorRange'
  35. clip = core.std.SetFrameProps(clip=clip, prop_name=vs.RANGE_LIMITED)
  36. # making sure frame rate is set to 29.97fps
  37. clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
  38. # making sure the detected scan type is set (detected: telecine)
  39. clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_TOP) # scan type: top field first
  40. # Deinterlacing using TIVTC
  41. clip = core.tivtc.TFM(clip)
  42. clip = core.tivtc.TDecimate(clip) # new fps: 23.976
  43. # Making sure content is preceived as frame based
  44. clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # scan type: progressive
  45. clipMask = clip
  46. ## Starting applying 'BloatedEdgeMask' masked filtering for vsBasicVSRPPFilter
  47. # Creating mask for clip
  48. clipMask = core.resize.Bicubic(clip=clipMask, format=vs.GRAY16, range_in_s="limited", dither_type="error_diffusion")
  49. clipMask = masked.bloated_edgemask(src=clipMask)
  50. for i in range(3):
  51. clipMask = core.std.Maximum(clipMask)
  52. clipMask = core.std.ShufflePlanes(clips=[clipMask], planes=[0], colorfamily=vs.GRAY)
  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: 1920x1080 and clipFiltered: 1920x1080 and clipMask: 1920x1080
  66. # Merging: clip and clipFiltered based on clipMask
  67. clip = core.std.MaskedMerge(clip, clipFiltered, clipMask) # BloatedEdgeMask
  68. ## Finished applying 'BloatedEdgeMask' masked filtering for vsBasicVSRPPFilter
  69. # chroma denoising using CCD
  70. clip = core.zsmooth.CCD(clip, threshold=60.00, points=[True,True,False])
  71. # adjusting output color from RGBS to YUV420P10 for NVEncModel
  72. clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, matrix_s="709", range_in_s="full", range_s="limited") # additional resize to match target color sampling
  73. # set output frame rate to 23.976fps (progressive)
  74. clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001)
  75. # output
  76. clip.set_output()
  77. # script was created by Hybrid 2026.04.07.1
Advertisement
Add Comment
Please, Sign In to add comment