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/akarin.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/vszip.dll")
- core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/BestSource/BestSource.dll")
- # defining beforeAutoGain-function - START
- def beforeAutoGain(clip):
- # requires colorformat YUV444PS
- import color
- min_val = 16/255.0 # ≈ 0.0627451
- max_val = 235/255.0 # ≈ 0.9215686
- limit = 0.15
- for i in range(20):
- clip = color.Tweak(clip, hue=0.00, sat=1.00, cont=1.00, bright=-limit, coring=True)
- clip = core.std.Limiter(clip, min=min_val, max=max_val, planes=[0])
- clip = color.Tweak(clip, hue=0.00, sat=1.00, cont=1.00, bright=limit, coring=True)
- return [clip]
- # defining beforeAutoGain-function - END
- # Import scripts
- import color
- import validate
- # Source: 'C:/Users/Selur/Desktop/4uHeJFa.png'
- # Current color space: RGB24, bit depth: 8, resolution: 778x528, frame rate: 25fps, scanorder: progressive, yuv luminance scale: limited, matrix: 240m, format: PNG
- # Loading 'C:/Users/Selur/Desktop/4uHeJFa.png' using BestSource
- clip = core.bs.VideoSource(source="C:/Users/Selur/Desktop/4uHeJFa.png", cachepath="J:/tmp/4uHeJFa_bestSource", hwdevice="opencl")
- clip = core.std.Loop(clip=clip, times=100)
- frame = clip.get_frame(0)
- # 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)
- # 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 format to YUV444PS for custom section
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV444PS, matrix_s="240m", range_in_s="full", range_s="limited", dither_type="error_diffusion") # additional resize to match target color sampling
- [clip] = beforeAutoGain(clip)
- # clip current meta; color space: YUV444PS, bit depth: 32, resolution: 778x528, fps: 25, color matrix: 240m, yuv luminance scale: limited, scanorder: progressive, full height: true
- # adjusting color space from YUV444PS to RGB48 for vsAutoWhite
- clip = core.resize.Bicubic(clip=clip, format=vs.RGB48, matrix_in_s="240m", range_in_s="limited", range_s="full")
- # adjusting colors using AutoWhite
- clip = color.AutoWhite(clip)
- # adjusting output color from RGB48 to YUV420P10 for NVEncModel
- clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, matrix_s="240m", range_in_s="full", range_s="limited") # additional resize to match target color sampling
- # set output frame rate to 25fps (progressive)
- clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
- # output
- clip.set_output()
- # script was created by Hybrid 2026.01.11.1
Advertisement
Add Comment
Please, Sign In to add comment