Integrated pix_fmt option for MP4/MKV/WEBM/MOV

This commit is contained in:
n00mkrad
2021-07-20 20:52:34 +02:00
parent c656ab3e89
commit 72cd93c589
4 changed files with 49 additions and 35 deletions

View File

@@ -187,7 +187,7 @@
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.resetBtn = new HTAlt.WinForms.HTButton();
this.label75 = new System.Windows.Forms.Label();
this.mp4Colors = new System.Windows.Forms.ComboBox();
this.pixFmt = new System.Windows.Forms.ComboBox();
this.settingsTabList.SuspendLayout();
this.generalTab.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.info1)).BeginInit();
@@ -1615,7 +1615,7 @@
//
// tabListPage1
//
this.tabListPage1.Controls.Add(this.mp4Colors);
this.tabListPage1.Controls.Add(this.pixFmt);
this.tabListPage1.Controls.Add(this.label75);
this.tabListPage1.Controls.Add(this.label13);
this.tabListPage1.Controls.Add(this.vp9Crf);
@@ -1644,7 +1644,7 @@
//
this.label13.AutoSize = true;
this.label13.ForeColor = System.Drawing.Color.Silver;
this.label13.Location = new System.Drawing.Point(393, 131);
this.label13.Location = new System.Drawing.Point(393, 101);
this.label13.Margin = new System.Windows.Forms.Padding(10, 10, 10, 7);
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(225, 13);
@@ -1655,7 +1655,7 @@
//
this.vp9Crf.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.vp9Crf.ForeColor = System.Drawing.Color.White;
this.vp9Crf.Location = new System.Drawing.Point(280, 128);
this.vp9Crf.Location = new System.Drawing.Point(280, 98);
this.vp9Crf.Maximum = new decimal(new int[] {
60,
0,
@@ -1674,7 +1674,7 @@
//
this.mp4Crf.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.mp4Crf.ForeColor = System.Drawing.Color.White;
this.mp4Crf.Location = new System.Drawing.Point(280, 98);
this.mp4Crf.Location = new System.Drawing.Point(280, 68);
this.mp4Crf.Maximum = new decimal(new int[] {
60,
0,
@@ -1807,7 +1807,7 @@
// label57
//
this.label57.AutoSize = true;
this.label57.Location = new System.Drawing.Point(10, 130);
this.label57.Location = new System.Drawing.Point(10, 100);
this.label57.Margin = new System.Windows.Forms.Padding(10, 10, 10, 7);
this.label57.Name = "label57";
this.label57.Size = new System.Drawing.Size(176, 13);
@@ -1857,7 +1857,7 @@
//
this.label14.AutoSize = true;
this.label14.ForeColor = System.Drawing.Color.Silver;
this.label14.Location = new System.Drawing.Point(393, 101);
this.label14.Location = new System.Drawing.Point(393, 71);
this.label14.Margin = new System.Windows.Forms.Padding(10, 10, 10, 7);
this.label14.Name = "label14";
this.label14.Size = new System.Drawing.Size(225, 13);
@@ -1867,7 +1867,7 @@
// label12
//
this.label12.AutoSize = true;
this.label12.Location = new System.Drawing.Point(10, 100);
this.label12.Location = new System.Drawing.Point(10, 70);
this.label12.Margin = new System.Windows.Forms.Padding(10, 10, 10, 7);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(260, 13);
@@ -2198,28 +2198,29 @@
// label75
//
this.label75.AutoSize = true;
this.label75.Location = new System.Drawing.Point(10, 70);
this.label75.Location = new System.Drawing.Point(10, 130);
this.label75.Margin = new System.Windows.Forms.Padding(10, 10, 10, 7);
this.label75.Name = "label75";
this.label75.Size = new System.Drawing.Size(122, 13);
this.label75.Size = new System.Drawing.Size(190, 13);
this.label75.TabIndex = 114;
this.label75.Text = "MP4/MKV: Color Format";
this.label75.Text = "MP4/MKV/WEBM/MOV: Color Format";
//
// mp4Colors
// pixFmt
//
this.mp4Colors.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.mp4Colors.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.mp4Colors.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.mp4Colors.ForeColor = System.Drawing.Color.White;
this.mp4Colors.FormattingEnabled = true;
this.mp4Colors.Items.AddRange(new object[] {
"yuv420p (8-Bit Color, 4:2:0 Sampling)",
this.pixFmt.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.pixFmt.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.pixFmt.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.pixFmt.ForeColor = System.Drawing.Color.White;
this.pixFmt.FormattingEnabled = true;
this.pixFmt.Items.AddRange(new object[] {
"yuv420p (8-Bit Color, 4:2:0 Sampling - Recommended)",
"yuv444p (8-Bit Color, 4:4:4 Sampling - May not work with some encoders!)",
"yuv420p10le (10-Bit Color, 4:2:0 Sampling - May not work with some encoders!)"});
this.mp4Colors.Location = new System.Drawing.Point(280, 67);
this.mp4Colors.Name = "mp4Colors";
this.mp4Colors.Size = new System.Drawing.Size(400, 21);
this.mp4Colors.TabIndex = 115;
"yuv420p10le (10-Bit Color, 4:2:0 Sampling - May not work with some encoders!)",
"yuv444p10le (10-Bit Color, 4:4:4 Sampling - May not work with some encoders!)"});
this.pixFmt.Location = new System.Drawing.Point(280, 127);
this.pixFmt.Name = "pixFmt";
this.pixFmt.Size = new System.Drawing.Size(400, 21);
this.pixFmt.TabIndex = 115;
//
// SettingsForm
//
@@ -2425,7 +2426,7 @@
private System.Windows.Forms.Label label58;
private System.Windows.Forms.Panel autoEncBlockPanel;
private HTAlt.WinForms.HTButton resetBtn;
private System.Windows.Forms.ComboBox mp4Colors;
private System.Windows.Forms.ComboBox pixFmt;
private System.Windows.Forms.Label label75;
}
}

View File

@@ -107,7 +107,7 @@ namespace Flowframes.Forms
ConfigParser.SaveGuiElement(fixOutputDuration);
// Encoding
ConfigParser.SaveComboxIndex(mp4Enc);
ConfigParser.SaveComboxIndex(mp4Colors);
ConfigParser.SaveComboxIndex(pixFmt);
Config.Set(mp4CrfConfigKey, mp4Crf.Value.ToString());
ConfigParser.SaveGuiElement(vp9Crf);
ConfigParser.SaveComboxIndex(proResProfile);
@@ -168,7 +168,7 @@ namespace Flowframes.Forms
ConfigParser.LoadGuiElement(fixOutputDuration);
// Encoding
ConfigParser.LoadComboxIndex(mp4Enc);
ConfigParser.LoadComboxIndex(mp4Colors);
ConfigParser.LoadComboxIndex(pixFmt);
ConfigParser.LoadGuiElement(vp9Crf);
ConfigParser.LoadComboxIndex(proResProfile);
ConfigParser.LoadGuiElement(aviCodec);

View File

@@ -362,6 +362,7 @@ namespace Flowframes.IO
minOutVidLength,
minVidLength,
mp4Enc,
pixFmt,
mpdecimateMode,
ncnnGpus,
ncnnThreads,

View File

@@ -54,49 +54,49 @@ namespace Flowframes.Media
public static string GetEncArgs (Codec codec)
{
string args = $"-c:v { GetEnc(codec)} ";
string args = $"-c:v {GetEnc(codec)} ";
if(codec == Codec.H264)
{
string preset = Config.Get(Config.Key.ffEncPreset).ToLower().Remove(" ");
args += $"-crf {Config.GetInt(Config.Key.h264Crf)} -preset {preset} -pix_fmt yuv420p";
args += $"-crf {Config.GetInt(Config.Key.h264Crf)} -preset {preset} -pix_fmt {GetPixFmt()}";
}
if (codec == Codec.H265)
{
string preset = Config.Get(Config.Key.ffEncPreset).ToLower().Remove(" ");
int crf = Config.GetInt(Config.Key.h265Crf);
args += $"{(crf > 0 ? $"-crf {crf}" : "-x265-params lossless=1")} -preset {preset} -pix_fmt yuv420p";
args += $"{(crf > 0 ? $"-crf {crf}" : "-x265-params lossless=1")} -preset {preset} -pix_fmt {GetPixFmt()}";
}
if (codec == Codec.H264NVENC)
{
int cq = (Config.GetInt(Config.Key.h264Crf) * 1.1f).RoundToInt();
args += $"-b:v 0 {(cq > 0 ? $"-cq {cq} -preset p7" : "-preset lossless")} -pix_fmt yuv420p";
args += $"-b:v 0 {(cq > 0 ? $"-cq {cq} -preset p7" : "-preset lossless")} -pix_fmt {GetPixFmt()}";
}
if (codec == Codec.H265NVENC)
{
int cq = (Config.GetInt(Config.Key.h265Crf) * 1.1f).RoundToInt();
args += $"-b:v 0 {(cq > 0 ? $"-cq {cq} -preset p7" : "-preset lossless")} -pix_fmt yuv420p";
args += $"-b:v 0 {(cq > 0 ? $"-cq {cq} -preset p7" : "-preset lossless")} -pix_fmt {GetPixFmt()}";
}
if (codec == Codec.AV1)
{
int cq = (Config.GetInt(Config.Key.av1Crf) * 1.0f).RoundToInt();
args += $"-b:v 0 -qp {cq} -g 240 {GetSvtAv1Speed()} -tile_rows 2 -tile_columns 2 -pix_fmt yuv420p";
args += $"-b:v 0 -qp {cq} -g 240 {GetSvtAv1Speed()} -tile_rows 2 -tile_columns 2 -pix_fmt {GetPixFmt()}";
}
if (codec == Codec.VP9)
{
int crf = Config.GetInt(Config.Key.vp9Crf);
string qualityStr = (crf > 0) ? $"-b:v 0 -crf {crf}" : "-lossless 1";
args += $"{qualityStr} {GetVp9Speed()} -tile-columns 2 -tile-rows 2 -row-mt 1 -pix_fmt yuv420p";
args += $"{qualityStr} {GetVp9Speed()} -tile-columns 2 -tile-rows 2 -row-mt 1 -pix_fmt {GetPixFmt()}";
}
if(codec == Codec.ProRes)
{
args += $"-profile:v {Config.GetInt(Config.Key.proResProfile)} -pix_fmt yuv420p";
args += $"-profile:v {Config.GetInt(Config.Key.proResProfile)} -pix_fmt {GetPixFmt()}";
}
if (codec == Codec.AviRaw)
@@ -139,6 +139,18 @@ namespace Flowframes.Media
return $"-preset {arg}";
}
static string GetPixFmt ()
{
switch (Config.GetInt(Config.Key.pixFmt))
{
case 0: return "yuv420p";
case 1: return "yuv444p";
case 2: return "yuv420p10le";
}
return "yuv420p";
}
public static bool ContainerSupportsAllAudioFormats (Interpolate.OutMode outMode, List<string> codecs)
{
if(codecs.Count < 1)