-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
yaml to ini, random fruits as output filename suffix, and many fixes
configs will now be ini instead of yaml renaming resampling to frame blending additional bool aliases random fruits as output (opt out) custom output folder verbose switch
- Loading branch information
Showing
4 changed files
with
94 additions
and
92 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,67 @@ | ||
from vapoursynth import core | ||
import vapoursynth as vs | ||
from os import path # To split file extension | ||
from yaml import load, FullLoader | ||
from configparser import ConfigParser | ||
import havsfunc # aka Interframe2 | ||
|
||
input_video="D:\\Video Vault\\R 01-30 15-30.mkv" | ||
config_filepath="D:\\GitHub\\Smoothie\\settings\\recipe.yaml" | ||
|
||
conf = load(open(f"{config_filepath}"), Loader=FullLoader) | ||
conf = ConfigParser() | ||
conf.read(config_filepath) | ||
|
||
# Bool aliases | ||
yes = ['True','true','yes','y','1'] | ||
no = ['False','false','no','n','0'] | ||
no = ['False','false','no','n','0','null','',None] | ||
|
||
if path.splitext(input_video)[1] == '.avi': | ||
video = core.avisource.AVISource(f"{input_video}") | ||
video = core.fmtc.matrix(clip=video, mat="601", col_fam=vs.YUV, bits=16) | ||
video = core.fmtc.resampling(clip=video, css="420") | ||
video = core.fmtc.bitdepth(clip=video, bits=8) | ||
else: | ||
video = core.ffms2.Source(source=f"{input_video}", cache=False) | ||
|
||
if float(conf['misc']['timescale']['in']) != 1: # Input timescale, done before interpolation | ||
video = core.std.AssumeFPS(video, fpsnum=(video.fps * (1 / conf['misc']['timescale']['in']))) | ||
video = core.ffms2.Source(source=input_video, cache=False) | ||
|
||
if str(conf['interpolation']['pre interpolation']['enabled']).lower() in yes: # Pre-interpolating with RIFE | ||
if float(conf['timescale']['in']) != 1: # Input timescale, done before interpolation | ||
video = core.std.AssumeFPS(video, fpsnum=(video.fps * (1 / float(conf['timescale']['in'])))) | ||
|
||
video = core.resize.Bicubic(video, format=vs.RGBS) | ||
if str(conf['interpolation']['pre interpolation']['rife type']).lower() == 'cuda': | ||
from vsrife import RIFE | ||
while video.fps > conf['interpolation']['pre interpolation']['minimum fps']: | ||
video = RIFE(video) | ||
elif str(conf['interpolation']['pre interpolation']['rife type']).lower() == 'ncnn': | ||
video = core.resize.Bicubic(video, format=vs.RGBS) | ||
while video.fps < conf['interpolation']['pre interpolation']['minimum fps']: | ||
video = core.rife.RIFE(video) | ||
video = core.resize.Bicubic(video, format=vs.YUV420P8, matrix_s="709") | ||
# if str(conf['interpolation']['pre interpolation']['enabled']).lower() in yes: # Pre-interpolating with RIFE | ||
# | ||
# video = core.resize.Bicubic(video, format=vs.RGBS) | ||
# if str(conf['interpolation']['pre interpolation']['rife type']).lower() == 'cuda': | ||
# from vsrife import RIFE | ||
# while video.fps > conf['interpolation']['pre interpolation']['minimum fps']: | ||
# video = RIFE(video) | ||
# elif str(conf['interpolation']['pre interpolation']['rife type']).lower() == 'ncnn': | ||
# video = core.resize.Bicubic(video, format=vs.RGBS) | ||
# while video.fps < conf['interpolation']['pre interpolation']['minimum fps']: | ||
# video = core.rife.RIFE(video) | ||
# video = core.resize.Bicubic(video, format=vs.YUV420P8, matrix_s="709") | ||
|
||
if str(conf['interpolation']['enabled']).lower() in yes: # Interpolation using Interframe2 (uses SVP-Flow, which is what blur uses) | ||
|
||
video = havsfunc.InterFrame( | ||
video, | ||
GPU=True, | ||
NewNum=conf['interpolation']['fps'], | ||
Preset=conf['interpolation']['speed'], | ||
Tuning=conf['interpolation']['tuning'], | ||
OverrideAlgo=conf['interpolation']['algorithm'] | ||
NewNum=int(conf['interpolation']['fps']), | ||
Preset=str(conf['interpolation']['speed']), | ||
Tuning=str(conf['interpolation']['tuning']), | ||
OverrideAlgo=int(conf['interpolation']['algorithm']) | ||
) | ||
|
||
if float(conf['misc']['timescale']['out']) != 1: # Output timescale, done after interpolation | ||
video = core.std.AssumeFPS(video, fpsnum=(video.fps * conf['misc']['timescale']['out'])) | ||
if float(conf['timescale']['out']) != 1: # Output timescale, done after interpolation | ||
video = core.std.AssumeFPS(video, fpsnum=(video.fps * float(conf['timescale']['out']))) | ||
|
||
if str(conf['misc']['deduplication']).lower() in yes: | ||
import filldrops | ||
video = filldrops.FillDrops(video, thresh=0.001) | ||
|
||
if str(conf['resampling']['enabled']).lower() in yes: | ||
if str(conf['frame blending']['enabled']).lower() in yes: | ||
import weighting | ||
frame_gap = int(video.fps / conf['resampling']['fps']) | ||
blended_frames = int(frame_gap * conf['resampling']['intensity']) | ||
frame_gap = int(video.fps / int(conf['frame blending']['fps'])) | ||
blended_frames = int(frame_gap * float(conf['frame blending']['intensity'])) | ||
if blended_frames > 0: | ||
if blended_frames % 2 == 0: | ||
blended_frames += 1 | ||
weights = weighting.equal(blended_frames) | ||
video = core.frameblender.FrameBlend(video, weights, True) | ||
video = havsfunc.ChangeFPS(video, conf['resampling']['fps']) | ||
video = havsfunc.ChangeFPS(video, int(conf['frame blending']['fps'])) | ||
|
||
video.set_output() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Will uses SVP-Flow to "guess" frames for a smoother resampling, slowers the higher you go | ||
[interpolation] | ||
enabled=y | ||
# This completly disables interpolation, same thing goes for resampling | ||
fps=960 | ||
speed=medium | ||
tuning=weak | ||
algorithm=23 | ||
|
||
# Blends the frames to make a smoother video with a lower FPS (e.g 60FPS) | ||
[frame blending] | ||
enabled=y | ||
fps=60 | ||
intensity=1.27 | ||
# The higher the frameblending's fps, the higher you can set this to | ||
|
||
[encoding] # How your video will be encoded | ||
process=ffmpeg | ||
args=-c:v hevc_nvenc -preset p7 -rc constqp -qp 18 | ||
|
||
[misc] | ||
folder= | ||
# Set a folder here if you wish to redirect all outputted videos to a specific folder, else leave it empty | ||
deduplication=y | ||
# Finds duplicate frames (e.g if you had encoding lag) and tries patching them with interpolation | ||
container=mp4 | ||
# If you prefer mkv, or would like to use uncompressed avi | ||
verbose=false | ||
flavors=fruits | ||
# If you wish to disable random fruits being added to your video's prefixes, make this empty | ||
|
||
[timescale] | ||
in=1 | ||
out=1 | ||
# If your clips are slowed down / you wish to accelerate your clips before resampling |
This file was deleted.
Oops, something went wrong.
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