tcFile = r"%temp_file%_timestamps.txt" # timestamps file path
clip = core.ffms2.Source(r"%source_file%", cachefile=r"%source_temp_file%.ffindex", timecodes=tcFile) if os.path.exists(tcFile) else core.ffms2.Source(r"%source_file%", cachefile=r"%source_temp_file%.ffindex")
core = vs.get_core(threads=8)
if not hasattr(core,'svp2'):
core.std.LoadPlugin(r"C:\\Program Files (x86)\\SVP 4\\plugins64\\svpflow2_vs.dll")
if not hasattr(core,'trt'):
core.std.LoadPlugin(r"C:\\Program Files (x86)\\SVP 4\\rife\\vstrt.dll")
import sys
sys.path.append("C:\\Program Files (x86)\\SVP 4\\rife")
from vsmlrt import RIFE, RIFEModel, Backend
from durfix import FixFrameDurations
clip = clip.resize.Spline64(format=vs.YUV420P8)
smoothfps_params = "{rate:{num:1}}"
src_fps = 23.976
demo_mode = 0
stereo_type = 0
nvof = 0
rife = 1
rife_num = 5
rife_den = 2
rife_trt = 1
rife_sc = 0.1
rife_fmt = vs.RGBH
rife_mnum = 46
trt_backend = Backend.TRT(fp16=True,device_id=0,num_streams=4,output_format=1,use_cuda_graph=True,workspace=None)
def interpolate(clip):
input_um = clip.format.replace(core=core, bits_per_sample=32)
input_m = input_um
input_m8 = input_m
input_m = input_m.std.AddBorders(0,0,0,8)
if nvof:
smooth = core.svp2.SmoothFps_NVOF(input_m,smoothfps_params,nvof_src=input_m8,src=input_um,fps=src_fps)
elif not rife:
super = core.svp1.Super(input_m8,super_params)
vectors = core.svp1.Analyse(super["clip"],super["data"],input_m8,analyse_params)
smooth = core.svp2.SmoothFps(input_m,super["clip"],super["data"],vectors["clip"],vectors["data"],smoothfps_params,src=input_um,fps=src_fps)
elif rife:
input_m = input_m.misc.SCDetect(threshold=rife_sc)
input_m = input_m.resize.Bicubic(format=rife_fmt,matrix_in_s="709")
if not rife_trt:
smooth = core.rife.RIFE(input_m,factor_num=rife_num,factor_den=rife_den,model_path=rife_mpath,gpu_id=rife_gpu,gpu_thread=rife_threads,tta=False,sc=True)
else:
smooth = RIFE(input_m,multi=rife_num,model=rife_mnum,backend=trt_backend)
if rife_den>1:
smooth = FixFrameDurations(smooth.std.SelectEvery(cycle=rife_den,offsets=0),input_m,rife_num,rife_den)
smooth = smooth.resize.Point(format=input_um.format.id,matrix_s="709")
smooth = smooth.std.CropRel(0,0,0,8)
smooth = core.svp2.SmoothFps_RIFE(smooth,smoothfps_params,src=input_um,multi=rife_num/rife_den,fps=src_fps)
if demo_mode == 1:
return demo(input_m, smooth)
else:
return smooth
smooth = interpolate(clip)
smooth.set_output()