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/Support/fmtconv.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libvs_placebo.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libtemporalmedian.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libmvtools.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/LSmashSource/LSMASHSource.dll")
- # Import scripts
- import havsfunc
- import SpotLess
- import chromashift
- # Source: 'C:\Users\Selur\Desktop\Day.avi'
- # Current color space: YUV422P8, bit depth: 8, resolution: 720x480, frame rate: 23.976fps, scanorder: progressive, yuv luminance scale: limited, matrix: 470bg
- # Loading C:\Users\Selur\Desktop\Day.avi using LWLibavSource
- clip = core.lsmas.LWLibavSource(source="C:/Users/Selur/Desktop/Day.avi", format="YUV422P8", stream_index=0, cache=0, prefer_hw=0)
- frame = clip.get_frame(0)
- # Setting detected color matrix (470bg).
- clip = core.std.SetFrameProps(clip, _Matrix=5)
- # setting color transfer (170), if it is not set.
- if ('_Transfer' not in frame.props) or (frame.props['_Transfer'] == '') or (frame.props['_Transfer'] == 0):
- clip = core.std.SetFrameProps(clip, _Transfer=6)
- # setting color primaries info (to 470), if it is not set.
- if ('_Primaries' not in frame.props) or (frame.props['_Primaries'] == '') or (frame.props['_Primaries'] == 0):
- 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 23.976fps
- clip = core.std.AssumeFPS(clip=clip, fpsnum=24000, fpsden=1001)
- # making sure the detected scan type is set (detected: progressive)
- clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=0) # progressive
- # Chroma adjustment using ChromaShiftSP
- clip = chromashift.ChromaShiftSP(clip=clip, X=-2.00)
- # Spot removal using SpotLess
- clip = SpotLess.SpotLess(clip=clip, radT=1, pel=1)
- clip = core.std.CropRel(clip=clip, left=10, right=10, top=58, bottom=58)# cropping to 700x364
- # Fix bright and dark line artifacts near the border of an image using BalanceBorders
- clip = havsfunc.bbmod(c=clip,cLeft=16,cTop=0,cRight=16,cBottom=0)
- # changing range from limited to full range
- clip = core.resize.Bicubic(clip, range_in_s="limited", range_s="full")
- # setting color range to PC (full) range.
- clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=0)
- # adjusting color space from YUV422P8 to RGBH for VsVSGANFilter
- clip = core.resize.Bicubic(clip=clip, format=vs.RGBH, matrix_in_s="470bg", range_s="full")
- # filtering using VSGANFilter
- from vsgan import ESRGAN
- vsgan = ESRGAN(clip=clip,device="cuda")
- model = "F:/Hybrid/64bit/vsgan_models/2x_LD-Anime-Compact.pth"
- vsgan.load(model)
- vsgan.apply() # 1400x728
- clip = vsgan.clip
- # undo resizing 1400x728 to 364x700
- clip = core.resize.Spline64(clip=clip, width=364, height=700) # resolution 364x700)
- # changing range from full to limited range
- clip = core.resize.Bicubic(clip, range_in_s="full", range_s="limited")
- # adjusting color space from RGBH to YUV444P16 for vsGLSLDarken
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="470bg", range_s="limited")
- # 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 1.5')
- clip = core.placebo.Shader(clip=clip, shader_s=glsl, width=clip.width, height=clip.height)
- # fallback - adjusting from 700x364 to output resolution 700x364
- clip = core.resize.Spline64(clip=clip, width=700, height=364) # resolution 700x364)
- # 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