Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Imports
- import vapoursynth as vs
- # getting Vapoursynth core
- import sys
- import os
- core = vs.core
- # Import scripts folder
- scriptPath = 'F:/Hybrid/64bit/vsscripts'
- sys.path.insert(0, os.path.abspath(scriptPath))
- # loading plugins
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SharpenFilter/AWarpSharp2/libawarpsharp2.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/CTMF/CTMF.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libvs_placebo.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/Support/libmvtools.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/GrainFilter/RemoveGrain/RemoveGrainVS.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV.dll")
- # Import scripts
- import lostfunc
- import havsfunc
- import validate
- # Source: 'C:\Users\Selur\Desktop\test.mkv'
- # Current color space: YUV420P8, bit depth: 8, resolution: 640x480, frame rate: 29.97fps, scanorder: progressive, yuv luminance scale: limited, matrix: 470bg, format: AVC
- # Loading C:\Users\Selur\Desktop\test.mkv using DGSource
- clip = core.dgdecodenv.DGSource("J:/tmp/mkv_aaf47d044f0319abfb06280a337316d9_853323747.dgi")# 29.97 fps, scanorder: progressive
- 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 29.97fps
- clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
- # making sure the detected scan type is set (detected: progressive)
- clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # progressive
- # Fix bright and dark line artifacts near the border of an image using BalanceBorders
- clip = havsfunc.bbmod(c=clip,cLeft=0,cTop=4,cRight=0,cBottom=0)
- clip = lostfunc.DeSpot(o=clip)
- # changing color matrix from '470bg' to '709' for vsProPainter
- clip = core.resize.Bicubic(clip, matrix_in_s="470bg", matrix_s="709")
- # changing range from limited to full range for vsProPainter
- clip = core.resize.Bicubic(clip, range_in_s="limited", range_s="full")
- # setting color range to PC (full) range.
- clip = core.std.SetFrameProps(clip=clip, _ColorRange=vs.RANGE_FULL)
- # adjusting color space from YUV420P8 to RGB24 for vsProPainter
- clip = core.resize.Bicubic(clip=clip, format=vs.RGB24, matrix_in_s="709", range_s="full")
- # Inpainting using ProPainter
- from vspropainter import propainter as ProPainter
- clip = ProPainter(clip=clip, img_mask_path="C:/Users/Selur/Desktop/mask.png", length=500, mask_region=(256,256,380,0))
- # internally changing color matrix for YUV<>RGB to '470bg' undoing color matrix change for vsProPainter
- # changing range from full to limited range for vsProPainter
- clip = core.resize.Bicubic(clip, range_in_s="full", range_s="limited")
- clip = core.std.Crop(clip=clip, left=2, right=4, top=0, bottom=0)# cropping to 634x480
- # adjusting color space from RGB24 to YUV444P16 for vsDeHalo_Alpha
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="470bg", range_s="limited")
- # applying dehalo using DeHalo_alpha
- clip = havsfunc.DeHalo_alpha(clip, rx=3.00, ry=3.00)
- clip = core.std.AddBorders(clip=clip, left=2, right=4, top=0, bottom=0) # add borders to archive mod 8 (vsBasicVSRPPFilter) - 640x480
- # adjusting color space from YUV444P16 to RGBH for vsBasicVSRPPFilter
- clip = core.resize.Bicubic(clip=clip, format=vs.RGBH, matrix_in_s="470bg", range_s="limited")
- # Quality enhancement using BasicVSR++
- from vsbasicvsrpp import basicvsrpp as BasicVSRPP
- clip = BasicVSRPP(clip=clip, model=4)
- clip = core.std.Crop(clip=clip, left=2, right=4, top=0, bottom=0) # removing borders (vsBasicVSRPPFilter) - 634x480
- # adjusting color space from RGBH to YUV444P16 for vsGLSLLumaSharpen
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="470bg", range_s="limited")
- with open("F:/Hybrid/64bit/vsfilters/GLSL/parameterized/LumaSharpenHook.glsl") as glslf:
- glsl = glslf.read()
- glsl = glsl.replace('#define sharp_strength 0.30', '#define sharp_strength 1.5000')
- glsl = glsl.replace('#define sharp_clamp 0.035', '#define sharp_clamp 0.0350')
- glsl = glsl.replace('#define pattern 2', '#define pattern 1')
- glsl = glsl.replace('#define offset_bias 1.0', '#define offset_bias 1.0000')
- clip = core.placebo.Shader(clip=clip, shader_s=glsl, width=clip.width, height=clip.height)
- # applying dehalo using YAHR
- clip = havsfunc.YAHR(clip, depth=16)
- # Using Anime4k Darken GLSL filter for line darkening
- with open("F:/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)
- # 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 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