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/libmvtools.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/TCanny.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DeinterlaceFilter/TIVTC/libtivtc.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV.dll")
- # Import scripts
- import mcdegrainsharp
- import validate
- # Source: 'C:\Users\Selur\Desktop\fragment.mkv'
- # Current color space: YUV420P8, bit depth: 8, resolution: 720x480, frame rate: 29.97fps, scanorder: telecine, yuv luminance scale: limited, matrix: 470bg, transfer: bt.601, primaries: bt.601 ntsc, format: mpeg-2
- # Loading C:\Users\Selur\Desktop\fragment.mkv using DGSource
- clip = core.dgdecodenv.DGSource("J:/tmp/mkv_01387fde008f41946f510fe24f295f63_853323747.dgi",fieldop=0)# 29.97 fps, scanorder: telecine
- 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: telecine)
- clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_TOP) # tff
- # Deinterlacing using TIVTC
- clip = core.tivtc.TFM(clip=clip)
- clip = core.tivtc.TDecimate(clip=clip, mode=7, rate=25.0000, dupThresh=0.04, vidThresh=3.50, sceneThresh=15.00, nt=3, denoise=True)# new fps: 25
- # Making sure content is preceived as frame based
- clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # progressive
- clip = core.std.Crop(clip=clip, left=10, right=12, top=66, bottom=72)# cropping to 698x342
- # removing grain using MCDegrain
- clip = mcdegrainsharp.mcdegrainsharp(clip=clip, csharp=0.70)
- from vsrealesrgan import realesrgan as RealESRGAN
- clip = core.std.AddBorders(clip=clip, left=0, right=2, top=0, bottom=2) # add borders to archive mod 4 (vsRealESRGAN) - 700x344
- # adjusting color space from YUV420P8 to RGBS for vsRealESRGAN
- clip = core.resize.Bicubic(clip=clip, format=vs.RGBS, matrix_in_s="470bg", range_s="limited")
- # resizing using RealESRGAN
- clip = RealESRGAN(clip=clip, model=5, device_index=0, denoise_strength=0.30) # 2800x1376
- # resizing 2800x1376 to 1280x706
- clip = core.std.Crop(clip=clip, left=0, right=8, top=0, bottom=8) # removing borders (vsRealESRGAN) - 2792x1368
- # adjusting resizing
- clip = core.fmtc.resample(clip=clip, w=1280, h=706, kernel="spline64", interlaced=False, interlacedd=False)
- # adjusting output color from: RGBS to YUV420P10 for NVEncModel
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, matrix_s="470bg", range_s="limited", dither_type="error_diffusion")
- # set output frame rate to 25fps (progressive)
- clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
- # output
- clip.set_output()
Advertisement
Add Comment
Please, Sign In to add comment