Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Imports
- import vapoursynth as vs
- import os
- import sys
- # getting Vapoursynth core
- 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/libvs_placebo.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SharpenFilter/AWarpSharp2/libawarpsharp2.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV.dll")
- # Import scripts
- import chromashift
- import muvsfunc
- import mvsfunc
- # source: 'C:\Users\Selur\Desktop\Gym Snip.mp4'
- # current color space: YUV420P8, bit depth: 8, resolution: 642x480, fps: 29.97, color matrix: 470bg, yuv luminance scale: limited, scanorder: progressive
- # Loading C:\Users\Selur\Desktop\Gym Snip.mp4 using DGSource
- clip = core.dgdecodenv.DGSource("J:/tmp/mp4_076c6c66888029ce51821890f630a438_853323747.dgi")# 29.97 fps, scanorder: progressive
- # Setting detected color matrix (470bg).
- clip = core.std.SetFrameProps(clip, _Matrix=5)
- # Setting color transfer info (470bg), when it is not set
- clip = clip if not core.text.FrameProps(clip,'_Transfer') else core.std.SetFrameProps(clip, _Transfer=5)
- # Setting color primaries info (BT.601 NTSC), when it is not set
- 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.97
- clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
- clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=0) # progressive
- # Color Adjustment using SmoothGrad
- clip = muvsfunc.SmoothGrad(input=clip)
- # Chroma adjustment using ChromaShiftSP
- clip = chromashift.ChromaShiftSP(clip=clip, X=-5.50, shiftV=False)
- # adjusting resolution before resizing
- clip = core.fmtc.resample(clip=clip, w=642, h=240, kernel="lanczos", interlaced=False, interlacedd=False)# before YUV420P8 after YUV420P16
- # Resizing using 10 - bicubic spline
- clip = core.fmtc.resample(clip=clip, kernel="spline16", w=642, h=480, interlaced=False, interlacedd=False) # resolution 642x480 before YUV420P16 after YUV420P16
- # sharpening using AWarpSharp2
- clip = core.warp.AWarpSharp2(clip=clip, blur=2, depth=32, chroma=True, planes=[1,2])
- # adjusting color space from YUV420P16 to YUV444P16 for vsGLSLFilmGrain
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, range_s="limited", dither_type="error_diffusion")
- with open("F:/Hybrid/64bit/vsfilters/GLSL/parameterized/filmgrain.glsl") as glslf:
- glsl = glslf.read()
- glsl = glsl.replace('#define INTENSITY 0.05', '#define INTENSITY 0.02')
- clip = core.placebo.Shader(clip=clip, shader_s=glsl, width=clip.width, height=clip.height)
- clip = core.std.AddBorders(clip=clip, left=4, right=4, top=0, bottom=0) # add borders to archive mod 8 (vsBasicVSRPPFilter) - 650x480
- # 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, length=20)
- clip = core.std.CropRel(clip=clip, left=4, right=4, top=0, bottom=0) # removing borders (vsBasicVSRPPFilter) - 642x480
- # adjusting output color from: RGBH to YUV420P10 for QSVEncModel
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, matrix_s="470bg", 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