Basic realtime GUI implementation

This commit is contained in:
n00mkrad
2022-08-16 09:18:53 +02:00
parent 61f402b48b
commit 55814846e5
5 changed files with 42 additions and 44 deletions

21
Code/Form1.Designer.cs generated
View File

@@ -96,7 +96,6 @@
this.completionAction = new System.Windows.Forms.ComboBox();
this.label25 = new System.Windows.Forms.Label();
this.encodingSettingsBtn = new HTAlt.WinForms.HTButton();
this.realtimeBtn = new HTAlt.WinForms.HTButton();
this.inputInfo = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.browseOutBtn = new HTAlt.WinForms.HTButton();
@@ -227,7 +226,8 @@
"MOV Video (Apple ProRes)",
"AVI Video (ffv1, huffyuv, magicyuv, rawvideo)",
"Animated GIF (Only supports up to 50 FPS)",
"Image Sequence (PNG, JPG, WEBP)"});
"Image Sequence (PNG, JPG, WEBP)",
"Real-time Interpolation (Video only)"});
this.outModeCombox.Location = new System.Drawing.Point(281, 157);
this.outModeCombox.Name = "outModeCombox";
this.outModeCombox.Size = new System.Drawing.Size(400, 23);
@@ -920,7 +920,6 @@
this.interpOptsTab.Controls.Add(this.outSpeedCombox);
this.interpOptsTab.Controls.Add(this.completionActionPanel);
this.interpOptsTab.Controls.Add(this.encodingSettingsBtn);
this.interpOptsTab.Controls.Add(this.realtimeBtn);
this.interpOptsTab.Controls.Add(this.inputInfo);
this.interpOptsTab.Controls.Add(this.label1);
this.interpOptsTab.Controls.Add(this.browseOutBtn);
@@ -1042,21 +1041,6 @@
this.encodingSettingsBtn.UseVisualStyleBackColor = false;
this.encodingSettingsBtn.Click += new System.EventHandler(this.encodingSettingsBtn_Click);
//
// realtimeBtn
//
this.realtimeBtn.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.realtimeBtn.FlatAppearance.BorderSize = 0;
this.realtimeBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.realtimeBtn.ForeColor = System.Drawing.Color.White;
this.realtimeBtn.Location = new System.Drawing.Point(689, 185);
this.realtimeBtn.Name = "realtimeBtn";
this.realtimeBtn.Size = new System.Drawing.Size(206, 23);
this.realtimeBtn.TabIndex = 38;
this.realtimeBtn.Text = "Realtime Interpolation";
this.realtimeBtn.UseVisualStyleBackColor = false;
this.realtimeBtn.Visible = false;
this.realtimeBtn.Click += new System.EventHandler(this.scnDetectTestBtn_Click);
//
// inputInfo
//
this.inputInfo.AutoSize = true;
@@ -1824,7 +1808,6 @@
private System.Windows.Forms.Panel mpDedupePanel;
private System.Windows.Forms.ComboBox mpdecimateMode;
private System.Windows.Forms.LinkLabel linkLabel1;
private HTAlt.WinForms.HTButton realtimeBtn;
private System.Windows.Forms.Panel busyControlsPanel;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.Button pauseBtn;

View File

@@ -74,7 +74,7 @@ namespace Flowframes
if (Debugger.IsAttached)
{
Logger.Log("Debugger is attached - Flowframes seems to be running within VS.");
realtimeBtn.Visible = true;
// ...
}
completionAction.SelectedIndex = 0;
@@ -319,18 +319,32 @@ namespace Flowframes
outputTbox.Text = dialog.FileName;
}
public void runBtn_Click(object sender, EventArgs e)
public async void runBtn_Click(object sender, EventArgs e)
{
if (Interpolate.currentMediaFile == null || !Interpolate.currentMediaFile.Initialized)
return;
ValidateFactor();
if (!BatchProcessing.busy) // Don't load values from gui if batch processing is used
if (!BatchProcessing.busy) // Don't load values from GUI if batch processing is used
Interpolate.currentSettings = GetCurrentSettings();
AiProcessSuspend.Reset();
Interpolate.Start();
if(Interpolate.currentSettings.outMode == Interpolate.OutMode.Realtime)
{
await Interpolate.Realtime();
SetProgress(0);
}
else
{
await Interpolate.Start();
}
}
private async void RealtimeInterp(object sender, EventArgs e)
{
}
public ModelCollection.ModelInfo GetModel(AI currentAi)
@@ -354,6 +368,7 @@ namespace Flowframes
if (outModeCombox.Text.ToLower().Contains("avi")) outMode = Interpolate.OutMode.VidAvi;
if (outModeCombox.Text.ToLower().Contains("gif")) outMode = Interpolate.OutMode.VidGif;
if (outModeCombox.Text.ToLower().Contains("image")) outMode = Interpolate.OutMode.ImgPng;
if (outModeCombox.Text.ToLower().Contains("real")) outMode = Interpolate.OutMode.Realtime;
return outMode;
}
@@ -370,6 +385,7 @@ namespace Flowframes
if (mode == Interpolate.OutMode.VidAvi && currentItem.Contains("avi")) targetIndex = i;
if (mode == Interpolate.OutMode.VidGif && currentItem.Contains("gif")) targetIndex = i;
if (mode == Interpolate.OutMode.ImgPng && currentItem.Contains("image")) targetIndex = i;
if (mode == Interpolate.OutMode.Realtime && currentItem.Contains("real")) targetIndex = i;
}
outModeCombox.SelectedIndex = targetIndex;
@@ -714,17 +730,6 @@ namespace Flowframes
#endregion
private async void scnDetectTestBtn_Click(object sender, EventArgs e)
{
if (BatchProcessing.busy || !File.Exists(inputTbox.Text.Trim())) return;
Interpolate.currentSettings = GetCurrentSettings();
AiProcessSuspend.Reset();
await Interpolate.Realtime();
SetProgress(0);
}
private void pauseBtn_Click(object sender, EventArgs e)
{
AiProcessSuspend.SuspendResumeAi(!AiProcessSuspend.aiProcFrozen);

View File

@@ -299,7 +299,6 @@ namespace Flowframes.IO
public enum Key
{
aacBitrate,
askedForDevModeVersion,
aiCombox,
allowConsecutiveSceneChanges,
allowCustomInputRate,
@@ -307,11 +306,13 @@ namespace Flowframes.IO
allowSymlinkEncoding,
allowSymlinkImport,
alwaysWaitForAutoEnc,
askedForDevModeVersion,
autoEncBackupMode,
autoEncDebug,
autoEncMode,
autoEncSafeBufferCuda,
autoEncSafeBufferNcnn,
av1Crf,
aviCodec,
aviColors,
clearLogOnInput,
@@ -337,7 +338,6 @@ namespace Flowframes.IO
gifDitherType,
h264Crf,
h265Crf,
av1Crf,
imgSeqFormat,
imgSeqQuality,
imgSeqSampleCount,
@@ -349,8 +349,8 @@ namespace Flowframes.IO
keepMeta,
keepSubs,
keepTempFolder,
loopMode,
lastUsedAiName,
loopMode,
lowDiskSpaceCancelGb,
lowDiskSpacePauseGb,
maxFps,
@@ -359,13 +359,13 @@ namespace Flowframes.IO
minOutVidLength,
minVidLength,
mp4Enc,
pixFmt,
mpdecimateMode,
ncnnGpus,
ncnnThreads,
opusBitrate,
processingMode,
pixFmt,
proResProfile,
processingMode,
rifeCudaBufferSize,
rifeCudaFp16,
rifeNcnnUseTta,
@@ -379,8 +379,9 @@ namespace Flowframes.IO
tempFolderLoc,
torchGpus,
uhdThresh,
vsUseLsmash,
vp9Crf
vp9Crf,
vsRtShowOsd,
vsUseLsmash
}
}
}

View File

@@ -22,7 +22,7 @@ namespace Flowframes
{
public class Interpolate
{
public enum OutMode { VidMp4, VidMkv, VidWebm, VidProRes, VidAvi, VidGif, ImgPng }
public enum OutMode { VidMp4, VidMkv, VidWebm, VidProRes, VidAvi, VidGif, ImgPng, Realtime }
public static bool currentlyUsingAutoEnc;
public static InterpSettings currentSettings;
@@ -89,7 +89,13 @@ namespace Flowframes
public static async Task Realtime ()
{
Program.mainForm.SetWorking(true);
if(currentSettings.ai.NameInternal != Implementations.rifeNcnnVs.NameInternal)
Cancel($"Real-time interpolation is only available when using {Implementations.rifeNcnnVs.FriendlyName}.");
await AiProcess.RunRifeNcnnVs(currentSettings.framesFolder, "", currentSettings.interpFactor, currentSettings.model.Dir, true);
Program.mainForm.SetWorking(false);
}
public static async Task GetFrames()

View File

@@ -339,6 +339,8 @@ namespace Flowframes.Os
public static async Task RunRifeNcnnVs(string framesPath, string outPath, float factor, string mdl, bool rt = false)
{
if(Interpolate.canceled) return;
AI ai = Implementations.rifeNcnnVs;
processTimeMulti.Restart();
@@ -385,7 +387,8 @@ namespace Flowframes.Os
Loop = Config.GetBool(Config.Key.enableLoop),
MatchDuration = Config.GetBool(Config.Key.fixOutputDuration),
Dedupe = Config.GetInt(Config.Key.dedupMode) != 0,
Realtime = rt
Realtime = rt,
Osd = Config.GetBool(Config.Key.vsRtShowOsd),
};
if (rt)
@@ -675,7 +678,7 @@ namespace Flowframes.Os
if (ai.Piped) // VS specific
{
if (!hasShownError && line.ToLower().Contains("fwrite() call failed"))
if (!hasShownError && Interpolate.currentSettings.outMode != Interpolate.OutMode.Realtime && line.ToLower().Contains("fwrite() call failed"))
{
hasShownError = true;
UiUtils.ShowMessageBox($"VapourSynth interpolation failed with an unknown error. Check the log for details:\n\n{lastLogLines}", UiUtils.MessageType.Error);