Guest User

Untitled

a guest
Nov 6th, 2026
7
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.74 KB | None | 0 0
  1. # Imports
  2. import sys
  3. import os
  4. import vapoursynth as vs
  5. # using Vapoursynth R82
  6. # getting Vapoursynth core
  7. core = vs.core
  8. # Import scripts folder
  9. scriptPath = 'F:/Hybrid/64bit/vsscripts'
  10. sys.path.insert(0, os.path.abspath(scriptPath))
  11. # loading plugins
  12. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/TCanny.dll")
  13. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/Neo-FFT/neo-fft.dll")
  14. core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/sangnom.dll")
  15. core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/tivtc.dll")
  16. core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/znedi3.dll")
  17. core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/zsmooth/zsmooth.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/mvutensils/mvutensils.dll")
  20. core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/fmtconv.dll")
  21. core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/d2vSource/DGDecode.dll")
  22. # Import scripts
  23. import degrain
  24. import antiAliasing
  25. import qtgmc
  26. import validate
  27. # Source: 'C:\Users\Selur\Desktop\【ドラえもん2003年一挙放送&#123.ts'
  28. # 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)
  29. # Loading 'C:\Users\Selur\Desktop\【ドラえもん2003年一挙放送&#123.ts' using DGDecode
  30. clip = core.dgdecode.MPEG2Source("J:/tmp/ts_a3de1159c96742744a2c920fd821fd54_853323747.d2v",info=3)# 29.97 fps, scanorder: telecine
  31. frame = clip.get_frame(0)
  32. # setting color matrix to 709.
  33. clip = core.std.SetFrameProps(clip, _Matrix=vs.MATRIX_BT709)
  34. # setting color transfer (vs.TRANSFER_BT709), if it is not set.
  35. if validate.transferIsInvalid(clip):
  36. clip = core.std.SetFrameProps(clip=clip, _Transfer=vs.TRANSFER_BT709)
  37. # setting color primaries info (to vs.PRIMARIES_BT709), if it is not set.
  38. if validate.primariesIsInvalid(clip):
  39. clip = core.std.SetFrameProps(clip=clip, _Primaries=vs.PRIMARIES_BT709)
  40. # setting color range to TV (limited) range.
  41. prop_name = '_Range' if core.core_version.release_major >= 74 else '_ColorRange'
  42. clip = core.std.SetFrameProps(clip=clip, **{prop_name: vs.RANGE_LIMITED})
  43. # making sure frame rate is set to 29.97fps
  44. clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
  45. # making sure the detected scan type is set (detected: telecine)
  46. clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_TOP) # scan type: top field first
  47. clip2clip = clip
  48. clip2clip = qtgmc.QTGMC(Input=clip2clip, Preset="fast", tools={'mv': 'mvutensils', 'expr': 'akarin', 'nnedi3': 'znedi3', 'eedi3': 'vszip', 'dfttest': 'neo_fft', 'nlmeans': 'knlm', 'bm3d': 'bm3d', 'rg': 'zsmooth', 'median': 'zsmooth', 'fft3d': 'neo_fft', 'grain': 'noise'}, TFF=True, FPSDivisor=2)
  49. # Deinterlacing using TIVTC
  50. clip = core.tivtc.TFM(clip, clip2=clip2clip)
  51. clip = core.tivtc.TDecimate(clip, mode=7, rate=11.98890, dupThresh=0.04, vidThresh=3.50, sceneThresh=15.00) # new fps: 11.9889
  52. # Making sure content is perceived as frame based
  53. clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # scan type: progressive
  54. clip = core.std.Crop(clip, left=180, right=180, top=0, bottom=0) # cropping to 1080x1080
  55. # applying anti aliasing using santiag
  56. clip = antiAliasing.santiag(clip, strh=3, strv=3, type="sangnom", aa=128, tools={'nnedi3': 'znedi3', 'eedi3': 'vszip', 'eedi2': 'eedi2'})
  57. ## Starting applying 'EdgeMask (Prewitt)' masked filtering for vsTemporalDegrain2
  58. # Creating mask for clip
  59. clipMask = clip
  60. clipMask = core.resize.Bicubic(clip=clipMask, format=vs.GRAY8, range_in_s="limited")
  61. clipMask = core.std.Prewitt(clip=clipMask)
  62. for i in range(2):
  63. clipMask = core.std.Maximum(clipMask)
  64. clipMask = core.std.ShufflePlanes(clips=[clipMask], planes=[0], colorfamily=vs.GRAY)
  65. clipFiltered = clip
  66. # removing grain using TemporalDegrain2
  67. clipFiltered = degrain.TemporalDegrain2(clipFiltered, degrainTR=3, degrainPlane=4, postFFT=0, fftThreads=10, DCT=1, tools={'mv': 'mvutensils', 'expr': 'akarin', 'dfttest': 'neo_fft', 'nlmeans': 'knlm', 'rg': 'zsmooth', 'median': 'zsmooth', 'boxblur': 'std', 'tcanny': 'tcanny', 'fft3d': 'neo_fft'})
  68. # Resolution: clip: 1080x1080 and clipFiltered: 1080x1080 and clipMask: 1080x1080
  69. # Color: clip: YUV420P8 and clipFiltered: YUV420P8 and clipMask: GRAY8
  70. # Merging: clip and clipFiltered based on clipMask
  71. clip = core.std.MaskedMerge(clip, clipFiltered, clipMask) # PrewittEdgeMask
  72. ## Finished applying 'PrewittEdgeMask' masked filtering for vsTemporalDegrain2
  73. # Resizing using 10 - bicubic spline
  74. clip = core.fmtc.resample(clip, kernel="spline16", w=1440, h=1080, interlaced=False, interlacedd=False) # resolution 1440x1080 before YUV420P8 after YUV420P16
  75. # adjusting output color from YUV420P16 to YUV420P10 for NVEncModel
  76. clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, dither_type="error_diffusion")
  77. # set output frame rate to 11.9889fps (progressive)
  78. clip = core.std.AssumeFPS(clip=clip, fpsnum=12000, fpsden=1001)
  79. # set output pixel aspect ratio to 1:1
  80. clip = core.std.SetFrameProps(clip=clip, _SARNum=1, _SARDen=1)
  81. # output
  82. clip.set_output()
  83. # clip current meta; color space: YUV420P10, bit depth: 10, resolution: 1440x1080, fps: 11.9889, color matrix: 709, color primaries: Unspecific, color transfer: BT.709, yuv luminance scale: limited, scanorder: progressive, full height: true (Meta)
  84. # script was created by Hybrid 2026.11.06.1
Advertisement
Add Comment
Please, Sign In to add comment