Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Imports
- import vapoursynth as vs
- import os
- import sys
- os.environ["CUDA_MODULE_LOADING"] = "LAZY"
- # 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/ColorFilter/Retinex/Retinex.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DebandFilter/Flash3kDeband/flash3kyuu_deband.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vs-mlrt/vstrt.dll")
- import site
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/LSmashSource/vslsmashsource.dll")
- # Import scripts
- from importlib.machinery import SourceFileLoader
- vsmlrt = SourceFileLoader('vsmlrt', 'F:/Hybrid/64bit/vs-mlrt/vsmlrt.py').load_module()
- import masked
- # source: 'C:\Users\Selur\Desktop\wind noise.mkv'
- # current color space: YUV420P8, bit depth: 8, resolution: 1024x576, fps: 59.94, color matrix: 709, yuv luminance scale: limited, scanorder: progressive
- # Loading C:\Users\Selur\Desktop\wind noise.mkv using LWLibavSource
- clip = core.lsmas.LWLibavSource(source="C:/Users/Selur/Desktop/wind noise.mkv", format="YUV420P8", stream_index=0, cache=0, prefer_hw=0)
- # Setting detected color matrix (709).
- clip = core.std.SetFrameProps(clip, _Matrix=1)
- # Setting color transfer info (709), when it is not set
- clip = clip if not core.text.FrameProps(clip,'_Transfer') else core.std.SetFrameProps(clip, _Transfer=1)
- # Setting color primaries info (), 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 59.94
- clip = core.std.AssumeFPS(clip=clip, fpsnum=60000, fpsden=1001)
- clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=0) # progressive
- from vsmlrt import Backend
- ## Starting applying 'limit' masked filtering for vsDPIRmlrtDeblock
- clipMask = clip
- clipMask = core.resize.Bicubic(clip=clipMask, format=vs.RGBS, matrix_in_s="709", range_s="limited")
- clipMask = core.resize.Bicubic(clip=clipMask, format=vs.GRAYS, matrix_s="709", range_s="limited")
- clipMask = core.std.BinarizeMask(clipMask, 0.117647)
- clipMask = core.std.InvertMask(clipMask)
- clipFiltered = clip
- # adjusting color space from YUV420P8 to RGBS for vsDPIRmlrtDeblock
- clipFiltered = core.resize.Bicubic(clip=clipFiltered, format=vs.RGBS, matrix_in_s="709", range_s="limited")
- # adjusting deblocking using DPIR (mlrt)
- clipFiltered = vsmlrt.DPIR(clipFiltered, strength=50.000, overlap=16, model=3, backend=Backend.TRT(fp16=False, device_id=0,verbose=True,use_cuda_graph=False, num_streams=1, workspace=1 << 30))
- clip = core.resize.Bicubic(clip=clip, format=vs.RGBS, matrix_in_s="709", range_s="limited")
- clip = core.std.MaskedMerge(clip, clipFiltered, clipMask) # LimitMask
- ## Finished applying 'LimitMask' masked filtering for vsDPIRmlrtDeblock
- # adjusting color space from RGBS to YUV444P16 for vsFlash3kDB
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="709", range_s="limited", dither_type="error_diffusion")
- # debanding using f3kdb
- clip = core.f3kdb.Deband(clip, keep_tv_range=True, output_depth=-1)
- # adjusting color space from YUV444P16 to YUV444P10 for vsRetinex
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P10, range_s="limited")
- # color adjustment using Retinex
- clip = core.retinex.MSRCP(input=clip, sigma=[25,80,250], fulls=False, fulld=False)
- # adjusting output color from: YUV444P10 to YUV420P8 for x264Model
- clip = core.resize.Bicubic(clip=clip, dither_type="error_diffusion", format=vs.YUV420P8, range_s="limited")
- # set output frame rate to 59.94fps (progressive)
- clip = core.std.AssumeFPS(clip=clip, fpsnum=60000, fpsden=1001)
- # Output
- clip.set_output()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement