Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Imports
- import ctypes
- 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 Support Files
- Dllref = ctypes.windll.LoadLibrary("F:/Hybrid/64bit/vsfilters/Support/libfftw3f-3.dll")
- # loading plugins
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/Cnr2/libcnr2.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SharpenFilter/MSmooth/libmsmoosh.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/vsnlm_cuda.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/NEO_FFT3DFilter/neo-fft3d.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/DFTTest/DFTTest.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DeinterlaceFilter/Bwdif/Bwdif.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/fmtconv.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/ResizeFilter/nnedi3/NNEDI3CL.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libeedi3vk.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/addnoise.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/mvtools.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/zsmooth/zsmooth.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DerainbowFilter/DeCross/libdecross.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV_AVX2.dll")
- # Import scripts
- import edi_rpow2
- import fromDoom9
- import derainbow
- import qtgmc
- import validate
- # Source: 'G:\clips\rainbows\output.mkv'
- # 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))
- # Loading 'G:\clips\rainbows\output.mkv' using DGSource
- clip = core.dgdecodenv.DGSource("J:/tmp/mkv_32aadea3e3412fbbdf318f8d53a89756_853323747.dgi",fieldop=0) # 29.97 fps, scanorder: top field first
- frame = clip.get_frame(0)
- # setting color matrix to 470bg.
- clip = core.std.SetFrameProps(clip, _Matrix=vs.MATRIX_BT470_BG)
- # setting color transfer (vs.TRANSFER_BT601), if it is not set.
- if validate.transferIsInvalid(clip):
- clip = core.std.SetFrameProps(clip=clip, _Transfer=vs.TRANSFER_BT601)
- # setting color primaries info (to vs.PRIMARIES_BT470_BG), if it is not set.
- if validate.primariesIsInvalid(clip):
- clip = core.std.SetFrameProps(clip=clip, _Primaries=vs.PRIMARIES_BT470_BG)
- # 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: top field first)
- clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_TOP) # scan type: top field first
- # cutting from frame 2450 to 3249 - WARNING: This might cause synch issues
- clip = core.std.Trim(clip=clip, first=2450, last=3249)
- # rainbow removal using DeCross
- clip = core.decross.DeCross(clip, thresholdy=1, noise=80, margin=2)
- # Deinterlacing using QTGMC
- clip = qtgmc.QTGMC(clip, Preset="Fast", TFF=True, opencl=True) # new fps: 59.94
- # Making sure content is preceived as frame based
- clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # scan type: progressive
- clip = core.std.Crop(clip, left=8, right=8, top=0, bottom=0) # cropping to 704x480
- # rainbow removal using LUTDeRainbow
- clip = derainbow.LUTDeRainbow(clip, cthresh=20, ythresh=60)
- # denoising using KNLMeansCL
- clip = core.nlm_cuda.NLMeans(clip, a=6, h=5.00, channels="UV")
- # removing flickering using Small Deflicker
- clip = fromDoom9.Small_Deflicker(clip, preset=3, cnr=True)
- # resizing using NNEDI3CL
- # current: 704x480 target: 1280x982
- clip = edi_rpow2.nnedi3cl_rpow2(clip, rfactor=4, nsize=3, nns=4) # 2816x1920
- # resizing 2816x1920 to 1280x982
- clip = core.fmtc.resample(clip, w=1280, h=982, kernel="spline64", interlaced=False, interlacedd=False) # 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 59.94fps (progressive)
- clip = core.std.AssumeFPS(clip=clip, fpsnum=60000, fpsden=1001)
- # output
- clip.set_output()
- # clip current meta; color space: YUV420P10, bit depth: 10, resolution: 1280x982, fps: 59.94, color matrix: 470bg, color primaries: Unspecific, color transfer: BT.601, yuv luminance scale: limited, scanorder: progressive, full height: true (Meta)
- # script was created by Hybrid 2026.05.16.1
Advertisement
Add Comment
Please, Sign In to add comment