Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Imports
- import sys
- import os
- import vapoursynth as vs
- # getting Vapoursynth core
- core = vs.core
- # Limit frame cache to 48449MB
- core.max_cache_size = 48449
- # 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/DenoiseFilter/ZSmooth/zsmooth.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DeinterlaceFilter/TIVTC/libtivtc.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/CTMF/CTMF.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV_AVX2.dll")
- # Import scripts
- import validate
- # Source: 'C:\Users\Selur\Desktop\OPBox2.mkv'
- # Current color space: YUV420P8, bit depth: 8, resolution: 1920x1080, frame rate: 29.97fps, scanorder: telecine, yuv luminance scale: limited, matrix: 709, format: AVC
- # Loading 'C:\Users\Selur\Desktop\OPBox2.mkv' using DGSource
- clip = core.dgdecodenv.DGSource("J:/tmp/mkv_0604cae322f9fbe00040844b856ac3a4_853323747.dgi",fieldop=0) # 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
- # converting interlaced to half-height progressive for filtering (vsCTMF) (separate fields)
- clip = core.std.SeparateFields(clip, tff=False) # resolution 1920x540
- clipEven = clip[::2]
- clipEven = core.std.SetFrameProps(clip=clipEven, _FieldBased=vs.FIELD_PROGRESSIVE) # scan type: progressive
- clipOdd = clip[1::2]
- clipOdd = core.std.SetFrameProps(clip=clipOdd, _FieldBased=vs.FIELD_PROGRESSIVE) # scan type: progressive
- # denoising using CTMF
- clipEven = core.ctmf.CTMF(clipEven, radius=1, memsize=1048576, opt=2)
- # denoising using CTMF
- clipOdd = core.ctmf.CTMF(clipOdd, radius=1, memsize=1048576, opt=2)
- # converting half-height progressive to interlaced
- clip = core.std.Interleave([clipEven, clipOdd])
- clip = core.std.DoubleWeave(clip=clip, tff=False) # resolution: 1920x1080
- clip = core.std.SelectEvery(clip, 2, 0) # scan type: bottom field first
- clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_TOP) # scan type: top field first
- # Deinterlacing using TIVTC
- clip = core.tivtc.TFM(clip)
- clip = core.tivtc.TDecimate(clip) # new fps: 23.976
- # Making sure content is preceived as frame based
- clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # scan type: progressive
- # adjusting color space from YUV420P8 to RGB24 for vsCCD
- clip = core.resize.Bicubic(clip=clip, format=vs.RGB24, matrix_in_s="709", range_in_s="limited", range_s="full")
- # chroma denoising using CCD
- clip = core.zsmooth.CCD(clip, threshold=60.00, points=[True,True,False])
- # adjusting output color from RGB24 to YUV420P10 for NVEncModel
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, matrix_s="709", range_in_s="full", range_s="limited", dither_type="error_diffusion") # additional resize to match target color sampling
- # set output frame rate to 23.976fps (progressive)
- clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001)
- # output
- clip.set_output()
- # script was created by Hybrid 2026.04.07.1
Advertisement
Add Comment
Please, Sign In to add comment