Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Imports
- import vapoursynth as vs
- # getting Vapoursynth core
- import site
- 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")
- # Adding torch dependencies to PATH
- path = site.getsitepackages()[0]+'/torch_dependencies/bin/'
- ctypes.windll.kernel32.SetDllDirectoryW(path)
- path = path.replace('\\', '/')
- os.environ["PATH"] = path + os.pathsep + os.environ["PATH"]
- # Loading Plugins
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/FFT3DFilter/fft3dfilter.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/CTMF/CTMF.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libmvtools_sf_em64t.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/TCanny.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/GrainFilter/RemoveGrain/RemoveGrainVS.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/GrainFilter/AddGrain/AddGrain.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/DFTTest/DFTTest.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/NEO_FFT3DFilter/neo-fft3d.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/EEDI3m.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/ResizeFilter/nnedi3/vsznedi3.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libmvtools.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/scenechange.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/MiscFilter/MiscFilters/MiscFilters.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DeinterlaceFilter/Bwdif/Bwdif.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libdescale.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/LSmashSource/vslsmashsource.dll")
- # Import scripts
- import G41Fun
- import havsfunc
- # source: 'C:\Users\Selur\Desktop\Interlaced Video.mov'
- # current color space: YUV422P10, bit depth: 10, resolution: 720x544, fps: 29.97, color matrix: 709, yuv luminance scale: limited, scanorder: top field first
- # Loading C:\Users\Selur\Desktop\Interlaced Video.mov using LibavSMASHSource
- clip = core.lsmas.LibavSMASHSource(source="C:/Users/Selur/Desktop/Interlaced Video.mov")
- frame = clip.get_frame(0)
- # Setting detected color matrix (709).
- clip = core.std.SetFrameProps(clip, _Matrix=1)
- # Setting color transfer (to 709), if it is not set.
- if '_Transfer' not in frame.props or not frame.props['_Transfer']:
- clip = core.std.SetFrameProps(clip, _Transfer=1)
- # Setting color primaries info (to 5), if it is not set.
- if '_Primaries' not in frame.props or not frame.props['_Primaries']:
- clip = core.std.SetFrameProps(clip, _Primaries=5)
- # Setting color range to TV (limited) range.
- clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
- # making sure frame rate is set to 29.97
- clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
- clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=2) # tff
- # converting interlaced to half-height progressive for filtering (vsVinverse) (separate fields)
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P10, range_s="limited")
- clip = core.std.SeparateFields(clip, tff=True)
- clipEven = clip[::2] # resolution 720x272
- clipEven = core.std.SetFrameProp(clip=clipEven, prop="_FieldBased", intval=0) # progressive
- clipOdd = clip[1::2] # resolution 720x272
- clipOdd = core.std.SetFrameProp(clip=clipOdd, prop="_FieldBased", intval=0) # progressive
- clipEven = havsfunc.Vinverse(clp=clipEven)
- clipOdd = havsfunc.Vinverse(clp=clipOdd)
- # converting half-height progressive to interlacedbefore deinterlacing
- clip = core.std.Interleave([clipOdd, clipEven])
- clip = core.std.DoubleWeave(clip=clip, tff=True) # resolution 720x544
- clip = core.std.SelectEvery(clip, 2, 0)
- clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=2) # tff
- # adjusting resolution before deinterlacing
- clip = core.descale.Debicubic(src=clip, width=720, height=160, b="0.00", c="0.50")
- # Deinterlacing using QTGMC
- clip = havsfunc.QTGMC(Input=clip, Preset="Fast", TFF=True) # new fps: 29.97
- # Making sure content is preceived as frame based
- clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=0) # progressive
- clip = clip[::2] # selecting previously even frames
- from vsdpir import dpir as DPIR
- # adjusting color space from YUV444P10 to RGBH for vsDPIRDeblock
- clip = core.resize.Bicubic(clip=clip, format=vs.RGBH, matrix_in_s="709", range_s="limited")
- # deblocking using DPIRDeblock
- clip = DPIR(clip=clip, strength=25.000, task="deblock", device_index=0)
- # adjusting color space from RGBH to YUV444P16 for vsTemporalDegrain2
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="709", range_s="limited")
- # removing grain using TemporalDegrain2
- clip = G41Fun.TemporalDegrain2(clip=clip, degrainPlane=4, meAlgPar=False, postFFT=0, fftThreads=1)
- # Resizing using 10 - bicubic spline
- clip = core.fmtc.resample(clip=clip, kernel="spline16", w=720, h=544, interlaced=False, interlacedd=False) # resolution 720x544 before YUV444P16 after YUV444P16
- # adjusting output color from: YUV444P16 to YUV420P8 for x264Model
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P8, range_s="limited", dither_type="error_diffusion")
- # set output frame rate to 29.97fps (progressive)
- clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
- # Output
- clip.set_output()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement