Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Imports
- import vapoursynth as vs
- # getting Vapoursynth core
- import ctypes
- import sys
- import os
- core = vs.core
- # 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/Support/libvs_placebo.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SharpenFilter/AWarpSharp2/libawarpsharp2.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/vszip.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SharpenFilter/CAS/CAS.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/CTMF/CTMF.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/DePan.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DebandFilter/Flash3kDeband/flash3kyuu_deband.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/EEDI3m_opencl.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/ResizeFilter/nnedi3/NNEDI3CL.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/MiscFilter/MiscFilters/MiscFilters.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/ZSmooth/zsmooth.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/GrainFilter/AddGrain/AddGrain.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/Support/libmvtools.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/akarin.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DeinterlaceFilter/TIVTC/libtivtc.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV_AVX2.dll")
- # Import scripts
- import dehalo
- import nnedi3_resample
- import smdegrain
- import edge
- import stabilize
- import SpotLess
- import chromashift
- import color
- import qtgmc
- import validate
- # Source: 'C:\Users\Selur\Desktop\clips\001.mpg'
- # Current color space: YUV420P8, bit depth: 8, resolution: 720x576, frame rate: 25fps, scanorder: top field first, yuv luminance scale: limited, matrix: 470bg, format: mpeg-2
- # Loading C:\Users\Selur\Desktop\clips\001.mpg using DGSource
- clip = core.dgdecodenv.DGSource("J:/tmp/mpg_892812d634e3a34795d106e2622c0a3b_853323747.dgi",fieldop=0)# 25 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.
- clip = core.std.SetFrameProps(clip=clip, _ColorRange=vs.RANGE_LIMITED)
- # making sure frame rate is set to 25fps
- clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
- # making sure the detected scan type is set (detected: top field first)
- clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_TOP) # tff
- clip = core.tivtc.TFM(clip=clip)
- # Making sure content is preceived as frame based
- clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # progressive
- # Denoising using QTGMC
- clip = qtgmc.QTGMC(Input=clip, Preset="Fast", InputType=3, TR2=1, TFF=False, SourceMatch=0, Lossless=0, opencl=True)
- # adjusting color using SmoothLevels
- clip = color.SmoothLevels(input=clip, output_low=16, output_high=235, gamma=0.55, limiter=2, Lmode=2, Ecurve=1)
- # Chroma adjustment using ChromaShiftSP
- clip = chromashift.ChromaShiftSP(clip=clip, X=2.00, Y=3.00, jeh=False)
- # Spot removal using SpotLess
- clip = SpotLess.SpotLess(clip=clip, radT=2, rec=True, pel=1, smoother="zsmooth")
- # stabilizing using Stab
- clip = stabilize.Stab(clp=clip,range=3,mirror=0,dxmax=14,dymax=14)
- clip = core.std.Crop(clip=clip, left=14, right=10, top=64, bottom=74)# cropping to 696x438
- # Fix bright and dark line artifacts near the border of an image using BalanceBorders
- clip = edge.bbmod(c=clip,cLeft=12,cTop=0,cRight=12,cBottom=0,thresh=64)
- # removing grain using SMDegrain
- clip = smdegrain.SMDegrain(input=clip, interlaced=False, opencl=True, device=-1)
- # contrast sharpening using CAS
- clip = core.cas.CAS(clip=clip, sharpness=0.600)
- # applying dehalo using DeHalo_alpha
- clip = dehalo.DeHalo_alpha(clip)
- # applying dehalo using YAHR
- clip = dehalo.YAHR(clip, depth=16)
- clip = dehalo.YAHR(clip, depth=16)
- clip = dehalo.YAHR(clip, depth=16)
- clip = dehalo.YAHR(clip, depth=16)
- clip = dehalo.YAHR(clip, depth=16)
- # Resizing using 10 - bicubic spline
- clip = core.fmtc.resample(clip=clip, kernel="spline16", w=1280, h=756, interlaced=False, interlacedd=False) # resolution 1280x756 before YUV420P8 after YUV420P16
- # adjusting color space from YUV420P16 to YUV444P16 for vsGLSLFilmGrain
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, range_s="limited")
- with open("F:/Hybrid/64bit/vsfilters/GLSL/parameterized/filmgrain.glsl") as glslf:
- glsl = glslf.read()
- glsl = glsl.replace('#define INTENSITY 0.05', '#define INTENSITY 0.01')
- clip = core.placebo.Shader(clip=clip, shader_s=glsl, width=clip.width, height=clip.height)
- # adjusting output color from: YUV444P16 to YUV420P10 for NVEncModel
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, range_s="limited", dither_type="error_diffusion")
- # set output frame rate to 25fps (progressive)
- clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
- # output
- clip.set_output()
Advertisement
Add Comment
Please, Sign In to add comment