mirror of
https://github.com/n00mkrad/flowframes.git
synced 2025-12-16 16:37:48 +01:00
Trimming input now works with RIFE-NCNN-VS
This commit is contained in:
@@ -84,7 +84,7 @@ namespace Flowframes.MiscUtils
|
||||
}
|
||||
}
|
||||
|
||||
public static long TimestampToMs(string timestamp, bool hasMilliseconds = true)
|
||||
public static long TimestampToMs(string timestamp)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -94,7 +94,7 @@ namespace Flowframes.MiscUtils
|
||||
int seconds = int.Parse(values[2].Split('.')[0]);
|
||||
long ms = 0;
|
||||
|
||||
if (hasMilliseconds)
|
||||
if (timestamp.Contains("."))
|
||||
{
|
||||
int milliseconds = int.Parse(values[2].Split('.')[1].Substring(0, 2)) * 10;
|
||||
ms = hours * 3600000 + minutes * 60000 + seconds * 1000 + milliseconds;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using Flowframes.Data;
|
||||
using Flowframes.IO;
|
||||
using Flowframes.MiscUtils;
|
||||
using Flowframes.Ui;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
@@ -36,9 +38,17 @@ namespace Flowframes.Os
|
||||
string mdlPath = Path.Combine(Paths.GetPkgPath(), Implementations.rifeNcnnVs.PkgDir, s.ModelDir).Replace(@"\", "/").Wrap();
|
||||
|
||||
bool sc = s.SceneDetectSensitivity >= 0.01f;
|
||||
long frameCount = (long)Interpolate.currentInputFrameCount;
|
||||
|
||||
bool trim = QuickSettingsTab.trimEnabled;
|
||||
long srcTrimStartFrame = trim ? (long)(Math.Round(FormatUtils.TimestampToMs(QuickSettingsTab.trimStart) / 1000f * s.InterpSettings.inFps.GetFloat())) : 0;
|
||||
long srcTrimEndFrame = trim && QuickSettingsTab.doTrimEnd ? (long)(Math.Round(FormatUtils.TimestampToMs(QuickSettingsTab.trimEnd) / 1000f * s.InterpSettings.inFps.GetFloat())) - 1 : frameCount - 1;
|
||||
|
||||
if(trim)
|
||||
frameCount = srcTrimEndFrame - srcTrimStartFrame;
|
||||
|
||||
int endDupeCount = s.Factor.RoundToInt() - 1;
|
||||
int targetFrameCountMatchDuration = (Interpolate.currentInputFrameCount * s.Factor).RoundToInt(); // Target frame count to match original duration (and for loops)
|
||||
int targetFrameCountMatchDuration = (frameCount * s.Factor).RoundToInt(); // Target frame count to match original duration (and for loops)
|
||||
int targetFrameCountTrue = targetFrameCountMatchDuration - endDupeCount; // Target frame count without dupes at the end (only in-between frames added)
|
||||
|
||||
List<string> l = new List<string> { "import sys", "import os", "import json", "import time", "import functools", "import vapoursynth as vs", "core = vs.core", "" }; // Imports
|
||||
@@ -59,6 +69,9 @@ namespace Flowframes.Os
|
||||
l.Add($"clip = core.lsmas.LWLibavSource(inputPath, cachefile=indexFilePath)"); // Load video with lsmash
|
||||
}
|
||||
|
||||
if (trim)
|
||||
l.Add($"clip = clip.std.Trim({srcTrimStartFrame}, {srcTrimEndFrame})");
|
||||
|
||||
l.Add($"");
|
||||
|
||||
if (s.Loop && !s.InterpSettings.inputIsFrames)
|
||||
|
||||
@@ -33,10 +33,10 @@ namespace Flowframes.Ui
|
||||
if (trimEndSecs <= trimStartSecs)
|
||||
trimEndBox.Text = FormatUtils.SecsToTimestamp(trimStartSecs + 1);
|
||||
|
||||
long dur = FormatUtils.TimestampToMs(trimEnd, false) - FormatUtils.TimestampToMs(trimStart, false);
|
||||
long dur = FormatUtils.TimestampToMs(trimEnd) - FormatUtils.TimestampToMs(trimStart);
|
||||
Program.mainForm.currInDurationCut = dur;
|
||||
|
||||
doTrimEnd = FormatUtils.TimestampToMs(trimEnd, false) != FormatUtils.TimestampToMs(FormatUtils.MsToTimestamp(Program.mainForm.currInDuration), false);
|
||||
doTrimEnd = FormatUtils.TimestampToMs(trimEnd) != FormatUtils.TimestampToMs(FormatUtils.MsToTimestamp(Program.mainForm.currInDuration));
|
||||
}
|
||||
|
||||
public static string GetTrimEndMinusOne ()
|
||||
|
||||
Reference in New Issue
Block a user