mirror of
https://github.com/n00mkrad/flowframes.git
synced 2025-12-24 20:29:26 +01:00
Added custom quality option
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
|
||||
public class Quality
|
||||
{
|
||||
public enum Common { Lossless, VeryHigh, High, Medium, Low, VeryLow }
|
||||
public enum Common { Lossless, VeryHigh, High, Medium, Low, VeryLow, Custom }
|
||||
public enum ProResProfile { Proxy, Lt, Standard, Hq, Quad4, Quad4Xq }
|
||||
public enum GifColors { Max256, High128, Medium64, Low32, VeryLow16 }
|
||||
}
|
||||
|
||||
@@ -12,5 +12,6 @@ namespace Flowframes.Data
|
||||
public Enums.Encoding.Encoder Encoder { get; set; }
|
||||
public Enums.Encoding.PixelFormat PixelFormat { get; set; }
|
||||
public string Quality { get; set; } = "";
|
||||
public string CustomQuality { get; set; } = "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -376,5 +376,15 @@ namespace Flowframes
|
||||
{
|
||||
return OutputUtils.GetEncoderInfoVideo(enc);
|
||||
}
|
||||
|
||||
public static bool IsEmpty (this string s)
|
||||
{
|
||||
return string.IsNullOrWhiteSpace(s);
|
||||
}
|
||||
|
||||
public static bool NotEmpty(this string s)
|
||||
{
|
||||
return !string.IsNullOrWhiteSpace(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
24
Code/Form1.Designer.cs
generated
24
Code/Form1.Designer.cs
generated
@@ -143,6 +143,7 @@
|
||||
this.cancelBtn = new System.Windows.Forms.Button();
|
||||
this.menuStripQueue = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.addCurrentConfigurationToQueueToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.textboxOutputQualityCust = new System.Windows.Forms.TextBox();
|
||||
this.panel1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox4)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).BeginInit();
|
||||
@@ -957,10 +958,11 @@
|
||||
this.flowLayoutPanel1.Controls.Add(this.comboxOutputFormat);
|
||||
this.flowLayoutPanel1.Controls.Add(this.comboxOutputEncoder);
|
||||
this.flowLayoutPanel1.Controls.Add(this.comboxOutputQuality);
|
||||
this.flowLayoutPanel1.Controls.Add(this.textboxOutputQualityCust);
|
||||
this.flowLayoutPanel1.Controls.Add(this.comboxOutputColors);
|
||||
this.flowLayoutPanel1.Location = new System.Drawing.Point(281, 157);
|
||||
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
|
||||
this.flowLayoutPanel1.Size = new System.Drawing.Size(400, 23);
|
||||
this.flowLayoutPanel1.Size = new System.Drawing.Size(508, 23);
|
||||
this.flowLayoutPanel1.TabIndex = 46;
|
||||
//
|
||||
// comboxOutputFormat
|
||||
@@ -1021,6 +1023,7 @@
|
||||
this.comboxOutputQuality.Name = "comboxOutputQuality";
|
||||
this.comboxOutputQuality.Size = new System.Drawing.Size(100, 23);
|
||||
this.comboxOutputQuality.TabIndex = 48;
|
||||
this.comboxOutputQuality.SelectedIndexChanged += new System.EventHandler(this.comboxOutputQuality_SelectedIndexChanged);
|
||||
//
|
||||
// comboxOutputColors
|
||||
//
|
||||
@@ -1029,7 +1032,7 @@
|
||||
this.comboxOutputColors.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.comboxOutputColors.ForeColor = System.Drawing.Color.White;
|
||||
this.comboxOutputColors.FormattingEnabled = true;
|
||||
this.comboxOutputColors.Location = new System.Drawing.Point(283, 0);
|
||||
this.comboxOutputColors.Location = new System.Drawing.Point(319, 0);
|
||||
this.comboxOutputColors.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.comboxOutputColors.Name = "comboxOutputColors";
|
||||
this.comboxOutputColors.Size = new System.Drawing.Size(117, 23);
|
||||
@@ -1713,7 +1716,7 @@
|
||||
this.menuStripQueue.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.addCurrentConfigurationToQueueToolStripMenuItem});
|
||||
this.menuStripQueue.Name = "menuStripQueue";
|
||||
this.menuStripQueue.Size = new System.Drawing.Size(269, 48);
|
||||
this.menuStripQueue.Size = new System.Drawing.Size(269, 26);
|
||||
//
|
||||
// addCurrentConfigurationToQueueToolStripMenuItem
|
||||
//
|
||||
@@ -1722,6 +1725,19 @@
|
||||
this.addCurrentConfigurationToQueueToolStripMenuItem.Text = "Add Current Configuration to Queue";
|
||||
this.addCurrentConfigurationToQueueToolStripMenuItem.Click += new System.EventHandler(this.addCurrentConfigurationToQueueToolStripMenuItem_Click);
|
||||
//
|
||||
// textboxOutputQualityCust
|
||||
//
|
||||
this.textboxOutputQualityCust.AllowDrop = true;
|
||||
this.textboxOutputQualityCust.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
||||
this.textboxOutputQualityCust.ForeColor = System.Drawing.Color.White;
|
||||
this.textboxOutputQualityCust.Location = new System.Drawing.Point(283, 0);
|
||||
this.textboxOutputQualityCust.Margin = new System.Windows.Forms.Padding(0, 0, 6, 0);
|
||||
this.textboxOutputQualityCust.MinimumSize = new System.Drawing.Size(4, 21);
|
||||
this.textboxOutputQualityCust.Name = "textboxOutputQualityCust";
|
||||
this.textboxOutputQualityCust.Size = new System.Drawing.Size(30, 23);
|
||||
this.textboxOutputQualityCust.TabIndex = 52;
|
||||
this.textboxOutputQualityCust.Visible = false;
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AllowDrop = true;
|
||||
@@ -1776,6 +1792,7 @@
|
||||
this.interpOptsTab.ResumeLayout(false);
|
||||
this.interpOptsTab.PerformLayout();
|
||||
this.flowLayoutPanel1.ResumeLayout(false);
|
||||
this.flowLayoutPanel1.PerformLayout();
|
||||
this.completionActionPanel.ResumeLayout(false);
|
||||
this.completionActionPanel.PerformLayout();
|
||||
this.quickSettingsTab.ResumeLayout(false);
|
||||
@@ -1913,6 +1930,7 @@
|
||||
private System.Windows.Forms.Label labelOutput;
|
||||
private System.Windows.Forms.ContextMenuStrip menuStripQueue;
|
||||
private System.Windows.Forms.ToolStripMenuItem addCurrentConfigurationToQueueToolStripMenuItem;
|
||||
private System.Windows.Forms.TextBox textboxOutputQualityCust;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,6 @@ namespace Flowframes
|
||||
// Main Tab
|
||||
UiUtils.InitCombox(interpFactorCombox, 0);
|
||||
UiUtils.InitCombox(outSpeedCombox, 0);
|
||||
//UiUtils.InitCombox(outModeCombox, 0);
|
||||
InitOutputUi();
|
||||
UiUtils.InitCombox(aiModel, 2);
|
||||
// Video Utils
|
||||
@@ -64,9 +63,10 @@ namespace Flowframes
|
||||
Program.mainForm = this;
|
||||
Logger.textbox = logBox;
|
||||
NvApi.Init();
|
||||
InitAis();
|
||||
InterpolationProgress.preview = previewPicturebox;
|
||||
RemovePreviewIfDisabled();
|
||||
await Checks();
|
||||
InitAis();
|
||||
UpdateStepByStepControls();
|
||||
Initialized();
|
||||
HandleArgs();
|
||||
@@ -78,11 +78,9 @@ namespace Flowframes
|
||||
if (Debugger.IsAttached)
|
||||
{
|
||||
Logger.Log("Debugger is attached - Flowframes seems to be running within VS.");
|
||||
// ...
|
||||
}
|
||||
|
||||
completionAction.SelectedIndex = 0;
|
||||
await Checks();
|
||||
}
|
||||
|
||||
private void InitOutputUi()
|
||||
@@ -96,7 +94,6 @@ namespace Flowframes
|
||||
var outMode = ParseUtils.GetEnum<Enums.Output.Format>(comboxOutputFormat.Text, true, Strings.OutputFormat);
|
||||
comboxOutputEncoder.FillFromEnum(OutputUtils.GetAvailableEncoders(outMode), Strings.Encoder, 0);
|
||||
comboxOutputEncoder.Visible = comboxOutputEncoder.Items.Count > 0;
|
||||
|
||||
UpdateOutputEncodingUi();
|
||||
}
|
||||
|
||||
@@ -425,7 +422,8 @@ namespace Flowframes
|
||||
|
||||
public OutputSettings GetOutputSettings ()
|
||||
{
|
||||
return new OutputSettings() { Encoder = GetEncoder, Format = GetOutputFormat, PixelFormat = GetPixelFormat(), Quality = comboxOutputQuality.Text };
|
||||
string custQ = textboxOutputQualityCust.Visible ? textboxOutputQualityCust.Text.Trim() : "";
|
||||
return new OutputSettings() { Encoder = GetEncoder, Format = GetOutputFormat, PixelFormat = GetPixelFormat(), Quality = comboxOutputQuality.Text, CustomQuality = custQ };
|
||||
}
|
||||
|
||||
public void SetFormat(Enums.Output.Format format)
|
||||
@@ -821,5 +819,19 @@ namespace Flowframes
|
||||
Program.batchQueue.Enqueue(Program.mainForm.GetCurrentSettings());
|
||||
Application.OpenForms.Cast<Form>().Where(f => f is BatchForm).Select(f => (BatchForm)f).ToList().ForEach(f => f.RefreshGui());
|
||||
}
|
||||
|
||||
private void comboxOutputQuality_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
var qualityPreset = ParseUtils.GetEnum<Enums.Encoding.Quality.Common>(comboxOutputQuality.Text, true, Strings.VideoQuality);
|
||||
bool cust = qualityPreset == Enums.Encoding.Quality.Common.Custom;
|
||||
textboxOutputQualityCust.Visible = cust;
|
||||
comboxOutputQuality.Margin = new System.Windows.Forms.Padding(0, 0, cust ? 0 : 6, 0);
|
||||
comboxOutputQuality.Width = cust ? 70 : 100;
|
||||
|
||||
if (!cust)
|
||||
textboxOutputQualityCust.Text = "";
|
||||
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Win32Interop.Enums;
|
||||
using static Flowframes.Data.Enums.Encoding;
|
||||
using static Flowframes.Media.GetVideoInfo;
|
||||
using Stream = Flowframes.Data.Streams.Stream;
|
||||
@@ -196,26 +197,26 @@ namespace Flowframes.Media
|
||||
if (enc == Encoder.X264)
|
||||
{
|
||||
string preset = Config.Get(Config.Key.ffEncPreset).ToLowerInvariant().Remove(" "); // TODO: Replace this ugly stuff with enums
|
||||
int crf = OutputUtils.GetCrf(ParseUtils.GetEnum<Quality.Common>(settings.Quality, true, Strings.VideoQuality), enc);
|
||||
int crf = GetCrf(settings);
|
||||
args.Add($"-crf {crf} -preset {preset}");
|
||||
}
|
||||
|
||||
if (enc == Encoder.X265)
|
||||
{
|
||||
string preset = Config.Get(Config.Key.ffEncPreset).ToLowerInvariant().Remove(" "); // TODO: Replace this ugly stuff with enums
|
||||
int crf = OutputUtils.GetCrf(ParseUtils.GetEnum<Quality.Common>(settings.Quality, true, Strings.VideoQuality), enc);
|
||||
int crf = GetCrf(settings);
|
||||
args.Add($"{(crf > 0 ? $"-crf {crf}" : "-x265-params lossless=1")} -preset {preset}");
|
||||
}
|
||||
|
||||
if (enc == Encoder.SvtAv1)
|
||||
{
|
||||
int crf = OutputUtils.GetCrf(ParseUtils.GetEnum<Quality.Common>(settings.Quality, true, Strings.VideoQuality), enc);
|
||||
int crf = GetCrf(settings);
|
||||
args.Add($"-crf {crf} {GetSvtAv1Speed()} -svtav1-params enable-qm=1:enable-overlays=1:enable-tf=0:scd=0");
|
||||
}
|
||||
|
||||
if (enc == Encoder.VpxVp9)
|
||||
{
|
||||
int crf = OutputUtils.GetCrf(ParseUtils.GetEnum<Quality.Common>(settings.Quality, true, Strings.VideoQuality), enc);
|
||||
int crf = GetCrf(settings);
|
||||
string qualityStr = (crf > 0) ? $"-crf {crf}" : "-lossless 1";
|
||||
string t = GetTilingArgs(res, "-tile-columns ", "-tile-rows ");
|
||||
|
||||
@@ -234,19 +235,19 @@ namespace Flowframes.Media
|
||||
|
||||
if (enc == Encoder.Nvenc264)
|
||||
{
|
||||
int crf = OutputUtils.GetCrf(ParseUtils.GetEnum<Quality.Common>(settings.Quality, true, Strings.VideoQuality), enc);
|
||||
int crf = GetCrf(settings);
|
||||
args.Add($"-b:v 0 {(crf > 0 ? $"-cq {crf} -preset p7" : "-preset lossless")}");
|
||||
}
|
||||
|
||||
if (enc == Encoder.Nvenc265)
|
||||
{
|
||||
int crf = OutputUtils.GetCrf(ParseUtils.GetEnum<Quality.Common>(settings.Quality, true, Strings.VideoQuality), enc);
|
||||
int crf = GetCrf(settings);
|
||||
args.Add($"-b:v 0 {(crf > 0 ? $"-cq {crf} -preset p7" : "-preset lossless")}");
|
||||
}
|
||||
|
||||
if (enc == Encoder.NvencAv1)
|
||||
{
|
||||
int crf = OutputUtils.GetCrf(ParseUtils.GetEnum<Quality.Common>(settings.Quality, true, Strings.VideoQuality), enc);
|
||||
int crf = GetCrf(settings);
|
||||
args.Add($"-b:v 0 -preset p7 {(crf > 0 ? $"-cq {crf}" : "-tune lossless")}"); // Lossless not supported as of Jan 2023!!
|
||||
}
|
||||
|
||||
@@ -263,6 +264,14 @@ namespace Flowframes.Media
|
||||
return new string[] { string.Join(" ", args) };
|
||||
}
|
||||
|
||||
private static int GetCrf(OutputSettings settings)
|
||||
{
|
||||
if (settings.CustomQuality.NotEmpty())
|
||||
return settings.CustomQuality.GetInt();
|
||||
else
|
||||
return OutputUtils.GetCrf(ParseUtils.GetEnum<Quality.Common>(settings.Quality, true, Strings.VideoQuality), settings.Encoder);
|
||||
}
|
||||
|
||||
public static string GetTilingArgs(Size resolution, string colArg, string rowArg)
|
||||
{
|
||||
int cols = 0;
|
||||
|
||||
Reference in New Issue
Block a user