Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Imports
- import sys
- import os
- import vapoursynth as vs
- # using Vapoursynth R82
- # getting Vapoursynth core
- core = vs.core
- # Import scripts folder
- scriptPath = 'F:/Hybrid/64bit/vsscripts'
- sys.path.insert(0, os.path.abspath(scriptPath))
- # loading plugins
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/TCanny.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/Neo-FFT/neo-fft.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/sangnom.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/tivtc.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/znedi3.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/zsmooth/zsmooth.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/akarin/libakarin.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/mvutensils/mvutensils.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/fmtconv.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/d2vSource/DGDecode.dll")
- # Import scripts
- import degrain
- import antiAliasing
- import qtgmc
- import validate
- # Source: 'C:\Users\Selur\Desktop\【ドラえもん2003年一挙放送{.ts'
- # 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)
- # Loading 'C:\Users\Selur\Desktop\【ドラえもん2003年一挙放送{.ts' using DGDecode
- clip = core.dgdecode.MPEG2Source("J:/tmp/ts_a3de1159c96742744a2c920fd821fd54_853323747.d2v",info=3)# 29.97 fps, scanorder: telecine
- frame = clip.get_frame(0)
- # setting color matrix to 709.
- clip = core.std.SetFrameProps(clip, _Matrix=vs.MATRIX_BT709)
- # setting color transfer (vs.TRANSFER_BT709), if it is not set.
- if validate.transferIsInvalid(clip):
- clip = core.std.SetFrameProps(clip=clip, _Transfer=vs.TRANSFER_BT709)
- # setting color primaries info (to vs.PRIMARIES_BT709), if it is not set.
- if validate.primariesIsInvalid(clip):
- clip = core.std.SetFrameProps(clip=clip, _Primaries=vs.PRIMARIES_BT709)
- # setting color range to TV (limited) range.
- prop_name = '_Range' if core.core_version.release_major >= 74 else '_ColorRange'
- clip = core.std.SetFrameProps(clip=clip, **{prop_name: vs.RANGE_LIMITED})
- # making sure frame rate is set to 29.97fps
- clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
- # making sure the detected scan type is set (detected: telecine)
- clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_TOP) # scan type: top field first
- clip2clip = clip
- 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)
- # Deinterlacing using TIVTC
- clip = core.tivtc.TFM(clip, clip2=clip2clip)
- clip = core.tivtc.TDecimate(clip, mode=7, rate=11.98890, dupThresh=0.04, vidThresh=3.50, sceneThresh=15.00) # new fps: 11.9889
- # Making sure content is perceived as frame based
- clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # scan type: progressive
- clip = core.std.Crop(clip, left=180, right=180, top=0, bottom=0) # cropping to 1080x1080
- # applying anti aliasing using santiag
- clip = antiAliasing.santiag(clip, strh=3, strv=3, type="sangnom", aa=128, tools={'nnedi3': 'znedi3', 'eedi3': 'vszip', 'eedi2': 'eedi2'})
- ## Starting applying 'EdgeMask (Prewitt)' masked filtering for vsTemporalDegrain2
- # Creating mask for clip
- clipMask = clip
- clipMask = core.resize.Bicubic(clip=clipMask, format=vs.GRAY8, range_in_s="limited")
- clipMask = core.std.Prewitt(clip=clipMask)
- for i in range(2):
- clipMask = core.std.Maximum(clipMask)
- clipMask = core.std.ShufflePlanes(clips=[clipMask], planes=[0], colorfamily=vs.GRAY)
- clipFiltered = clip
- # removing grain using TemporalDegrain2
- 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'})
- # Resolution: clip: 1080x1080 and clipFiltered: 1080x1080 and clipMask: 1080x1080
- # Color: clip: YUV420P8 and clipFiltered: YUV420P8 and clipMask: GRAY8
- # Merging: clip and clipFiltered based on clipMask
- clip = core.std.MaskedMerge(clip, clipFiltered, clipMask) # PrewittEdgeMask
- ## Finished applying 'PrewittEdgeMask' masked filtering for vsTemporalDegrain2
- # Resizing using 10 - bicubic spline
- clip = core.fmtc.resample(clip, kernel="spline16", w=1440, h=1080, interlaced=False, interlacedd=False) # resolution 1440x1080 before YUV420P8 after YUV420P16
- # adjusting output color from YUV420P16 to YUV420P10 for NVEncModel
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, dither_type="error_diffusion")
- # set output frame rate to 11.9889fps (progressive)
- clip = core.std.AssumeFPS(clip=clip, fpsnum=12000, fpsden=1001)
- # set output pixel aspect ratio to 1:1
- clip = core.std.SetFrameProps(clip=clip, _SARNum=1, _SARDen=1)
- # output
- clip.set_output()
- # 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)
- # script was created by Hybrid 2026.11.06.1
Advertisement
Add Comment
Please, Sign In to add comment