Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Imports
- import vapoursynth as vs
- # getting Vapoursynth core
- core = vs.core
- import site
- # Import libraries for onnxruntime
- import ctypes
- path = site.getsitepackages()[0]+'/onnxruntime_dlls/'
- ctypes.windll.kernel32.SetDllDirectoryW(path)
- # Loading Plugins
- core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
- core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/Support/libvs_placebo.dll")
- core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/DebandFilter/Flash3kDeband/flash3kyuu_deband.dll")
- core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/DeinterlaceFilter/TIVTC/libtivtc.dll")
- core.std.LoadPlugin(path="i:/Hybrid/64bit/vsfilters/SourceFilter/LSmashSource/vslsmashsource.dll")
- # source: 'C:\Users\Selur\Desktop\Taylor Swift - You Belong With Me_USCJY0903499-Source Prores 480i.mkv'
- # current color space: YUV422P10, bit depth: 10, resolution: 720x480, fps: 29.97, color matrix: 170m, yuv luminance scale: limited, scanorder: telecine
- # Loading C:\Users\Selur\Desktop\Taylor Swift - You Belong With Me_USCJY0903499-Source Prores 480i.mkv using LWLibavSource
- clip = core.lsmas.LWLibavSource(source="C:/Users/Selur/Desktop/Taylor Swift - You Belong With Me_USCJY0903499-Source Prores 480i.mkv", format="YUV422P10", stream_index=0, cache=0, prefer_hw=0)
- # Setting color matrix to 170m.
- clip = core.std.SetFrameProps(clip, _Matrix=6)
- clip = clip if not core.text.FrameProps(clip,'_Transfer') else core.std.SetFrameProps(clip, _Transfer=6)
- clip = clip if not core.text.FrameProps(clip,'_Primaries') else 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.970
- clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
- # Deinterlacing using TIVTC
- clip = core.tivtc.TFM(clip=clip)
- clip = core.tivtc.TDecimate(clip=clip)# new fps: 23.976
- # make sure content is preceived as frame based
- clip = core.std.SetFieldBased(clip, 0)
- # cropping the video to 720x364
- clip = core.std.CropRel(clip=clip, left=0, right=0, top=58, bottom=58)
- from vsdpir import DPIR
- # adjusting color space from YUV422P10 to RGBS for vsDPIRDenoise
- clip = core.resize.Bicubic(clip=clip, format=vs.RGBS, matrix_in_s="170m", range_s="limited")
- # denoising using DPIRDenoise
- clip = DPIR(clip=clip, strength=5.000, task="denoise", provider=1, device_id=0)
- # adjusting color space from RGBS to YUV444P16 for vsFlash3kDB
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="170m", range_s="limited", dither_type="error_diffusion")
- # debanding using f3kdb
- clip = core.f3kdb.Deband(clip, keep_tv_range=True, output_depth=16)
- with open("i:/Hybrid/64bit/vsfilters/GLSL/parameterized/Anime4K_Darken_HQ.glsl") as glslf:
- glsl = glslf.read()
- glsl = glsl.replace('#define STRENGTH 1.5', '#define STRENGTH 2.5')
- clip = core.placebo.Shader(clip=clip, shader_s=glsl, width=clip.width, height=clip.height)
- from vsswinir import SwinIR
- # adjusting color space from YUV444P16 to RGBS for VsSwinIR
- clip = core.resize.Bicubic(clip=clip, format=vs.RGBS, matrix_in_s="170m", range_s="limited")
- # resizing using SwinIR
- clip = SwinIR(clip=clip, task="lightweight_sr", scale=4, device_type="cuda", device_index=0) # 2880x1456
- # resizing 2880x1456 to 3840x2160
- # adjusting resizing
- clip = core.fmtc.resample(clip=clip, w=3840, h=2160, kernel="lanczos", interlaced=False, interlacedd=False)
- # adjusting output color from: RGBS to YUV420P10 for x265Model
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, matrix_s="170m", range_s="limited", dither_type="error_diffusion")
- # set output frame rate to 23.976fps
- clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001)
- # Output
- clip.set_output()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement