Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Imports
- import ctypes
- import logging
- import sys
- import os
- import vapoursynth as vs
- # using Vapoursynth R79
- # getting Vapoursynth core
- 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))
- # Force logging to std:err
- logging.StreamHandler(sys.stderr)
- # Loading Support Files
- Dllref = ctypes.windll.LoadLibrary("F:/Hybrid/64bit/vsfilters/Support/libfftw3f-3.dll")
- # loading plugins
- core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/nnedi3vk/nnedi3vk.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/cas.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/DFTTest/DFTTest.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/edgemasks.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/NEO_FFT3DFilter/neo-fft3d.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/deblock.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/descratch.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/fmtconv.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vs-mlrt/vstrt.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/mvutensils/mvutensils.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/zsmooth/zsmooth.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/vszip/vszip.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/grayworld.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/akarin/libakarin.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/Vapoursynth/Lib/site-packages/vapoursynth/plugins2/libbestsource.dll")
- # defining beforeCrop-function - START
- def beforeCrop(clip):
- clip = core.std.Expr(clip, expr=["x 200 > x 0.8 * 40 + x ?","", ""])
- return [clip]
- # defining beforeCrop-function - END
- # Import scripts
- import edi_rpow2
- import denoise
- import SpotLess
- import masked
- import vs_temporalfix
- import fromDoom9
- import color
- import validate
- # Source: 'C:\Users\Selur\Desktop\O GROYSOYZHS_for_stabilize_31807.mov'
- # clip current meta; color space: YUV422P10, bit depth: 10, resolution: 1920x1080, fps: 25, color matrix: 709, color primaries: Unspecific, color transfer: BT.709, yuv luminance scale: limited, scanorder: progressive, full height: true (Source)
- # Loading 'C:\Users\Selur\Desktop\O GROYSOYZHS_for_stabilize_31807.mov' using BestSource
- clip = core.bs.VideoSource(source="C:/Users/Selur/Desktop/O GROYSOYZHS_for_stabilize_31807.mov", cachepath="J:/tmp/O GROYSOYZHS_for_stabilize_31807_bestSource", track=0, hwdevice="opencl")
- frame = clip.get_frame(0)
- # setting color matrix to 709.
- clip = core.std.SetFrameProps(clip, _Matrix=vs.MATRIX_BT709)
- # setting color transfer (vs.TRANSFER_BT709), if it is not set.
- if validate.transferIsInvalid(clip):
- clip = core.std.SetFrameProps(clip=clip, _Transfer=vs.TRANSFER_BT709)
- # setting color primaries info (to vs.PRIMARIES_BT709), if it is not set.
- if validate.primariesIsInvalid(clip):
- clip = core.std.SetFrameProps(clip=clip, _Primaries=vs.PRIMARIES_BT709)
- # setting color range to TV (limited) range.
- prop_name = '_Range' if core.core_version.release_major >= 74 else '_ColorRange'
- clip = core.std.SetFrameProps(clip=clip, **{prop_name: vs.RANGE_LIMITED})
- # making sure frame rate is set to 25fps
- clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
- # making sure the detected scan type is set (detected: progressive)
- clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # scan type: progressive
- # adjusting color space from YUV422P10 to RGB30 for vsLevels
- clip = core.resize.Bicubic(clip=clip, format=vs.RGB30, matrix_in_s="709", range_in_s="limited", range_s="full")
- # adjusting color using Levels on RGB30 (10 bit)
- clip = core.std.Levels(clip, min_in=0, max_in=1020, min_out=64, max_out=940)
- # adjusting color space from RGB30 to YUV444P10 for vsTweak
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P10, matrix_s="709", range_in_s="full", range_s="limited")
- # adjusting color using Tweak
- clip = color.Tweak(clip, hue=0.00, sat=0.00, cont=0.80, coring=True)
- # adjusting color space from YUV444P10 to RGBS for vsGrayworld
- clip = core.resize.Bicubic(clip=clip, format=vs.RGBS, matrix_in_s="709", range_in_s="limited", range_s="full")
- # adjusting color using Grayworld
- clip = core.grwrld.grayworld(clip, cc=1)
- # adjusting color space from RGBS to RGB48 for vsAutoWhite
- clip = core.resize.Bicubic(clip=clip, format=vs.RGB48, dither_type="error_diffusion")
- # adjusting colors using AutoWhite
- clip = color.AutoWhite(clip)
- # adjusting color space from RGB48 to YUV444P16 for vsStabilizeIT
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="709", range_in_s="full", range_s="limited")
- # stabilizing using StabilizeIT
- clip = fromDoom9.StabilizeIT(clip, zoomMax=2.00, thSCD2=140)
- # changing range from limited to full range for vsTemporalfix
- clip = core.resize.Bicubic(clip, format=vs.YUV444P16, range_in_s="limited", range_s="full")
- # setting color range to PC (full) range.
- prop_name = '_Range' if core.core_version.release_major >= 74 else '_ColorRange'
- clip = core.std.SetFrameProps(clip=clip, **{prop_name: vs.RANGE_FULL})
- # adjusting color space from YUV444P16 to RGBH for vsTemporalfix
- clip = core.resize.Bicubic(clip=clip, format=vs.RGBH, matrix_in_s="709", range_in_s="full", range_s="full")
- # stabilizing using Temporalfix (Torch)
- clip = vs_temporalfix.model(clip, backend="tensorrt", engine_folder="J:/TRT")
- [clip] = beforeCrop(clip)
- # clip current meta; color space: RGBH, bit depth: 16, resolution: 1920x1080, fps: 25, color matrix: 709, color primaries: Unspecific, color transfer: BT.709, yuv luminance scale: full, scanorder: progressive, full height: true
- clip = core.std.Crop(clip, left=20, right=30, top=4, bottom=20) # cropping to 1870x1056
- ## Starting applying 'limit' masked filtering for vsDeScratch
- # Creating mask for clip
- clipMask = clip
- clipMask = core.resize.Bicubic(clip=clipMask, format=vs.GRAY8, matrix_s="709", range_in_s="full", range_s="full", dither_type="error_diffusion")
- clipMask = core.std.BinarizeMask(clipMask, 30)
- clipFiltered = clip
- clipFiltered = core.resize.Bicubic(clip=clipFiltered, format=vs.RGBS)
- clipFiltered = core.fmtc.resample(clip=clipFiltered, w=720, h=408, kernel="point", interlaced=False, interlacedd=False) # resizing for 'Gimmick' (vsDeScratch)
- # adjusting color space from RGBS to YUV444P8 for vsDeScratch
- clipFiltered = core.resize.Bicubic(clip=clipFiltered, format=vs.YUV444P8, matrix_s="709", range_in_s="full", range_s="full", dither_type="error_diffusion")
- # scratch removal using DeScratch
- clipFiltered = core.descratch.DeScratch(clipFiltered, asym=20, mindif=4, minlen=30, maxangle=3, maxgap=1)
- # adjusting clip color before mask merge
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P8, matrix_s="709", range_in_s="full", range_s="full", dither_type="error_diffusion")
- # Resolution: clip: 1870x1056 and clipFiltered: 720x408 and clipMask: 1870x1056
- # Color: clip: YUV444P8 and clipFiltered: YUV444P8 and clipMask: GRAY8
- clipMask = core.resize.Spline64(clip=clipMask, width=720, height=408)# resize to match filtered dimensions
- clip = core.resize.Spline64(clip=clip, width=720, height=408)# resize to match filtered dimensions
- # Merging: clip and clipFiltered based on clipMask
- clip = core.std.MaskedMerge(clip, clipFiltered, clipMask) # LimitMask
- ## Finished applying 'LimitMask' masked filtering for vsDeScratch
- # Spot removal using SpotLess
- clip = SpotLess.SpotLess(clip, chroma=False, radT=3, rec=True, pel=1)
- # denoising using MCTemporalDenoise
- clip = denoise.MCTemporalDenoise(clip, settings="very high", ncpu=10)
- # contrast sharpening using CAS
- clip = core.cas.CAS(clip, sharpness=0.700)
- # resizing using NNEDI3CL
- # current: 720x408 target: 1920x1084
- clip = edi_rpow2.nnedi3cl_rpow2(clip, rfactor=4, nsize=3, nns=4) # 2880x1632
- # resizing 2880x1632 to 1920x1084
- clip = core.fmtc.resample(clip, w=1920, h=1084, kernel="spline64", interlaced=False, interlacedd=False) # before YUV444P8 after YUV444P16
- # adjusting output color from YUV444P16 to YUV420P10 for NVEncModel
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, dither_type="error_diffusion")
- # changing range from full to limited range for matching filter target luma scale
- clip = core.resize.Bicubic(clip, format=vs.YUV420P10,range_in_s="full", range_s="limited")
- # setting color range to TV (limited) range.
- prop_name = '_Range' if core.core_version.release_major >= 74 else '_ColorRange'
- clip = core.std.SetFrameProps(clip=clip, **{prop_name: vs.RANGE_LIMITED})
- # set output frame rate to 25fps (progressive)
- clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
- # output
- clip.set_output()
- # clip current meta; color space: YUV420P10, bit depth: 10, resolution: 1920x1084, fps: 25, color matrix: 709, color primaries: Unspecific, color transfer: BT.709, yuv luminance scale: limited, scanorder: progressive, full height: true (Meta)
- # script was created by Hybrid 2026.08.11.1
Advertisement
Add Comment
Please, Sign In to add comment