mirror of
https://github.com/n00mkrad/flowframes.git
synced 2025-12-16 16:37:48 +01:00
Unify mpdecimate variables, also show settings tooltips on click (not just hover)
This commit is contained in:
@@ -29,5 +29,10 @@
|
||||
public enum ExrPrecision { Float, Half }
|
||||
}
|
||||
}
|
||||
|
||||
public class Interpolation
|
||||
{
|
||||
public enum MpDecimateSens { Normal, High, VeryHigh, Extreme }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ using System.Drawing;
|
||||
using Flowframes.MiscUtils;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using Newtonsoft.Json;
|
||||
using Flowframes.Ui;
|
||||
|
||||
namespace Flowframes
|
||||
{
|
||||
@@ -299,7 +300,7 @@ namespace Flowframes
|
||||
if (key == null)
|
||||
key = "";
|
||||
|
||||
for (int i = 0; i < dict.Count; i++)
|
||||
for (int i = 0; i < (dict == null ? 0 : dict.Count); i++)
|
||||
{
|
||||
if (ignoreCase)
|
||||
{
|
||||
@@ -319,13 +320,13 @@ namespace Flowframes
|
||||
return "";
|
||||
}
|
||||
|
||||
public static void FillFromEnum<TEnum>(this ComboBox comboBox, Dictionary<string, string> stringMap = null, int defaultIndex = -1, List<TEnum> exclusionList = null) where TEnum : Enum
|
||||
public static void FillFromEnum<TEnum>(this ComboBox comboBox, Dictionary<string, string> stringMap = null, int defaultIndex = -1, List<TEnum> exclusionList = null, bool useKeyNames = false) where TEnum : Enum
|
||||
{
|
||||
if (exclusionList == null)
|
||||
exclusionList = new List<TEnum>();
|
||||
|
||||
var entriesToAdd = Enum.GetValues(typeof(TEnum)).Cast<TEnum>().Except(exclusionList);
|
||||
var strings = entriesToAdd.Select(x => stringMap.Get(x.ToString(), true));
|
||||
var strings = useKeyNames ? entriesToAdd.Select(x => UiUtils.PascalCaseToText($"{x}")) : entriesToAdd.Select(x => stringMap.Get($"{x}", true));
|
||||
comboBox.FillFromStrings(strings, stringMap, defaultIndex);
|
||||
}
|
||||
|
||||
|
||||
5
CodeLegacy/Forms/Main/Form1.Designer.cs
generated
5
CodeLegacy/Forms/Main/Form1.Designer.cs
generated
@@ -1265,11 +1265,6 @@
|
||||
this.mpdecimateMode.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.mpdecimateMode.ForeColor = System.Drawing.Color.White;
|
||||
this.mpdecimateMode.FormattingEnabled = true;
|
||||
this.mpdecimateMode.Items.AddRange(new object[] {
|
||||
"Normal",
|
||||
"High",
|
||||
"Very High",
|
||||
"Extreme"});
|
||||
this.mpdecimateMode.Location = new System.Drawing.Point(0, 0);
|
||||
this.mpdecimateMode.Margin = new System.Windows.Forms.Padding(3, 3, 8, 3);
|
||||
this.mpdecimateMode.Name = "mpdecimateMode";
|
||||
|
||||
@@ -79,6 +79,8 @@ namespace Flowframes.Forms.Main
|
||||
UiUtils.InitCombox(outSpeedCombox, 0);
|
||||
// Video Utils
|
||||
UiUtils.InitCombox(trimCombox, 0);
|
||||
// Quick Settings
|
||||
mpdecimateMode.FillFromEnum<Enums.Interpolation.MpDecimateSens>(useKeyNames: true);
|
||||
|
||||
Program.mainForm = this;
|
||||
Logger.textbox = logBox;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Flowframes.Data;
|
||||
using Flowframes.IO;
|
||||
using Flowframes.Media;
|
||||
using Flowframes.MiscUtils;
|
||||
using Flowframes.Os;
|
||||
using Flowframes.Ui;
|
||||
@@ -30,15 +29,17 @@ namespace Flowframes.Forms
|
||||
{
|
||||
MinimumSize = new Size(Width, Height);
|
||||
MaximumSize = new Size(Width, (Height * 1.5f).RoundToInt());
|
||||
mpdecimateMode.FillFromEnum<Enums.Interpolation.MpDecimateSens>(useKeyNames: true);
|
||||
|
||||
InitGpus();
|
||||
InitServers();
|
||||
LoadSettings();
|
||||
AddTooltipClickFunction();
|
||||
initialized = true;
|
||||
Task.Run(() => CheckModelCacheSize());
|
||||
}
|
||||
|
||||
private void InitGpus ()
|
||||
private void InitGpus()
|
||||
{
|
||||
string tooltipTorch = "";
|
||||
string tooltipNcnn = "";
|
||||
@@ -49,7 +50,7 @@ namespace Flowframes.Forms
|
||||
tooltipTorch += $"{i} = {NvApi.NvGpus[i].FullName} ({NvApi.NvGpus[i].GetVramGb().ToString("0.")} GB)\n";
|
||||
}
|
||||
|
||||
foreach(var vkGpu in VulkanUtils.VkDevices)
|
||||
foreach (var vkGpu in VulkanUtils.VkDevices)
|
||||
{
|
||||
ncnnGpus.Items.Add(vkGpu.Id);
|
||||
tooltipNcnn += $"{vkGpu.Id} = {vkGpu.Name}\n";
|
||||
@@ -70,7 +71,7 @@ namespace Flowframes.Forms
|
||||
serverCombox.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
public async Task CheckModelCacheSize ()
|
||||
public async Task CheckModelCacheSize()
|
||||
{
|
||||
await Task.Delay(200);
|
||||
|
||||
@@ -97,7 +98,7 @@ namespace Flowframes.Forms
|
||||
Program.mainForm.LoadQuickSettings();
|
||||
}
|
||||
|
||||
void SaveSettings ()
|
||||
void SaveSettings()
|
||||
{
|
||||
// Remove spaces...
|
||||
torchGpus.Text = torchGpus.Text.Replace(" ", "");
|
||||
@@ -183,7 +184,7 @@ namespace Flowframes.Forms
|
||||
ConfigParser.LoadGuiElement(dainNcnnTilesize);
|
||||
// Export
|
||||
ConfigParser.LoadGuiElement(minOutVidLength);
|
||||
ConfigParser.LoadGuiElement(maxFps);
|
||||
ConfigParser.LoadGuiElement(maxFps);
|
||||
ConfigParser.LoadComboxIndex(loopMode);
|
||||
ConfigParser.LoadGuiElement(fixOutputDuration);
|
||||
// Debugging
|
||||
@@ -193,7 +194,7 @@ namespace Flowframes.Forms
|
||||
ConfigParser.LoadGuiElement(ffEncArgs);
|
||||
}
|
||||
|
||||
private void SetVisibility ()
|
||||
private void SetVisibility()
|
||||
{
|
||||
// Dev options
|
||||
List<Control> devOptions = new List<Control> { panKeepTempFolder, };
|
||||
@@ -215,6 +216,39 @@ namespace Flowframes.Forms
|
||||
panRifeCudaHalfPrec.SetVisible(NvApi.NvGpus.Count > 0 && availAis.Contains(Implementations.rifeCuda));
|
||||
}
|
||||
|
||||
private static List<Control> GetAllControls(Control parent)
|
||||
{
|
||||
var controls = new List<Control>();
|
||||
|
||||
foreach (Control ctrl in parent.Controls)
|
||||
{
|
||||
controls.Add(ctrl);
|
||||
|
||||
if (ctrl.HasChildren)
|
||||
{
|
||||
controls.AddRange(GetAllControls(ctrl));
|
||||
}
|
||||
}
|
||||
|
||||
return controls;
|
||||
}
|
||||
|
||||
private void AddTooltipClickFunction()
|
||||
{
|
||||
foreach (Control control in GetAllControls(this))
|
||||
{
|
||||
if(!(control is PictureBox))
|
||||
continue;
|
||||
|
||||
string tooltipText = toolTip1.GetToolTip(control);
|
||||
|
||||
if (tooltipText.IsEmpty())
|
||||
continue;
|
||||
|
||||
control.Click += (sender, e) => { MessageBox.Show(tooltipText, "Tooltip", MessageBoxButtons.OK, MessageBoxIcon.Information); };
|
||||
}
|
||||
}
|
||||
|
||||
private void tempFolderLoc_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
tempDirBrowseBtn.Visible = tempFolderLoc.SelectedIndex == 4;
|
||||
@@ -230,7 +264,7 @@ namespace Flowframes.Forms
|
||||
private void tempDirBrowseBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
CommonOpenFileDialog dialog = new CommonOpenFileDialog { InitialDirectory = tempDirCustom.Text.Trim(), IsFolderPicker = true };
|
||||
|
||||
|
||||
if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
|
||||
tempDirCustom.Text = dialog.FileName;
|
||||
|
||||
|
||||
@@ -269,7 +269,7 @@ namespace Flowframes.Magick
|
||||
|
||||
Process ffmpeg = OsUtils.NewProcess(true);
|
||||
string baseCmd = $"/C cd /D {Path.Combine(IO.Paths.GetPkgPath(), IO.Paths.audioVideoDir).Wrap()}";
|
||||
string mpDec = FfmpegCommands.GetMpdecimate((int)FfmpegCommands.MpDecSensitivity.Normal, false);
|
||||
string mpDec = FfmpegCommands.GetMpdecimate(wrap: false); // FfmpegCommands.GetMpdecimate((int)FfmpegCommands.MpDecSensitivity.Normal, false);
|
||||
ffmpeg.StartInfo.Arguments = $"{baseCmd} & ffmpeg -loglevel debug -y -i {videoPath.Wrap()} -fps_mode vfr -vf {mpDec} -f null NUL 2>&1 | findstr keep_count:";
|
||||
List<string> ffmpegOutputLines = (await Task.Run(() => OsUtils.GetProcStdOut(ffmpeg, true))).SplitIntoLines().Where(l => l.IsNotEmpty()).ToList();
|
||||
|
||||
|
||||
@@ -16,19 +16,19 @@ namespace Flowframes
|
||||
public static string hdrFilter = @"-vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,format=yuv420p";
|
||||
public static string pngCompr = "-compression_level 3";
|
||||
|
||||
public enum MpDecSensitivity { Normal = 4, High = 20, VeryHigh = 32, Extreme = 40 }
|
||||
|
||||
public static string GetMpdecimate(int sensitivity = 4, bool wrap = true)
|
||||
public static Dictionary<Enums.Interpolation.MpDecimateSens, int> MpDecSensLookup = new Dictionary<Enums.Interpolation.MpDecimateSens, int>
|
||||
{
|
||||
string mpd = $"mpdecimate=hi=64*1024:lo=64*{sensitivity}:frac=1.0";
|
||||
return wrap ? mpd.Wrap() : mpd;
|
||||
}
|
||||
{ Enums.Interpolation.MpDecimateSens.Normal, 4 },
|
||||
{ Enums.Interpolation.MpDecimateSens.High, 20 },
|
||||
{ Enums.Interpolation.MpDecimateSens.VeryHigh, 32 },
|
||||
{ Enums.Interpolation.MpDecimateSens.Extreme, 40 }
|
||||
};
|
||||
|
||||
public static string GetMpdecimate(bool wrap = true)
|
||||
{
|
||||
int mpdValIndex = Config.GetInt(Config.Key.mpdecimateMode);
|
||||
var mpdVal = ((MpDecSensitivity[])Enum.GetValues(typeof(MpDecSensitivity)))[mpdValIndex];
|
||||
string mpd = $"mpdecimate=hi=64*1024:lo=64*{(int)mpdVal}:frac=1.0";
|
||||
int mpdVal = MpDecSensLookup[(Enums.Interpolation.MpDecimateSens)mpdValIndex];
|
||||
string mpd = $"mpdecimate=hi=64*1024:lo=64*{mpdVal}:frac=1.0";
|
||||
return wrap ? mpd.Wrap() : mpd;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using Flowframes.IO;
|
||||
using Flowframes.Main;
|
||||
using Flowframes.Os;
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Flowframes.Ui
|
||||
@@ -148,5 +149,14 @@ namespace Flowframes.Ui
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Move to NmkdUtils once implemented
|
||||
public static string PascalCaseToText(string s)
|
||||
{
|
||||
if (s.IsEmpty())
|
||||
return "";
|
||||
|
||||
return Regex.Replace(s, "([A-Z])", " $1").Trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user