Guest User

Vapoursynth separate fields + denoise + Deinterlace + stabilize + reduce frame rate

a guest
Jul 6th, 2026
95
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.04 KB | None | 0 0
  1. # Imports
  2. import logging
  3. import ctypes
  4. import sys
  5. import os
  6. import vapoursynth as vs
  7. # getting Vapoursynth core
  8. core = vs.core
  9. # Limit frame cache to 48449MB
  10. core.max_cache_size = 48449
  11. # Import scripts folder
  12. scriptPath = 'F:/Hybrid/64bit/vsscripts'
  13. sys.path.insert(0, os.path.abspath(scriptPath))
  14. # Loading Support Files
  15. Dllref = ctypes.windll.LoadLibrary("F:/Hybrid/64bit/vsfilters/Support/libfftw3f-3.dll")
  16. # Force logging to std:err
  17. logging.StreamHandler(sys.stderr)
  18. # loading plugins
  19. core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/scenechange/scenechange.dll")
  20. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/FrameFilter/RIFE/librife.dll")
  21. core.std.LoadPlugin(path="F:/Hybrid/64bit/vs-mlrt/vstrt.dll")
  22. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/NEO_FFT3DFilter/neo-fft3d.dll")
  23. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/DFTTest/DFTTest.dll")
  24. core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/bwdif.dll")
  25. core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/sneedif/libsneedif.dll")
  26. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libeedi3vk.dll")
  27. core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/addnoise.dll")
  28. core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/mvtools.dll")
  29. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/CTMF/CTMF.dll")
  30. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SharpenFilter/AWarpSharp2/libawarpsharp2.dll")
  31. core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/fmtconv.dll")
  32. core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/akarin/libakarin.dll")
  33. core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/zsmooth/zsmooth.dll")
  34. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV_AVX2.dll")
  35. # Import scripts
  36. import misc
  37. import vs_temporalfix
  38. import qtgmc
  39. import SpotLess
  40. import sharpen
  41. import dehalo
  42. import validate
  43. # Source: 'C:\Users\Selur\Desktop\S01E01 - GTO - The Legend Begins.mkv'
  44. # clip current meta; color space: YUV420P8, bit depth: 8, resolution: 720x480, fps: 29.97, color matrix: 470bg, color primaries: Unspecific, color transfer: BT.601, yuv luminance scale: limited, scanorder: top field first, full height: true (Source)
  45. # Loading 'C:\Users\Selur\Desktop\S01E01 - GTO - The Legend Begins.mkv' using DGSource
  46. clip = core.dgdecodenv.DGSource("J:/tmp/mkv_82ddc8a0a57ca25c024680bb71faa1df_853323747.dgi",fieldop=0) # 29.97 fps, scanorder: top field first
  47. frame = clip.get_frame(0)
  48. # setting color matrix to 470bg.
  49. clip = core.std.SetFrameProps(clip, _Matrix=vs.MATRIX_BT470_BG)
  50. # setting color transfer (vs.TRANSFER_BT601), if it is not set.
  51. if validate.transferIsInvalid(clip):
  52. clip = core.std.SetFrameProps(clip=clip, _Transfer=vs.TRANSFER_BT601)
  53. # setting color primaries info (to vs.PRIMARIES_BT470_BG), if it is not set.
  54. if validate.primariesIsInvalid(clip):
  55. clip = core.std.SetFrameProps(clip=clip, _Primaries=vs.PRIMARIES_BT470_BG)
  56. # setting color range to TV (limited) range.
  57. prop_name = '_Range' if core.core_version.release_major >= 74 else '_ColorRange'
  58. clip = core.std.SetFrameProps(clip=clip, **{prop_name: vs.RANGE_LIMITED})
  59. # making sure frame rate is set to 29.97fps
  60. clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
  61. # making sure the detected scan type is set (detected: top field first)
  62. clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_TOP) # scan type: top field first
  63. # converting interlaced to half-height progressive for filtering (vsYAHR) (separate fields)
  64. clip = core.std.SeparateFields(clip, tff=True) # resolution 720x240
  65. clipEven = clip[::2]
  66. clipEven = core.std.SetFrameProps(clip=clipEven, _FieldBased=vs.FIELD_PROGRESSIVE) # scan type: progressive
  67. clipOdd = clip[1::2]
  68. clipOdd = core.std.SetFrameProps(clip=clipOdd, _FieldBased=vs.FIELD_PROGRESSIVE) # scan type: progressive
  69. # applying dehalo using YAHR
  70. clipEven = dehalo.YAHR(clipEven, depth=16)
  71. # applying dehalo using YAHR
  72. clipOdd = dehalo.YAHR(clipOdd, depth=16)
  73. # Spot removal using SpotLess
  74. clipEven = SpotLess.SpotLess(clipEven, radT=3, rec=True, pel=1)
  75. # Spot removal using SpotLess
  76. clipOdd = SpotLess.SpotLess(clipOdd, radT=3, rec=True, pel=1)
  77. # adjusting color space from YUV420P8 to RGBH for vsBasicVSRPPFilter
  78. clipEven = core.resize.Bicubic(clip=clipEven, format=vs.RGBH, matrix_in_s="470bg", range_in_s="limited", range_s="full")
  79. # Quality enhancement using BasicVSR++
  80. from vsbasicvsrpp import basicvsrpp as BasicVSRPP
  81. clipEven = BasicVSRPP(clipEven, model=4)
  82. # adjusting color space from YUV420P8 to RGBH for vsBasicVSRPPFilter
  83. clipOdd = core.resize.Bicubic(clip=clipOdd, format=vs.RGBH, matrix_in_s="470bg", range_in_s="limited", range_s="full")
  84. # Quality enhancement using BasicVSR++
  85. clipOdd = BasicVSRPP(clipOdd, model=4)
  86. # converting half-height progressive to interlacedbefore deinterlacing
  87. clip = core.std.Interleave([clipEven, clipOdd])
  88. clip = core.std.DoubleWeave(clip=clip, tff=False) # resolution: 720x480
  89. clip = core.std.SelectEvery(clip, 2, 0) # scan type: bottom field first
  90. clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_TOP) # scan type: top field first
  91. # adjusting color space from RGBH to YUV444P16 for vsQTGMC
  92. clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="470bg", range_in_s="full", range_s="limited")
  93. # Deinterlacing using QTGMC
  94. clip = qtgmc.QTGMC(clip, Preset="Fast", TFF=True, opencl=True) # new fps: 59.94
  95. # Making sure content is preceived as frame based
  96. clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # scan type: progressive
  97. # changing range from limited to full range for vsTemporalfix
  98. clip = core.resize.Bicubic(clip, format=vs.YUV444P16, range_in_s="limited", range_s="full")
  99. # setting color range to PC (full) range.
  100. prop_name = '_Range' if core.core_version.release_major >= 74 else '_ColorRange'
  101. clip = core.std.SetFrameProps(clip=clip, **{prop_name: vs.RANGE_FULL})
  102. # adjusting color space from YUV444P16 to RGBH for vsTemporalfix
  103. clip = core.resize.Bicubic(clip=clip, format=vs.RGBH, matrix_in_s="470bg", range_in_s="full", range_s="full")
  104. # stabilizing using Temporalfix (Torch)
  105. clip = vs_temporalfix.model(clip, backend="tensorrt", engine_folder="J:/TRT")
  106. clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="470bg", range_in_s="full", range_s="full")
  107. clip = misc.SCDetect(clip=clip,threshold=0.100)
  108. # adjusting color space from YUV444P16 to RGBS for vsRIFE
  109. clip = core.resize.Bicubic(clip=clip, format=vs.RGBS, matrix_in_s="470bg", range_in_s="full", range_s="full")
  110. # adjusting frame count&rate with RIFE, target fps: 23.976fps
  111. clip = core.rife.RIFE(clip, model=58, fps_num=24000, fps_den=1001, sc=True) # new fps: 23.976
  112. # Resizing using 10 - bicubic spline
  113. clip = core.fmtc.resample(clip, kernel="spline16", w=656, h=480, interlaced=False, interlacedd=False) # resolution 656x480
  114. # adjusting output color from RGBS to YUV420P10 for NVEncModel
  115. clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, matrix_s="470bg", range_in_s="full", range_s="full", dither_type="error_diffusion")
  116. # changing range from full to limited range for matching filter target luma scale
  117. clip = core.resize.Bicubic(clip, format=vs.YUV420P10,range_in_s="full", range_s="limited")
  118. # setting color range to TV (limited) range.
  119. prop_name = '_Range' if core.core_version.release_major >= 74 else '_ColorRange'
  120. clip = core.std.SetFrameProps(clip=clip, **{prop_name: vs.RANGE_LIMITED})
  121. # set output frame rate to 23.976fps (progressive)
  122. clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001)
  123. # output
  124. clip.set_output()
  125. # clip current meta; color space: YUV420P10, bit depth: 10, resolution: 656x480, fps: 23.976, color matrix: 470bg, color primaries: Unspecific, color transfer: BT.601, yuv luminance scale: limited, scanorder: progressive, full height: true (Meta)
  126. # script was created by Hybrid 2026.07.05.1
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment