Slowmo options, UI improvements

This commit is contained in:
N00MKRAD
2021-08-28 10:21:52 +02:00
parent 58cf1f5888
commit c835a199a5
6 changed files with 70 additions and 53 deletions

View File

@@ -46,6 +46,7 @@ namespace Flowframes.Data
Numerator = (value * 10000f).RoundToInt(); Numerator = (value * 10000f).RoundToInt();
Denominator = 10000; Denominator = 10000;
this = GetReduced(); this = GetReduced();
Logger.Log($"Converted float {value} to Fraction {this}", true);
} }
public Fraction(string text) public Fraction(string text)

View File

@@ -22,6 +22,7 @@ namespace Flowframes
public Fraction inFps; public Fraction inFps;
public Fraction inFpsDetected; public Fraction inFpsDetected;
public Fraction outFps; public Fraction outFps;
public float outItsScale;
public float interpFactor; public float interpFactor;
public Interpolate.OutMode outMode; public Interpolate.OutMode outMode;
public ModelCollection.ModelInfo model; public ModelCollection.ModelInfo model;
@@ -39,7 +40,7 @@ namespace Flowframes
public string framesExt; public string framesExt;
public string interpExt; public string interpExt;
public InterpSettings(string inPathArg, string outPathArg, AI aiArg, Fraction inFpsDetectedArg, Fraction inFpsArg, int interpFactorArg, Interpolate.OutMode outModeArg, ModelCollection.ModelInfo modelArg) public InterpSettings(string inPathArg, string outPathArg, AI aiArg, Fraction inFpsDetectedArg, Fraction inFpsArg, int interpFactorArg, float itsScale, Interpolate.OutMode outModeArg, ModelCollection.ModelInfo modelArg)
{ {
inPath = inPathArg; inPath = inPathArg;
outPath = outPathArg; outPath = outPathArg;
@@ -48,6 +49,7 @@ namespace Flowframes
inFps = inFpsArg; inFps = inFpsArg;
interpFactor = interpFactorArg; interpFactor = interpFactorArg;
outFps = inFpsArg * interpFactorArg; outFps = inFpsArg * interpFactorArg;
outItsScale = itsScale;
outMode = outModeArg; outMode = outModeArg;
model = modelArg; model = modelArg;

93
Code/Form1.Designer.cs generated
View File

@@ -37,9 +37,7 @@
this.outModeCombox = new System.Windows.Forms.ComboBox(); this.outModeCombox = new System.Windows.Forms.ComboBox();
this.label9 = new System.Windows.Forms.Label(); this.label9 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label(); this.label8 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label(); this.label6 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.fpsOutTbox = new System.Windows.Forms.TextBox(); this.fpsOutTbox = new System.Windows.Forms.TextBox();
this.fpsInTbox = new System.Windows.Forms.TextBox(); this.fpsInTbox = new System.Windows.Forms.TextBox();
this.interpFactorCombox = new System.Windows.Forms.ComboBox(); this.interpFactorCombox = new System.Windows.Forms.ComboBox();
@@ -91,6 +89,7 @@
this.label15 = new System.Windows.Forms.Label(); this.label15 = new System.Windows.Forms.Label();
this.label11 = new System.Windows.Forms.Label(); this.label11 = new System.Windows.Forms.Label();
this.interpOptsTab = new System.Windows.Forms.TabPage(); this.interpOptsTab = new System.Windows.Forms.TabPage();
this.outSpeedCombox = new System.Windows.Forms.ComboBox();
this.completionActionPanel = new System.Windows.Forms.Panel(); this.completionActionPanel = new System.Windows.Forms.Panel();
this.completionAction = new System.Windows.Forms.ComboBox(); this.completionAction = new System.Windows.Forms.ComboBox();
this.label25 = new System.Windows.Forms.Label(); this.label25 = new System.Windows.Forms.Label();
@@ -137,6 +136,7 @@
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.pauseBtn = new System.Windows.Forms.Button(); this.pauseBtn = new System.Windows.Forms.Button();
this.cancelBtn = new System.Windows.Forms.Button(); this.cancelBtn = new System.Windows.Forms.Button();
this.pictureBox5 = new System.Windows.Forms.PictureBox();
this.panel1.SuspendLayout(); this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox4)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox4)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).BeginInit();
@@ -160,6 +160,7 @@
this.abtTab.SuspendLayout(); this.abtTab.SuspendLayout();
this.busyControlsPanel.SuspendLayout(); this.busyControlsPanel.SuspendLayout();
this.tableLayoutPanel1.SuspendLayout(); this.tableLayoutPanel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox5)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// titleLabel // titleLabel
@@ -255,43 +256,22 @@
this.label8.TabIndex = 13; this.label8.TabIndex = 13;
this.label8.Text = "AI Model"; this.label8.Text = "AI Model";
// //
// label7
//
this.label7.AutoSize = true;
this.label7.ForeColor = System.Drawing.Color.White;
this.label7.Location = new System.Drawing.Point(684, 100);
this.label7.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(67, 15);
this.label7.TabIndex = 12;
this.label7.Text = "Output FPS";
//
// label6 // label6
// //
this.label6.AutoSize = true; this.label6.AutoSize = true;
this.label6.ForeColor = System.Drawing.Color.White; this.label6.ForeColor = System.Drawing.Color.White;
this.label6.Location = new System.Drawing.Point(554, 100); this.label6.Location = new System.Drawing.Point(443, 100);
this.label6.Margin = new System.Windows.Forms.Padding(3, 0, 0, 0);
this.label6.Name = "label6"; this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(15, 15); this.label6.Size = new System.Drawing.Size(15, 15);
this.label6.TabIndex = 11; this.label6.TabIndex = 11;
this.label6.Text = "="; this.label6.Text = "=";
// //
// label5
//
this.label5.AutoSize = true;
this.label5.ForeColor = System.Drawing.Color.White;
this.label5.Location = new System.Drawing.Point(384, 100);
this.label5.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(57, 15);
this.label5.TabIndex = 10;
this.label5.Text = "Input FPS";
//
// fpsOutTbox // fpsOutTbox
// //
this.fpsOutTbox.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); this.fpsOutTbox.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.fpsOutTbox.ForeColor = System.Drawing.Color.White; this.fpsOutTbox.ForeColor = System.Drawing.Color.White;
this.fpsOutTbox.Location = new System.Drawing.Point(574, 97); this.fpsOutTbox.Location = new System.Drawing.Point(461, 97);
this.fpsOutTbox.MinimumSize = new System.Drawing.Size(4, 21); this.fpsOutTbox.MinimumSize = new System.Drawing.Size(4, 21);
this.fpsOutTbox.Name = "fpsOutTbox"; this.fpsOutTbox.Name = "fpsOutTbox";
this.fpsOutTbox.ReadOnly = true; this.fpsOutTbox.ReadOnly = true;
@@ -317,9 +297,9 @@
this.interpFactorCombox.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.interpFactorCombox.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.interpFactorCombox.ForeColor = System.Drawing.Color.White; this.interpFactorCombox.ForeColor = System.Drawing.Color.White;
this.interpFactorCombox.FormattingEnabled = true; this.interpFactorCombox.FormattingEnabled = true;
this.interpFactorCombox.Location = new System.Drawing.Point(447, 96); this.interpFactorCombox.Location = new System.Drawing.Point(387, 97);
this.interpFactorCombox.Name = "interpFactorCombox"; this.interpFactorCombox.Name = "interpFactorCombox";
this.interpFactorCombox.Size = new System.Drawing.Size(100, 23); this.interpFactorCombox.Size = new System.Drawing.Size(50, 23);
this.interpFactorCombox.TabIndex = 7; this.interpFactorCombox.TabIndex = 7;
this.interpFactorCombox.SelectedIndexChanged += new System.EventHandler(this.interpFactorCombox_SelectedIndexChanged); this.interpFactorCombox.SelectedIndexChanged += new System.EventHandler(this.interpFactorCombox_SelectedIndexChanged);
this.interpFactorCombox.TextUpdate += new System.EventHandler(this.interpFactorCombox_SelectedIndexChanged); this.interpFactorCombox.TextUpdate += new System.EventHandler(this.interpFactorCombox_SelectedIndexChanged);
@@ -332,9 +312,9 @@
this.label4.Location = new System.Drawing.Point(11, 100); this.label4.Location = new System.Drawing.Point(11, 100);
this.label4.Margin = new System.Windows.Forms.Padding(8, 0, 3, 0); this.label4.Margin = new System.Windows.Forms.Padding(8, 0, 3, 0);
this.label4.Name = "label4"; this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(148, 13); this.label4.Size = new System.Drawing.Size(117, 13);
this.label4.TabIndex = 6; this.label4.TabIndex = 6;
this.label4.Text = "Set FPS / Interpolation Factor"; this.label4.Text = "Output FPS and Speed";
// //
// outputTbox // outputTbox
// //
@@ -586,7 +566,8 @@
this.pictureBox4.Size = new System.Drawing.Size(29, 21); this.pictureBox4.Size = new System.Drawing.Size(29, 21);
this.pictureBox4.TabIndex = 31; this.pictureBox4.TabIndex = 31;
this.pictureBox4.TabStop = false; this.pictureBox4.TabStop = false;
this.toolTip1.SetToolTip(this.pictureBox4, "Supports drag-n-drop."); this.toolTip1.SetToolTip(this.pictureBox4, "Set your input video file, or a folder that contains frames/images.\r\nSupports Dra" +
"g-N-Drop.");
// //
// pictureBox3 // pictureBox3
// //
@@ -597,19 +578,19 @@
this.pictureBox3.Size = new System.Drawing.Size(29, 21); this.pictureBox3.Size = new System.Drawing.Size(29, 21);
this.pictureBox3.TabIndex = 30; this.pictureBox3.TabIndex = 30;
this.pictureBox3.TabStop = false; this.pictureBox3.TabStop = false;
this.toolTip1.SetToolTip(this.pictureBox3, "Supports drag-n-drop.\r\nGets auto-assigned whenever you set an input file."); this.toolTip1.SetToolTip(this.pictureBox3, "Supports Drag-N-Drop.\r\nGets auto-assigned whenever you set an input file.");
// //
// info1 // info1
// //
this.info1.BackgroundImage = global::Flowframes.Properties.Resources.questmark_72px_bordeer; this.info1.BackgroundImage = global::Flowframes.Properties.Resources.questmark_72px_bordeer;
this.info1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; this.info1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.info1.Location = new System.Drawing.Point(165, 97); this.info1.Location = new System.Drawing.Point(134, 97);
this.info1.Name = "info1"; this.info1.Name = "info1";
this.info1.Size = new System.Drawing.Size(29, 21); this.info1.Size = new System.Drawing.Size(29, 21);
this.info1.TabIndex = 27; this.info1.TabIndex = 27;
this.info1.TabStop = false; this.info1.TabStop = false;
this.toolTip1.SetToolTip(this.info1, "Note: RIFE does not support factors that are not a power of two (like 3x, or 5x)." + this.toolTip1.SetToolTip(this.info1, "Here you can change your interpolation factor (different AIs support different fa" +
"\r\nFuture interpolation AIs might support this however."); "ctors), which will determine your output frame rate.");
// //
// settingsBtn // settingsBtn
// //
@@ -692,8 +673,8 @@
this.pictureBox1.Size = new System.Drawing.Size(29, 21); this.pictureBox1.Size = new System.Drawing.Size(29, 21);
this.pictureBox1.TabIndex = 28; this.pictureBox1.TabIndex = 28;
this.pictureBox1.TabStop = false; this.pictureBox1.TabStop = false;
this.toolTip1.SetToolTip(this.pictureBox1, "This is the trained data the AI will use.\r\nDifferent AI models will produce sligh" + this.toolTip1.SetToolTip(this.pictureBox1, "This is the training data the AI will use.\r\nDifferent AI models will produce slig" +
"tly different results. Try them for yourself."); "htly different results. Try them for yourself.");
// //
// pictureBox2 // pictureBox2
// //
@@ -919,6 +900,8 @@
// //
this.interpOptsTab.AllowDrop = true; this.interpOptsTab.AllowDrop = true;
this.interpOptsTab.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48))))); this.interpOptsTab.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
this.interpOptsTab.Controls.Add(this.pictureBox5);
this.interpOptsTab.Controls.Add(this.outSpeedCombox);
this.interpOptsTab.Controls.Add(this.completionActionPanel); this.interpOptsTab.Controls.Add(this.completionActionPanel);
this.interpOptsTab.Controls.Add(this.encodingSettingsBtn); this.interpOptsTab.Controls.Add(this.encodingSettingsBtn);
this.interpOptsTab.Controls.Add(this.scnDetectTestBtn); this.interpOptsTab.Controls.Add(this.scnDetectTestBtn);
@@ -936,11 +919,9 @@
this.interpOptsTab.Controls.Add(this.aiModel); this.interpOptsTab.Controls.Add(this.aiModel);
this.interpOptsTab.Controls.Add(this.fpsInTbox); this.interpOptsTab.Controls.Add(this.fpsInTbox);
this.interpOptsTab.Controls.Add(this.fpsOutTbox); this.interpOptsTab.Controls.Add(this.fpsOutTbox);
this.interpOptsTab.Controls.Add(this.label5);
this.interpOptsTab.Controls.Add(this.aiCombox); this.interpOptsTab.Controls.Add(this.aiCombox);
this.interpOptsTab.Controls.Add(this.label6); this.interpOptsTab.Controls.Add(this.label6);
this.interpOptsTab.Controls.Add(this.label13); this.interpOptsTab.Controls.Add(this.label13);
this.interpOptsTab.Controls.Add(this.label7);
this.interpOptsTab.Controls.Add(this.label8); this.interpOptsTab.Controls.Add(this.label8);
this.interpOptsTab.Controls.Add(this.label9); this.interpOptsTab.Controls.Add(this.label9);
this.interpOptsTab.Controls.Add(this.outModeCombox); this.interpOptsTab.Controls.Add(this.outModeCombox);
@@ -958,6 +939,23 @@
this.interpOptsTab.DragDrop += new System.Windows.Forms.DragEventHandler(this.Form1_DragDrop); this.interpOptsTab.DragDrop += new System.Windows.Forms.DragEventHandler(this.Form1_DragDrop);
this.interpOptsTab.DragEnter += new System.Windows.Forms.DragEventHandler(this.Form1_DragEnter); this.interpOptsTab.DragEnter += new System.Windows.Forms.DragEventHandler(this.Form1_DragEnter);
// //
// outSpeedCombox
//
this.outSpeedCombox.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.outSpeedCombox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.outSpeedCombox.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.outSpeedCombox.ForeColor = System.Drawing.Color.White;
this.outSpeedCombox.FormattingEnabled = true;
this.outSpeedCombox.Items.AddRange(new object[] {
"Normal Speed",
"2x Slowmo",
"4x Slowmo",
"8x Slowmo"});
this.outSpeedCombox.Location = new System.Drawing.Point(574, 97);
this.outSpeedCombox.Name = "outSpeedCombox";
this.outSpeedCombox.Size = new System.Drawing.Size(107, 23);
this.outSpeedCombox.TabIndex = 43;
//
// completionActionPanel // completionActionPanel
// //
this.completionActionPanel.Controls.Add(this.completionAction); this.completionActionPanel.Controls.Add(this.completionAction);
@@ -1628,6 +1626,18 @@
this.cancelBtn.TabIndex = 0; this.cancelBtn.TabIndex = 0;
this.cancelBtn.UseVisualStyleBackColor = true; this.cancelBtn.UseVisualStyleBackColor = true;
this.cancelBtn.Click += new System.EventHandler(this.cancelBtn_Click); this.cancelBtn.Click += new System.EventHandler(this.cancelBtn_Click);
//
// pictureBox5
//
this.pictureBox5.BackgroundImage = global::Flowframes.Properties.Resources.questmark_72px_bordeer;
this.pictureBox5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.pictureBox5.Location = new System.Drawing.Point(95, 7);
this.pictureBox5.Name = "pictureBox5";
this.pictureBox5.Size = new System.Drawing.Size(29, 21);
this.pictureBox5.TabIndex = 44;
this.pictureBox5.TabStop = false;
this.toolTip1.SetToolTip(this.pictureBox5, "Set the AI interpolation network to use for this video.\r\nDifferent AIs have diffe" +
"rent quality, VRAM requirements and speeds.");
// //
// Form1 // Form1
// //
@@ -1697,6 +1707,7 @@
this.abtTab.ResumeLayout(false); this.abtTab.ResumeLayout(false);
this.busyControlsPanel.ResumeLayout(false); this.busyControlsPanel.ResumeLayout(false);
this.tableLayoutPanel1.ResumeLayout(false); this.tableLayoutPanel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBox5)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@@ -1712,9 +1723,7 @@
private System.Windows.Forms.TextBox outputTbox; private System.Windows.Forms.TextBox outputTbox;
private System.Windows.Forms.ComboBox interpFactorCombox; private System.Windows.Forms.ComboBox interpFactorCombox;
private System.Windows.Forms.Label label4; private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label6; private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox fpsOutTbox; private System.Windows.Forms.TextBox fpsOutTbox;
private System.Windows.Forms.TextBox fpsInTbox; private System.Windows.Forms.TextBox fpsInTbox;
private System.Windows.Forms.Label label8; private System.Windows.Forms.Label label8;
@@ -1811,6 +1820,8 @@
private System.Windows.Forms.Panel completionActionPanel; private System.Windows.Forms.Panel completionActionPanel;
private System.Windows.Forms.ComboBox completionAction; private System.Windows.Forms.ComboBox completionAction;
private System.Windows.Forms.Label label25; private System.Windows.Forms.Label label25;
private System.Windows.Forms.ComboBox outSpeedCombox;
private System.Windows.Forms.PictureBox pictureBox5;
} }
} }

View File

@@ -40,6 +40,7 @@ namespace Flowframes
// Main Tab // Main Tab
UiUtils.InitCombox(interpFactorCombox, 0); UiUtils.InitCombox(interpFactorCombox, 0);
UiUtils.InitCombox(outSpeedCombox, 0);
UiUtils.InitCombox(outModeCombox, 0); UiUtils.InitCombox(outModeCombox, 0);
UiUtils.InitCombox(aiModel, 2); UiUtils.InitCombox(aiModel, 2);
// Video Utils // Video Utils
@@ -162,7 +163,8 @@ namespace Flowframes
public InterpSettings GetCurrentSettings() public InterpSettings GetCurrentSettings()
{ {
SetTab("interpolate"); SetTab("interpolate");
return new InterpSettings(inputTbox.Text.Trim(), outputTbox.Text.Trim(), GetAi(), currInFpsDetected, currInFps, interpFactorCombox.GetInt(), GetOutMode(), GetModel(GetAi())); return new InterpSettings(inputTbox.Text.Trim(), outputTbox.Text.Trim(), GetAi(), currInFpsDetected, currInFps,
interpFactorCombox.GetInt(), outSpeedCombox.GetInt().Clamp(1, 64), GetOutMode(), GetModel(GetAi()));
} }
public InterpSettings UpdateCurrentSettings(InterpSettings settings) public InterpSettings UpdateCurrentSettings(InterpSettings settings)
@@ -385,7 +387,7 @@ namespace Flowframes
{ {
string[] split = fpsInTbox.Text.Split('/'); string[] split = fpsInTbox.Text.Split('/');
Fraction frac = new Fraction(split[0].GetInt(), split[1].GetInt()); Fraction frac = new Fraction(split[0].GetInt(), split[1].GetInt());
fpsOutTbox.Text = (frac * interpFactorCombox.GetFloat()).ToString(); fpsOutTbox.Text = (frac * interpFactorCombox.GetFloat()).ToString() + " FPS";
if (!fpsInTbox.ReadOnly) if (!fpsInTbox.ReadOnly)
currInFps = frac; currInFps = frac;
@@ -393,7 +395,7 @@ namespace Flowframes
else // Parse float else // Parse float
{ {
fpsInTbox.Text = fpsInTbox.Text.TrimNumbers(true); fpsInTbox.Text = fpsInTbox.Text.TrimNumbers(true);
fpsOutTbox.Text = (fpsInTbox.GetFloat() * interpFactorCombox.GetFloat()).ToString(); fpsOutTbox.Text = (fpsInTbox.GetFloat() * interpFactorCombox.GetFloat()).ToString() + " FPS";
if (!fpsInTbox.ReadOnly) if (!fpsInTbox.ReadOnly)
currInFps = new Fraction(fpsInTbox.GetFloat()); currInFps = new Fraction(fpsInTbox.GetFloat());

View File

@@ -150,12 +150,12 @@ namespace Flowframes.Main
if (mode == I.OutMode.VidGif) if (mode == I.OutMode.VidGif)
{ {
await FfmpegEncode.FramesToGifConcat(framesFile, outPath, fps, true, Config.GetInt(Config.Key.gifColors), resampleFps); await FfmpegEncode.FramesToGifConcat(framesFile, outPath, fps, true, Config.GetInt(Config.Key.gifColors), resampleFps, I.current.outItsScale);
} }
else else
{ {
VidExtraData extraData = await FfmpegCommands.GetVidExtraInfo(I.current.inPath); VidExtraData extraData = await FfmpegCommands.GetVidExtraInfo(I.current.inPath);
await FfmpegEncode.FramesToVideo(framesFile, outPath, mode, fps, resampleFps, extraData); await FfmpegEncode.FramesToVideo(framesFile, outPath, mode, fps, resampleFps, I.current.outItsScale, extraData);
await MuxOutputVideo(I.current.inPath, outPath); await MuxOutputVideo(I.current.inPath, outPath);
await Loop(outPath, await GetLoopTimes()); await Loop(outPath, await GetLoopTimes());
} }
@@ -241,14 +241,14 @@ namespace Flowframes.Main
bool dontEncodeFullFpsVid = fpsLimit && Config.GetInt(Config.Key.maxFpsMode) == 0; bool dontEncodeFullFpsVid = fpsLimit && Config.GetInt(Config.Key.maxFpsMode) == 0;
if (!dontEncodeFullFpsVid) if (!dontEncodeFullFpsVid)
await FfmpegEncode.FramesToVideo(framesFileChunk, outPath, mode, I.current.outFps, new Fraction(), extraData, AvProcess.LogMode.Hidden, true); // Encode await FfmpegEncode.FramesToVideo(framesFileChunk, outPath, mode, I.current.outFps, new Fraction(), I.current.outItsScale, extraData, AvProcess.LogMode.Hidden, true); // Encode
if (fpsLimit) if (fpsLimit)
{ {
string filename = Path.GetFileName(outPath); string filename = Path.GetFileName(outPath);
string newParentDir = outPath.GetParentDir() + Paths.fpsLimitSuffix; string newParentDir = outPath.GetParentDir() + Paths.fpsLimitSuffix;
outPath = Path.Combine(newParentDir, filename); outPath = Path.Combine(newParentDir, filename);
await FfmpegEncode.FramesToVideo(framesFileChunk, outPath, mode, I.current.outFps, maxFps, extraData, AvProcess.LogMode.Hidden, true); // Encode with limited fps await FfmpegEncode.FramesToVideo(framesFileChunk, outPath, mode, I.current.outFps, maxFps, I.current.outItsScale, extraData, AvProcess.LogMode.Hidden, true); // Encode with limited fps
} }
} }

View File

@@ -13,7 +13,7 @@ namespace Flowframes.Media
{ {
partial class FfmpegEncode : FfmpegCommands partial class FfmpegEncode : FfmpegCommands
{ {
public static async Task FramesToVideo(string framesFile, string outPath, Interpolate.OutMode outMode, Fraction fps, Fraction resampleFps, VidExtraData extraData, LogMode logMode = LogMode.OnlyLastLine, bool isChunk = false) public static async Task FramesToVideo(string framesFile, string outPath, Interpolate.OutMode outMode, Fraction fps, Fraction resampleFps, float itsScale, VidExtraData extraData, LogMode logMode = LogMode.OnlyLastLine, bool isChunk = false)
{ {
if (logMode != LogMode.Hidden) if (logMode != LogMode.Hidden)
Logger.Log((resampleFps.GetFloat() <= 0) ? "Encoding video..." : $"Encoding video resampled to {resampleFps.GetString()} FPS..."); Logger.Log((resampleFps.GetFloat() <= 0) ? "Encoding video..." : $"Encoding video resampled to {resampleFps.GetString()} FPS...");
@@ -32,7 +32,6 @@ namespace Flowframes.Media
} }
string extraArgs = Config.Get(Config.Key.ffEncArgs); string extraArgs = Config.Get(Config.Key.ffEncArgs);
string rate = fps.ToString().Replace(",", ".");
List<string> filters = new List<string>(); List<string> filters = new List<string>();
@@ -47,7 +46,8 @@ namespace Flowframes.Media
} }
string vf = filters.Count > 0 ? $"-vf {string.Join(",", filters)}" : ""; string vf = filters.Count > 0 ? $"-vf {string.Join(",", filters)}" : "";
string args = $"-vsync 0 -r {rate} {inArg} {encArgs} {vf} {GetAspectArg(extraData)} {extraArgs} -threads {Config.GetInt(Config.Key.ffEncThreads)} {outPath.Wrap()}"; fps = fps / new Fraction(itsScale);
string args = $"-vsync 0 -r {fps} {inArg} {encArgs} {vf} {GetAspectArg(extraData)} {extraArgs} -threads {Config.GetInt(Config.Key.ffEncThreads)} {outPath.Wrap()}";
await RunFfmpeg(args, framesFile.GetParentDir(), logMode, "error", TaskType.Encode, !isChunk); await RunFfmpeg(args, framesFile.GetParentDir(), logMode, "error", TaskType.Encode, !isChunk);
IoUtils.TryDeleteIfExists(linksDir); IoUtils.TryDeleteIfExists(linksDir);
} }
@@ -85,7 +85,7 @@ namespace Flowframes.Media
IoUtils.TryDeleteIfExists(linksDir); IoUtils.TryDeleteIfExists(linksDir);
} }
public static async Task FramesToGifConcat(string framesFile, string outPath, Fraction rate, bool palette, int colors, Fraction resampleFps, LogMode logMode = LogMode.OnlyLastLine) public static async Task FramesToGifConcat(string framesFile, string outPath, Fraction rate, bool palette, int colors, Fraction resampleFps, float itsScale, LogMode logMode = LogMode.OnlyLastLine)
{ {
if (rate.GetFloat() > 50f && (resampleFps.GetFloat() > 50f || resampleFps.GetFloat() < 1)) if (rate.GetFloat() > 50f && (resampleFps.GetFloat() > 50f || resampleFps.GetFloat() < 1))
resampleFps = new Fraction(50, 1); // Force limit framerate as encoding above 50 will cause problems resampleFps = new Fraction(50, 1); // Force limit framerate as encoding above 50 will cause problems
@@ -99,6 +99,7 @@ namespace Flowframes.Media
string fpsFilter = (resampleFps.GetFloat() <= 0) ? "" : $"fps=fps={resampleFps}"; string fpsFilter = (resampleFps.GetFloat() <= 0) ? "" : $"fps=fps={resampleFps}";
string vf = FormatUtils.ConcatStrings(new string[] { paletteFilter, fpsFilter }); string vf = FormatUtils.ConcatStrings(new string[] { paletteFilter, fpsFilter });
string extraArgs = Config.Get(Config.Key.ffEncArgs); string extraArgs = Config.Get(Config.Key.ffEncArgs);
rate = rate / new Fraction(itsScale);
string args = $"-f concat -r {rate} -i {framesFilename.Wrap()} -gifflags -offsetting {vf} {extraArgs} {outPath.Wrap()}"; string args = $"-f concat -r {rate} -i {framesFilename.Wrap()} -gifflags -offsetting {vf} {extraArgs} {outPath.Wrap()}";
await RunFfmpeg(args, framesFile.GetParentDir(), LogMode.OnlyLastLine, "error", TaskType.Encode); await RunFfmpeg(args, framesFile.GetParentDir(), LogMode.OnlyLastLine, "error", TaskType.Encode);
} }