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
- # Limit frame cache to 48449MB
- core.max_cache_size = 48449
- # 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/ResizeFilter/nnedi3/NNEDI3CL.dll")
- 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/fmtconv.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/akarin.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/ZSmooth/zsmooth.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DeinterlaceFilter/TIVTC/libtivtc.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV_AVX2.dll")
- # Import scripts
- import edi_rpow2
- import dehalo
- import validate
- # Source: 'C:\Users\Selur\Desktop\05.mp4'
- # Current color space: YUV420P8, bit depth: 8, resolution: 720x480, frame rate: 29.97fps, scanorder: progressive, yuv luminance scale: limited, matrix: 470bg, format: mpeg-2
- # Loading 'C:\Users\Selur\Desktop\05.mp4' using DGSource
- clip = core.dgdecodenv.DGSource("J:/tmp/mp4_293d961aef361edabdd092b5aebdf51e_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) # scan type: progressive
- # Decimate using TDecimate
- clip = core.tivtc.TDecimate(clip) # new fps: 23.976
- clip = core.std.Crop(clip, left=14, right=12, top=72, bottom=72) # cropping to 694x336
- # applying dehalo using YAHR
- clip = dehalo.YAHR(clip, depth=16) # call: 0
- clip = core.std.AddBorders(clip=clip, left=0, right=2, top=0, bottom=0) # add borders to archive mod 4 (NNEDI3(CL)) - 696x336
- # resizing using NNEDI3CL
- # current: 696x336 target: 1280x698 -> pow: 4
- clip = edi_rpow2.nnedi3cl_rpow2(clip, rfactor=4, nsize=3, nns=4) # 2784x1344
- clip = core.std.Crop(clip=clip, left=0, right=8, top=0, bottom=0) # removing added borders from mod requirement (NNEDI3(CL)) - 2776x1344
- # resizing 2776x1344 to 1280x698
- clip = core.fmtc.resample(clip, w=1280, h=698, kernel="spline64", interlaced=False, interlacedd=False) # before YUV420P8 after YUV420P16
- clip = core.std.AddBorders(clip=clip, left=0, right=0, top=2, bottom=4) # add borders to archive mod 8 (vsBasicVSRPPFilter) - 1280x704
- # adjusting color space from YUV420P16 to RGBH for vsBasicVSRPPFilter
- clip = core.resize.Bicubic(clip=clip, format=vs.RGBH, matrix_in_s="470bg", range_in_s="limited", range_s="full")
- # Quality enhancement using BasicVSR++
- from vsbasicvsrpp import basicvsrpp as BasicVSRPP
- clip = BasicVSRPP(clip, model=4)
- clip = core.std.Crop(clip=clip, left=0, right=0, top=2, bottom=4) # removing added borders from mod requirement (vsBasicVSRPPFilter) - 1280x698
- # adjusting color space from RGBH to YUV444P16 for vsGLSLFilmGrain
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="470bg", range_in_s="full", range_s="limited") # additional resize to match target color sampling
- # Adding grain using GLSL AddGrain
- 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, 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, 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()
- # script was created by Hybrid 2025.12.29.1
Advertisement
Add Comment
Please, Sign In to add comment