Last active
May 30, 2024 15:22
-
-
Save Mr-Z-2697/5dab5352e078cdde96453216ad7a7f92 to your computer and use it in GitHub Desktop.
Rife frame interpolation VapourSynth script for mpv.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import vapoursynth as vs | |
from vapoursynth import core | |
import mvsfunc as mvf | |
from math import log,ceil,floor | |
fps = container_fps | |
css = '4'+['44','22','20'][video_in.format.subsampling_w+video_in.format.subsampling_h] | |
src = video_in.fmtc.bitdepth(bits=16) | |
################ | |
# Rife is very computing power intensive, so maybe you should enable these two lines. | |
''' | |
w,h,wt = video_in.width,video_in.height,480 | |
src = video_in.fmtc.bitdepth(bits=16).resize.Bicubic(wt,(floor(wt*h/w)+(floor(wt*h/w)%2))) | |
''' | |
################ | |
last = core.std.AssumeFPS(src,fpsnum=fps*1e8,fpsden=1e8) | |
''' | |
sup = core.mv.Super(last) | |
vec = core.mv.Analyse(sup,isb=True) | |
last = core.mv.SCDetection(last,vec) | |
''' | |
last = core.misc.SCDetect(last) | |
last = mvf.ToRGB(last).fmtc.bitdepth(bits=32) | |
if fps < 60: | |
for x in range(ceil(log(60/int(fps),2))): | |
# UHD models are faster so even if the video is not uhd it can still be an improvement of speed. | |
# The decline in quality is minor. | |
# 2021/7/8 Change model to 0 (v3.1) because model 1 (v2.4) makes shaky images when uhd=True. | |
last = core.rife.RIFE(last,model=0,uhd=True,sc=True) | |
last = mvf.ToYUV(last,depth=16,css=css) | |
if abs(fps-30)>0.001 and abs(fps-60)>0.001 and fps<60: | |
sup = core.mv.Super(last) | |
vec = core.mv.Analyse(sup,isb=True) | |
vecf = core.mv.Analyse(sup,isb=False) | |
last = core.mv.FlowFPS(last,sup,vec,vecf,60,1) | |
#last = core.fmtc.bitdepth(last,bits=10) | |
last.set_output() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment