43 lines
1.6 KiB
Python
43 lines
1.6 KiB
Python
import os
|
|
import subprocess
|
|
|
|
def createInterpolateScript(upscaleOut, tempName):
|
|
if os.path.isfile(upscaleOut + '.vpy'):
|
|
print('Interpolate script exists')
|
|
return
|
|
|
|
script = ['from vsrife import rife',
|
|
'import vapoursynth as vs',
|
|
'from vapoursynth import core',
|
|
'clip = core.ffms2.Source(source="./' + tempName + ' [4k][HEVC].mkv")',
|
|
'clip = vs.core.resize.Bicubic(clip, width=3840, height=2160, format=vs.RGBS, matrix_in_s="709")',
|
|
'clip = rife(clip=clip, model="4.25.lite", factor_num=2, factor_den=1)',
|
|
'clip = vs.core.resize.Bicubic(clip, format=vs.YUV420P8, matrix_s="709")',
|
|
'clip.set_output()']
|
|
|
|
if not os.path.isfile(upscaleOut + '.vpy'):
|
|
with open(upscaleOut + '.vpy', 'a') as fs:
|
|
fs.writelines([i + '\n' for i in script])
|
|
|
|
def Interpolate4K(interpolateOut, upscaleOut, interpolateVideo, tempName):
|
|
if not interpolateVideo:
|
|
print('Skipped interpolation')
|
|
return
|
|
|
|
if os.path.isfile(interpolateOut):
|
|
print('Already interpolated')
|
|
return
|
|
|
|
createInterpolateScript(upscaleOut, tempName)
|
|
|
|
if not os.path.isfile(upscaleOut + '.vpy'):
|
|
print('=== Interpolation script not found ===')
|
|
return
|
|
|
|
print('Interpolating')
|
|
subprocess.call('vspipe -c y4m "' + upscaleOut + '.vpy" - | ffmpeg -v quiet -stats -i - -c:v hevc_nvenc -qp 5 "' + interpolateOut + '"', shell=True)
|
|
|
|
# Remove Temp Files
|
|
os.remove(upscaleOut + '.ffindex')
|
|
os.remove(upscaleOut + '.vpy')
|