Guest User

Untitled

a guest
Aug 21st, 2026
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.37 KB | None | 0 0
  1. # Imports
  2. import sys
  3. import os
  4. import vapoursynth as vs
  5. # using Vapoursynth R79
  6. # getting Vapoursynth core
  7. core = vs.core
  8. # Limit frame cache to 48449MB
  9. core.max_cache_size = 48449
  10. # Import scripts folder
  11. scriptPath = 'F:/Hybrid/64bit/vsscripts'
  12. sys.path.insert(0, os.path.abspath(scriptPath))
  13. # loading plugins
  14. core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/fmtconv.dll")
  15. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SharpenFilter/AWarpSharp2/libawarpsharp2.dll")
  16. core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/zsmooth/zsmooth.dll")
  17. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DerainbowFilter/SmoothUV/libsmoothuv.dll")
  18. core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/akarin/libakarin.dll")
  19. core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/edgefixer.dll")
  20. core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/tivtc.dll")
  21. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV_AVX2.dll")
  22. # Import scripts
  23. import sharpen
  24. import linedarken
  25. import masked
  26. import RainbowSmooth
  27. import validate
  28. # Source: 'C:\Users\Selur\Desktop\removeheavyanalogartifacts.ts'
  29. # clip current meta; color space: YUV420P8, bit depth: 8, resolution: 1440x1080, fps: 29.97, color matrix: 709, color primaries: Unspecific, color transfer: BT.709, yuv luminance scale: limited, scanorder: telecine, full height: true (Source)
  30. # Loading 'C:\Users\Selur\Desktop\removeheavyanalogartifacts.ts' using DGSource
  31. clip = core.dgdecodenv.DGSource("J:/tmp/ts_541bdebe8c57c01d2fbdb83685d70881_853323747.dgi",fieldop=0) # 29.97 fps, scanorder: telecine
  32. frame = clip.get_frame(0)
  33. # setting color matrix to 709.
  34. clip = core.std.SetFrameProps(clip, _Matrix=vs.MATRIX_BT709)
  35. # setting color transfer (vs.TRANSFER_BT709), if it is not set.
  36. if validate.transferIsInvalid(clip):
  37. clip = core.std.SetFrameProps(clip=clip, _Transfer=vs.TRANSFER_BT709)
  38. # setting color primaries info (to vs.PRIMARIES_BT709), if it is not set.
  39. if validate.primariesIsInvalid(clip):
  40. clip = core.std.SetFrameProps(clip=clip, _Primaries=vs.PRIMARIES_BT709)
  41. # setting color range to TV (limited) range.
  42. prop_name = '_Range' if core.core_version.release_major >= 74 else '_ColorRange'
  43. clip = core.std.SetFrameProps(clip=clip, **{prop_name: vs.RANGE_LIMITED})
  44. # making sure frame rate is set to 29.97fps
  45. clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
  46. # making sure the detected scan type is set (detected: telecine)
  47. clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_TOP) # scan type: top field first
  48. # Deinterlacing using TIVTC
  49. clip = core.tivtc.TFM(clip)
  50. clip = core.tivtc.TDecimate(clip) # new fps: 23.976
  51. # Making sure content is perceived as frame based
  52. clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # scan type: progressive
  53. clip = core.std.Crop(clip, left=186, right=186, top=4, bottom=0) # cropping to 1068x1076
  54. # Fix bright and dark line artifacts near the border of an image using EdgeFixer
  55. clip = core.edgefixer.Continuity(clip, left=6, top=6, right=4, bottom=6, radius=3)
  56. clip = core.std.AddBorders(clip=clip, left=2, right=2, top=6, bottom=6) # add borders to archive mod 16 (vsRainbowSmooth) - 1072x1088
  57. # rainbow removal using RainbowSmooth
  58. clip = RainbowSmooth.RainbowSmooth(clip, radius=7, lthresh=50)
  59. clip = core.std.Crop(clip=clip, left=2, right=2, top=6, bottom=6) # removing added borders from mod requirement (vsRainbowSmooth) - 1068x1076
  60. ## Starting applying (experimental) 'Finegrain Mask' masked filtering for vsBasicVSRPPFilter
  61. # Creating mask for clip
  62. clipMask = clip
  63. clipMask = core.resize.Bicubic(clip=clipMask, format=vs.YUV444P8)
  64. clipMask = core.resize.Bicubic(clip=clipMask, format=vs.GRAY8, range_in_s="limited")
  65. clipMask = masked.FinegrainMask(clip=clipMask, mode="RemoveGrain")
  66. clipMask = core.std.Maximum(clipMask)
  67. EXPR = core.akarin.Expr if hasattr(core, 'akarin') else core.std.Expr
  68. clipMask = EXPR(clipMask, expr=f"x 100 *")
  69. clipFiltered = clip
  70. clipFiltered = core.std.AddBorders(clip=clipFiltered, left=2, right=2, top=2, bottom=2) # add borders to archive mod 8 (vsBasicVSRPPFilter) - 1072x1080
  71. # adjusting color space from YUV420P8 to RGBH for vsBasicVSRPPFilter
  72. clipFiltered = core.resize.Bicubic(clip=clipFiltered, format=vs.RGBH, matrix_in_s="709", range_in_s="limited", range_s="full")
  73. # Quality enhancement using BasicVSR++
  74. from vsbasicvsrpp import basicvsrpp as BasicVSRPP
  75. clipFiltered = BasicVSRPP(clipFiltered, model=4)
  76. clipFiltered = core.std.Crop(clip=clipFiltered, left=2, right=2, top=2, bottom=2) # removing added borders from mod requirement (vsBasicVSRPPFilter) - 1068x1076
  77. # adjusting clip color before mask merge
  78. clip = core.resize.Bicubic(clip=clip, format=vs.RGBH, matrix_in_s="709", range_in_s="limited", range_s="full")
  79. # adjusting mask before mask merge
  80. clipMask = core.resize.Bicubic(clip=clipMask, format=vs.GRAYH, range_in_s="limited")
  81. # Resolution: clip: 1068x1076 and clipFiltered: 1068x1076 and clipMask: 1068x1076
  82. # Color: clip: RGBH and clipFiltered: RGBH and clipMask: GRAYH
  83. # Merging: clip and clipFiltered based on clipMask
  84. clip = core.std.MaskedMerge(clip, clipFiltered, clipMask) # FinegrainMask
  85. ## Finished applying 'FinegrainMask' masked filtering for vsBasicVSRPPFilter
  86. # adjusting color space from RGBH to YUV444P16 for vsToon
  87. clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="709", range_in_s="full", range_s="limited")
  88. # line darkening using Toon
  89. clip = linedarken.Toon(clip, str=1.50)
  90. # Resizing using 10 - bicubic spline
  91. clip = core.fmtc.resample(clip, kernel="spline16", w=1068, h=808, interlaced=False, interlacedd=False) # resolution 1068x808 before YUV444P16 after YUV444P16
  92. # adjusting output color from YUV444P16 to YUV420P10 for NVEncModel
  93. clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, dither_type="error_diffusion")
  94. # set output frame rate to 23.976fps (progressive)
  95. clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001)
  96. # output
  97. clip.set_output()
  98. # clip current meta; color space: YUV420P10, bit depth: 10, resolution: 1068x808, fps: 23.976, color matrix: 709, color primaries: Unspecific, color transfer: BT.709, yuv luminance scale: limited, scanorder: progressive, full height: true (Meta)
  99. # script was created by Hybrid 2026.08.21.1
Advertisement
Add Comment
Please, Sign In to add comment