Guest User

Vapoursynth heavy denoise

a guest
Jun 22nd, 2026
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.00 KB | None | 0 0
  1. # Imports
  2. import ctypes
  3. import sys
  4. import os
  5. import vapoursynth as vs
  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 Support Files
  14. Dllref = ctypes.windll.LoadLibrary("F:/Hybrid/64bit/vsfilters/Support/libfftw3f-3.dll")
  15. # loading plugins
  16. core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/fmtconv.dll")
  17. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/DFTTest/DFTTest.dll")
  18. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/NEO_FFT3DFilter/neo-fft3d.dll")
  19. core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/deblock.dll")
  20. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/RemoveDirt/RemoveDirt.dll")
  21. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/FrameFilter/ReduceFlicker/ReduceFlicker.dll")
  22. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/vcm.dll")
  23. core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/hysteresis/hysteresis.dll")
  24. core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/zsmooth/zsmooth.dll")
  25. core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/mvtools.dll")
  26. core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/akarin/libakarin.dll")
  27. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/d2vSource/DGDecode.dll")
  28. # Import scripts
  29. import denoise
  30. import removeDirt
  31. import edge
  32. import SpotLess
  33. import validate
  34. # Source: 'C:\Users\Selur\Desktop\5 - stereo.mpeg'
  35. # clip current meta; color space: YUV420P8, bit depth: 8, resolution: 720x576, fps: 25, color matrix: 470bg, color primaries: Unspecific, color transfer: Unspecified, yuv luminance scale: limited, scanorder: progressive, full height: true (Source)
  36. # Loading 'C:\Users\Selur\Desktop\5 - stereo.mpeg' using DGDecode
  37. clip = core.dgdecode.MPEG2Source("J:/tmp/mpeg_99e8642d0f318c6ba643ee3eaf232651_853323747.d2v",info=3)# 25 fps, scanorder: progressive
  38. frame = clip.get_frame(0)
  39. # setting color matrix to 470bg.
  40. clip = core.std.SetFrameProps(clip, _Matrix=vs.MATRIX_BT470_BG)
  41. # setting color transfer (vs.TRANSFER_BT601), if it is not set.
  42. if validate.transferIsInvalid(clip):
  43. clip = core.std.SetFrameProps(clip=clip, _Transfer=vs.TRANSFER_BT601)
  44. # setting color primaries info (to vs.PRIMARIES_BT470_BG), if it is not set.
  45. if validate.primariesIsInvalid(clip):
  46. clip = core.std.SetFrameProps(clip=clip, _Primaries=vs.PRIMARIES_BT470_BG)
  47. # setting color range to TV (limited) range.
  48. prop_name = '_Range' if core.core_version.release_major >= 74 else '_ColorRange'
  49. clip = core.std.SetFrameProps(clip=clip, **{prop_name: vs.RANGE_LIMITED})
  50. # making sure frame rate is set to 25fps
  51. clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
  52. # making sure the detected scan type is set (detected: progressive)
  53. clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # scan type: progressive
  54. # Spot removal using SpotLess + DeltaRestore
  55. clip = SpotLess.SpotDelta(clip, radT=3, rec=True, pel=1, dark2_brt=0.97)
  56. # adjusting color space from YUV420P8 to YUV444P8 for vsDeJitter
  57. clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P8)
  58. # remove jitter using DeJitter
  59. clip = core.vcm.DeJitter(clip)
  60. # removing flickering using ReduceFlicker
  61. clip = core.rdfl.ReduceFlicker(clip, strength=3, aggressive=1)
  62. clip = core.std.Crop(clip, left=28, right=6, top=2, bottom=16) # cropping to 686x558
  63. # Fix bright and dark line artifacts near the border of an image using BalanceBorders
  64. clip = edge.bbmod(clip, cLeft=8, cTop=8, cRight=0, cBottom=0)
  65. # denoising using VsRemoveDirtMC
  66. clip = removeDirt.RemoveDirtMC(clip)
  67. clip = core.std.AddBorders(clip=clip, left=1, right=1, top=1, bottom=1) # add borders to archive mod 4 (vsMCTemporalDenoise) - 688x560
  68. # denoising using MCTemporalDenoise
  69. clip = denoise.MCTemporalDenoise(clip, settings="very high", ncpu=10)
  70. clip = core.std.Crop(clip=clip, left=1, right=1, top=1, bottom=1) # removing added borders from mod requirement (vsMCTemporalDenoise) - 686x558
  71. # Resizing using 10 - bicubic spline
  72. clip = core.fmtc.resample(clip, kernel="spline16", w=686, h=524, interlaced=False, interlacedd=False) # resolution 686x524 before YUV444P8 after YUV444P16
  73. # adjusting output color from YUV444P16 to YUV420P10 for NVEncModel
  74. clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, dither_type="error_diffusion")
  75. # set output frame rate to 25fps (progressive)
  76. clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
  77. # output
  78. clip.set_output()
  79. # clip current meta; color space: YUV420P10, bit depth: 10, resolution: 686x524, fps: 25, color matrix: 470bg, color primaries: Unspecific, color transfer: Unspecified, yuv luminance scale: limited, scanorder: progressive, full height: true (Meta)
  80. # script was created by Hybrid 2026.06.21.1
Advertisement
Add Comment
Please, Sign In to add comment