Guest User

Untitled

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