Advertisement
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
- # Limit thread count to 1, due to usage of sRestore
- core.num_threads = 1
- # 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/libtemporalmedian.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SharpenFilter/CAS/CAS.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_opencl.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/ResizeFilter/nnedi3/NNEDI3CL.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/DGDecNV/DGDecodeNV.dll")
- # Import scripts
- import SpotLess
- import havsfunc
- # source: 'C:\Users\Selur\Desktop\Copenhagen01-001-CLIP.mp4'
- # current color space: YUV420P8, bit depth: 8, resolution: 1258x720, fps: 29.97, color matrix: 709, yuv luminance scale: limited, scanorder: top field first
- # Loading C:\Users\Selur\Desktop\Copenhagen01-001-CLIP.mp4 using DGSource
- clip = core.dgdecodenv.DGSource("J:/tmp/mp4_e563cfd6e2734c84919598f607f26f0f_853323747.dgi",fieldop=0)# 29.97 fps, scanorder: top field first
- 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 1), if it is not set.
- if '_Primaries' not in frame.props or not frame.props['_Primaries']:
- clip = core.std.SetFrameProps(clip, _Primaries=1)
- # 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.YUV444P8, range_s="limited")
- clip = core.std.SeparateFields(clip, tff=True)
- clipEven = clip[::2] # resolution 1258x360
- clipEven = core.std.SetFrameProp(clip=clipEven, prop="_FieldBased", intval=0) # progressive
- clipOdd = clip[1::2] # resolution 1258x360
- 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 1258x720
- 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=1258, height=282, b="0.00", c="0.50")
- clip = core.std.AddBorders(clip=clip, left=0, right=2, top=0, bottom=2) # add borders to archive mod 4 (vsQTGMC) - 1260x284
- # Deinterlacing using QTGMC
- clip = havsfunc.QTGMC(Input=clip, Preset="Faster", InputType=0, TFF=True, TR2=0, SourceMatch=0, Lossless=0, EZDenoise=5.00, NoisePreset="Fast", opencl=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
- clip = core.std.CropRel(clip=clip, left=0, right=2, top=0, bottom=2) # removing borders (vsQTGMC) - 1258x282
- clip = core.std.AddBorders(clip=clip, left=0, right=2, top=0, bottom=2) # add borders to archive mod 4 (vsQTGMCFilter) - 1260x284
- # Denoising using QTGMC
- clip = havsfunc.QTGMC(Input=clip, Preset="Fast", InputType=3, TR2=1, TFF=False, SourceMatch=0, Lossless=0, opencl=True)
- clip = core.std.CropRel(clip=clip, left=0, right=2, top=0, bottom=2) # removing borders (vsQTGMCFilter) - 1258x282
- clip = core.std.CropRel(clip=clip, left=0, right=0, top=0, bottom=2)# cropping to 1258x280
- # Resizing using 10 - bicubic spline
- clip = core.fmtc.resample(clip=clip, kernel="spline16", w=1258, h=790, interlaced=False, interlacedd=False) # resolution 1258x790 before YUV444P8 after YUV444P16
- # contrast sharpening using CAS
- clip = core.cas.CAS(clip=clip, sharpness=0.600)
- # adjusting frame count and rate with sRestore
- clip = havsfunc.srestore(source=clip, frate=23.9760)
- # Spot removal using SpotLess
- clip = SpotLess.SpotLess(clip=clip, radT=1, pel=2)
- # 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 23.976fps (progressive)
- clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001)
- # Output
- clip.set_output()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement