mirror of https://github.com/n00mkrad/flowframes
Fix image sequences, Nmkoder session path system, some refactoring/cleanup
This commit is contained in:
parent
7e0a8e7c94
commit
a0b145ae0d
|
@ -1,4 +1,5 @@
|
|||
using Flowframes.Data.Streams;
|
||||
using Flowframes.Forms;
|
||||
using Flowframes.IO;
|
||||
using Flowframes.Media;
|
||||
using Flowframes.MiscUtils;
|
||||
|
@ -17,7 +18,6 @@ namespace Flowframes.Data
|
|||
public bool IsDirectory;
|
||||
public FileInfo FileInfo;
|
||||
public DirectoryInfo DirectoryInfo;
|
||||
public int FileCount;
|
||||
public string Name;
|
||||
public string SourcePath;
|
||||
public string ImportPath;
|
||||
|
@ -40,9 +40,10 @@ namespace Flowframes.Data
|
|||
public bool Initialized = false;
|
||||
public bool SequenceInitialized = false;
|
||||
|
||||
public int FileCount = 1;
|
||||
public int FrameCount { get { return VideoStreams.Count > 0 ? VideoStreams[0].FrameCount : 0; } }
|
||||
|
||||
public MediaFile(string path /* , bool requestFpsInputIfUnset = true */)
|
||||
public MediaFile(string path, bool requestFpsInputIfUnset = true)
|
||||
{
|
||||
CreationTime = (long)(DateTime.Now - new DateTime(1970, 1, 1)).TotalMilliseconds; // Unix Timestamp as UID
|
||||
|
||||
|
@ -54,12 +55,12 @@ namespace Flowframes.Data
|
|||
SourcePath = DirectoryInfo.FullName;
|
||||
Format = "Folder";
|
||||
|
||||
// if (requestFpsInputIfUnset && InputRate == null)
|
||||
// {
|
||||
// PromptForm form = new PromptForm("Enter Frame Rate", $"Please enter a frame rate to use for the image sequence '{Name.Trunc(80)}'.", "30");
|
||||
// form.ShowDialog();
|
||||
// InputRate = new Fraction(form.EnteredText);
|
||||
// }
|
||||
if (requestFpsInputIfUnset && InputRate == null)
|
||||
{
|
||||
PromptForm form = new PromptForm("Enter Frame Rate", $"Please enter a frame rate to use for the image sequence '{Name.Trunc(80)}'.", "15");
|
||||
form.ShowDialog();
|
||||
InputRate = new Fraction(form.EnteredText);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -68,7 +69,6 @@ namespace Flowframes.Data
|
|||
SourcePath = FileInfo.FullName;
|
||||
ImportPath = FileInfo.FullName;
|
||||
Format = FileInfo.Extension.Remove(".").ToUpper();
|
||||
FileCount = 1;
|
||||
InputRate = new Fraction(-1, 1);
|
||||
}
|
||||
|
||||
|
@ -77,27 +77,22 @@ namespace Flowframes.Data
|
|||
|
||||
public async Task InitializeSequence()
|
||||
{
|
||||
Logger.Log($"InitializeSequence not implemented!!");
|
||||
try
|
||||
{
|
||||
if (SequenceInitialized) return;
|
||||
|
||||
// try
|
||||
// {
|
||||
// if (SequenceInitialized) return;
|
||||
//
|
||||
// Logger.Log($"Preparing image sequence...");
|
||||
// Logger.Log($"MediaFile {Name}: Preparing image sequence", true);
|
||||
// string seqPath = Path.Combine(Paths.GetFrameSeqPath(), CreationTime.ToString(), "frames.concat");
|
||||
// string chosenExt = IoUtils.GetUniqueExtensions(SourcePath).FirstOrDefault();
|
||||
// int fileCount = FfmpegUtils.CreateConcatFile(SourcePath, seqPath, new List<string> { chosenExt });
|
||||
// ImportPath = seqPath;
|
||||
// FileCount = fileCount;
|
||||
// Logger.Log($"Created concat file with {fileCount} files.", true);
|
||||
// SequenceInitialized = true;
|
||||
// }
|
||||
// catch (Exception e)
|
||||
// {
|
||||
// Logger.Log($"Error preparing frame sequence: {e.Message}\n{e.StackTrace}");
|
||||
// FileCount = 0;
|
||||
// }
|
||||
string seqPath = Path.Combine(Paths.GetFrameSeqPath(), CreationTime.ToString(), "frames.concat");
|
||||
string chosenExt = IoUtils.GetUniqueExtensions(SourcePath).FirstOrDefault();
|
||||
int fileCount = FfmpegUtils.CreateConcatFile(SourcePath, seqPath, new List<string> { chosenExt });
|
||||
ImportPath = seqPath;
|
||||
FileCount = fileCount;
|
||||
SequenceInitialized = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Log($"Error preparing frame sequence: {e.Message}\n{e.StackTrace}");
|
||||
FileCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task Initialize(bool progressBar = true, bool countFrames = true)
|
||||
|
|
|
@ -25,6 +25,14 @@ namespace Flowframes.IO
|
|||
public const string audioVideoDir = "av";
|
||||
public const string licensesDir = "licenses";
|
||||
|
||||
public static string sessionTimestamp;
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
var n = DateTime.Now;
|
||||
sessionTimestamp = $"{n.Year}-{n.Month}-{n.Day}-{n.Hour}-{n.Minute}-{n.Second}-{n.Millisecond}";
|
||||
}
|
||||
|
||||
public static string GetFrameOrderFilename(float factor)
|
||||
{
|
||||
return $"{frameOrderPrefix}-{factor.ToStringDot()}x.ini";
|
||||
|
@ -57,6 +65,13 @@ namespace Flowframes.IO
|
|||
return path;
|
||||
}
|
||||
|
||||
public static string GetSessionsPath()
|
||||
{
|
||||
string path = Path.Combine(GetDataPath(), "sessions");
|
||||
Directory.CreateDirectory(path);
|
||||
return path;
|
||||
}
|
||||
|
||||
public static string GetPkgPath()
|
||||
{
|
||||
string path = Path.Combine(GetDataPath(), "pkgs");
|
||||
|
@ -64,9 +79,23 @@ namespace Flowframes.IO
|
|||
return path;
|
||||
}
|
||||
|
||||
public static string GetLogPath()
|
||||
public static string GetLogPath(bool noSession = false)
|
||||
{
|
||||
string path = Path.Combine(GetDataPath(), "logs");
|
||||
string path = Path.Combine(GetDataPath(), "logs", (noSession ? "" : sessionTimestamp));
|
||||
Directory.CreateDirectory(path);
|
||||
return path;
|
||||
}
|
||||
|
||||
public static string GetSessionDataPath()
|
||||
{
|
||||
string path = Path.Combine(GetSessionsPath(), sessionTimestamp);
|
||||
Directory.CreateDirectory(path);
|
||||
return path;
|
||||
}
|
||||
|
||||
public static string GetFrameSeqPath(bool noSession = false)
|
||||
{
|
||||
string path = Path.Combine((noSession ? GetDataPath() : GetSessionDataPath()), "frameSequences");
|
||||
Directory.CreateDirectory(path);
|
||||
return path;
|
||||
}
|
||||
|
|
|
@ -384,6 +384,12 @@
|
|||
<Compile Include="Forms\ModelDownloadForm.Designer.cs">
|
||||
<DependentUpon>ModelDownloadForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\PromptForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\PromptForm.designer.cs">
|
||||
<DependentUpon>PromptForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\SettingsForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
@ -487,6 +493,9 @@
|
|||
<EmbeddedResource Include="Forms\ModelDownloadForm.resx">
|
||||
<DependentUpon>ModelDownloadForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Forms\PromptForm.resx">
|
||||
<DependentUpon>PromptForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Forms\SettingsForm.resx">
|
||||
<DependentUpon>SettingsForm.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
|
|
|
@ -509,6 +509,8 @@ namespace Flowframes
|
|||
|
||||
if (dialog == DialogResult.No)
|
||||
e.Cancel = true;
|
||||
|
||||
Program.Cleanup();
|
||||
}
|
||||
|
||||
private void licenseBtn_Click(object sender, EventArgs e)
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Flowframes.Forms
|
||||
{
|
||||
public partial class PromptForm : Form
|
||||
{
|
||||
public string EnteredText { get; set; }
|
||||
|
||||
public PromptForm(string title, string message, string defaultText)
|
||||
{
|
||||
InitializeComponent();
|
||||
Text = title;
|
||||
msgLabel.Text = message;
|
||||
textBox.Text = defaultText;
|
||||
AcceptButton = confirmBtn;
|
||||
}
|
||||
|
||||
private void PromptForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void confirmBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
EnteredText = textBox.Text.Trim();
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
Program.mainForm.BringToFront();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
|
||||
namespace Flowframes.Forms
|
||||
{
|
||||
partial class PromptForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PromptForm));
|
||||
this.msgLabel = new System.Windows.Forms.Label();
|
||||
this.textBox = new System.Windows.Forms.TextBox();
|
||||
this.confirmBtn = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// msgLabel
|
||||
//
|
||||
this.msgLabel.ForeColor = System.Drawing.Color.White;
|
||||
this.msgLabel.Location = new System.Drawing.Point(13, 13);
|
||||
this.msgLabel.Margin = new System.Windows.Forms.Padding(4, 4, 4, 11);
|
||||
this.msgLabel.Name = "msgLabel";
|
||||
this.msgLabel.Size = new System.Drawing.Size(318, 30);
|
||||
this.msgLabel.TabIndex = 18;
|
||||
this.msgLabel.Text = "The Text Here";
|
||||
this.msgLabel.TextAlign = System.Drawing.ContentAlignment.TopCenter;
|
||||
//
|
||||
// textBox
|
||||
//
|
||||
this.textBox.AllowDrop = true;
|
||||
this.textBox.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
||||
this.textBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.textBox.ForeColor = System.Drawing.Color.White;
|
||||
this.textBox.Location = new System.Drawing.Point(16, 57);
|
||||
this.textBox.MinimumSize = new System.Drawing.Size(4, 23);
|
||||
this.textBox.Name = "textBox";
|
||||
this.textBox.Size = new System.Drawing.Size(315, 21);
|
||||
this.textBox.TabIndex = 55;
|
||||
//
|
||||
// confirmBtn
|
||||
//
|
||||
this.confirmBtn.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.confirmBtn.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
|
||||
this.confirmBtn.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
|
||||
this.confirmBtn.Location = new System.Drawing.Point(12, 106);
|
||||
this.confirmBtn.Name = "confirmBtn";
|
||||
this.confirmBtn.Size = new System.Drawing.Size(320, 23);
|
||||
this.confirmBtn.TabIndex = 56;
|
||||
this.confirmBtn.Text = "OK";
|
||||
this.confirmBtn.UseVisualStyleBackColor = false;
|
||||
this.confirmBtn.Click += new System.EventHandler(this.confirmBtn_Click);
|
||||
//
|
||||
// PromptForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(32)))), ((int)(((byte)(32)))), ((int)(((byte)(32)))));
|
||||
this.ClientSize = new System.Drawing.Size(344, 141);
|
||||
this.Controls.Add(this.confirmBtn);
|
||||
this.Controls.Add(this.textBox);
|
||||
this.Controls.Add(this.msgLabel);
|
||||
this.ForeColor = System.Drawing.Color.White;
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.Name = "PromptForm";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Prompt";
|
||||
this.Load += new System.EventHandler(this.PromptForm_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Label msgLabel;
|
||||
private System.Windows.Forms.TextBox textBox;
|
||||
private System.Windows.Forms.Button confirmBtn;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -60,8 +60,6 @@
|
|||
this.panel10 = new System.Windows.Forms.Panel();
|
||||
this.maxVidHeight = new System.Windows.Forms.ComboBox();
|
||||
this.label31 = new System.Windows.Forms.Label();
|
||||
this.delLogsOnStartup = new System.Windows.Forms.CheckBox();
|
||||
this.label11 = new System.Windows.Forms.Label();
|
||||
this.tabListPage2 = new Cyotek.Windows.Forms.TabListPage();
|
||||
this.autoEncBlockPanel = new System.Windows.Forms.Panel();
|
||||
this.label70 = new System.Windows.Forms.Label();
|
||||
|
@ -250,8 +248,6 @@
|
|||
this.generalTab.Controls.Add(this.panel10);
|
||||
this.generalTab.Controls.Add(this.maxVidHeight);
|
||||
this.generalTab.Controls.Add(this.label31);
|
||||
this.generalTab.Controls.Add(this.delLogsOnStartup);
|
||||
this.generalTab.Controls.Add(this.label11);
|
||||
this.generalTab.ForeColor = System.Drawing.Color.White;
|
||||
this.generalTab.Name = "generalTab";
|
||||
this.generalTab.Size = new System.Drawing.Size(762, 419);
|
||||
|
@ -310,7 +306,7 @@
|
|||
//
|
||||
this.label77.AutoSize = true;
|
||||
this.label77.ForeColor = System.Drawing.Color.Silver;
|
||||
this.label77.Location = new System.Drawing.Point(308, 220);
|
||||
this.label77.Location = new System.Drawing.Point(308, 190);
|
||||
this.label77.Margin = new System.Windows.Forms.Padding(10, 10, 10, 7);
|
||||
this.label77.Name = "label77";
|
||||
this.label77.Size = new System.Drawing.Size(270, 13);
|
||||
|
@ -320,7 +316,7 @@
|
|||
// disablePreview
|
||||
//
|
||||
this.disablePreview.AutoSize = true;
|
||||
this.disablePreview.Location = new System.Drawing.Point(280, 220);
|
||||
this.disablePreview.Location = new System.Drawing.Point(280, 190);
|
||||
this.disablePreview.Name = "disablePreview";
|
||||
this.disablePreview.Size = new System.Drawing.Size(15, 14);
|
||||
this.disablePreview.TabIndex = 88;
|
||||
|
@ -329,7 +325,7 @@
|
|||
// label76
|
||||
//
|
||||
this.label76.AutoSize = true;
|
||||
this.label76.Location = new System.Drawing.Point(10, 220);
|
||||
this.label76.Location = new System.Drawing.Point(10, 190);
|
||||
this.label76.Margin = new System.Windows.Forms.Padding(10, 10, 10, 7);
|
||||
this.label76.Name = "label76";
|
||||
this.label76.Size = new System.Drawing.Size(105, 13);
|
||||
|
@ -342,7 +338,7 @@
|
|||
this.modelDownloaderBtn.FlatAppearance.BorderSize = 0;
|
||||
this.modelDownloaderBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.modelDownloaderBtn.ForeColor = System.Drawing.Color.White;
|
||||
this.modelDownloaderBtn.Location = new System.Drawing.Point(492, 245);
|
||||
this.modelDownloaderBtn.Location = new System.Drawing.Point(492, 215);
|
||||
this.modelDownloaderBtn.Name = "modelDownloaderBtn";
|
||||
this.modelDownloaderBtn.Size = new System.Drawing.Size(206, 23);
|
||||
this.modelDownloaderBtn.TabIndex = 86;
|
||||
|
@ -417,7 +413,7 @@
|
|||
this.clearModelCacheBtn.FlatAppearance.BorderSize = 0;
|
||||
this.clearModelCacheBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.clearModelCacheBtn.ForeColor = System.Drawing.Color.White;
|
||||
this.clearModelCacheBtn.Location = new System.Drawing.Point(280, 245);
|
||||
this.clearModelCacheBtn.Location = new System.Drawing.Point(280, 215);
|
||||
this.clearModelCacheBtn.Name = "clearModelCacheBtn";
|
||||
this.clearModelCacheBtn.Size = new System.Drawing.Size(206, 23);
|
||||
this.clearModelCacheBtn.TabIndex = 79;
|
||||
|
@ -428,7 +424,7 @@
|
|||
// label64
|
||||
//
|
||||
this.label64.AutoSize = true;
|
||||
this.label64.Location = new System.Drawing.Point(10, 250);
|
||||
this.label64.Location = new System.Drawing.Point(10, 220);
|
||||
this.label64.Margin = new System.Windows.Forms.Padding(10, 10, 10, 7);
|
||||
this.label64.Name = "label64";
|
||||
this.label64.Size = new System.Drawing.Size(165, 13);
|
||||
|
@ -582,25 +578,6 @@
|
|||
this.label31.TabIndex = 62;
|
||||
this.label31.Text = "Maximum Video Input Size (Height)";
|
||||
//
|
||||
// delLogsOnStartup
|
||||
//
|
||||
this.delLogsOnStartup.AutoSize = true;
|
||||
this.delLogsOnStartup.Location = new System.Drawing.Point(280, 190);
|
||||
this.delLogsOnStartup.Name = "delLogsOnStartup";
|
||||
this.delLogsOnStartup.Size = new System.Drawing.Size(15, 14);
|
||||
this.delLogsOnStartup.TabIndex = 23;
|
||||
this.delLogsOnStartup.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// label11
|
||||
//
|
||||
this.label11.AutoSize = true;
|
||||
this.label11.Location = new System.Drawing.Point(10, 190);
|
||||
this.label11.Margin = new System.Windows.Forms.Padding(10, 10, 10, 7);
|
||||
this.label11.Name = "label11";
|
||||
this.label11.Size = new System.Drawing.Size(216, 13);
|
||||
this.label11.TabIndex = 22;
|
||||
this.label11.Text = "Delete Logs Of Previous Session On Startup";
|
||||
//
|
||||
// tabListPage2
|
||||
//
|
||||
this.tabListPage2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
|
||||
|
@ -2030,7 +2007,7 @@
|
|||
this.ffEncArgs.Location = new System.Drawing.Point(280, 180);
|
||||
this.ffEncArgs.MinimumSize = new System.Drawing.Size(4, 21);
|
||||
this.ffEncArgs.Name = "ffEncArgs";
|
||||
this.ffEncArgs.Size = new System.Drawing.Size(400, 21);
|
||||
this.ffEncArgs.Size = new System.Drawing.Size(400, 20);
|
||||
this.ffEncArgs.TabIndex = 85;
|
||||
//
|
||||
// label56
|
||||
|
@ -2215,8 +2192,6 @@
|
|||
private Cyotek.Windows.Forms.TabListPage tabListPage2;
|
||||
private Cyotek.Windows.Forms.TabListPage debugTab;
|
||||
private System.Windows.Forms.Label titleLabel;
|
||||
private System.Windows.Forms.CheckBox delLogsOnStartup;
|
||||
private System.Windows.Forms.Label label11;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.CheckBox keepAudio;
|
||||
private System.Windows.Forms.Label label1;
|
||||
|
|
|
@ -90,7 +90,6 @@ namespace Flowframes.Forms
|
|||
ConfigParser.SaveGuiElement(keepTempFolder);
|
||||
ConfigParser.SaveGuiElement(exportNamePattern);
|
||||
ConfigParser.SaveGuiElement(exportNamePatternLoop);
|
||||
ConfigParser.SaveGuiElement(delLogsOnStartup);
|
||||
ConfigParser.SaveGuiElement(disablePreview);
|
||||
// Interpolation
|
||||
ConfigParser.SaveGuiElement(keepAudio);
|
||||
|
@ -147,7 +146,6 @@ namespace Flowframes.Forms
|
|||
ConfigParser.LoadGuiElement(maxVidHeight);
|
||||
ConfigParser.LoadComboxIndex(tempFolderLoc); ConfigParser.LoadGuiElement(tempDirCustom);
|
||||
ConfigParser.LoadComboxIndex(outFolderLoc); ConfigParser.LoadGuiElement(custOutDir);
|
||||
ConfigParser.LoadGuiElement(delLogsOnStartup);
|
||||
ConfigParser.LoadGuiElement(keepTempFolder);
|
||||
ConfigParser.LoadGuiElement(exportNamePattern);
|
||||
ConfigParser.LoadGuiElement(exportNamePatternLoop);
|
||||
|
|
|
@ -243,7 +243,6 @@ namespace Flowframes.IO
|
|||
|
||||
if (key == Key.disablePreview) return WriteDefault(key, "True");
|
||||
if (key == Key.maxVidHeight) return WriteDefault(key, "2160");
|
||||
if (key == Key.delLogsOnStartup) return WriteDefault(key, "True");
|
||||
if (key == Key.clearLogOnInput) return WriteDefault(key, "True");
|
||||
if (key == Key.tempDirCustom) return WriteDefault(key, "D:/");
|
||||
if (key == Key.exportNamePattern) return WriteDefault(key, "[NAME]-[FACTOR]x-[AI]-[MODEL]-[FPS]fps");
|
||||
|
@ -322,7 +321,6 @@ namespace Flowframes.IO
|
|||
dainNcnnTilesize,
|
||||
dedupMode,
|
||||
dedupThresh,
|
||||
delLogsOnStartup,
|
||||
disablePreview,
|
||||
dupeScanDebug,
|
||||
enableLoop,
|
||||
|
|
|
@ -950,5 +950,12 @@ namespace Flowframes.IO
|
|||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static string[] GetUniqueExtensions(string path, bool recursive = false)
|
||||
{
|
||||
FileInfo[] fileInfos = GetFileInfosSorted(path, recursive);
|
||||
List<string> exts = fileInfos.Select(x => x.Extension).ToList();
|
||||
return exts.Select(x => x).Distinct().ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ namespace Flowframes
|
|||
currentSettings.RefreshAlpha();
|
||||
currentSettings.RefreshExtensions(InterpSettings.FrameType.Import);
|
||||
|
||||
if (Config.GetBool(Config.Key.scnDetect))
|
||||
if (Config.GetBool(Config.Key.scnDetect) && !currentSettings.ai.Piped)
|
||||
{
|
||||
Program.mainForm.SetStatus("Extracting scenes from video...");
|
||||
await FfmpegExtract.ExtractSceneChanges(currentSettings.inPath, Path.Combine(currentSettings.tempFolder, Paths.scenesDir), currentSettings.inFpsDetected, currentSettings.inputIsFrames, currentSettings.framesExt);
|
||||
|
|
|
@ -159,18 +159,19 @@ namespace Flowframes
|
|||
|
||||
public static async Task<int> GetFrameCountAsync(string inputFile)
|
||||
{
|
||||
Logger.Log($"GetFrameCountAsync('{inputFile}') - Trying ffprobe packet counting first (fastest).", true, false, "ffmpeg");
|
||||
Logger.Log($"GetFrameCountAsync - Trying ffprobe packet counting first (fastest).", true, false, "ffmpeg");
|
||||
int frames = await ReadFrameCountFfprobePacketCount(inputFile); // Try reading frame count with ffprobe packet counting
|
||||
if (frames > 0) return frames;
|
||||
|
||||
Logger.Log($"GetFrameCountAsync('{inputFile}') - Trying ffprobe decoding now.", true, false, "ffmpeg");
|
||||
Logger.Log($"GetFrameCountAsync - Trying ffmpeg demuxing.", true, false, "ffmpeg");
|
||||
frames = await ReadFrameCountFfmpegAsync(inputFile); // Try reading frame count with ffmpeg
|
||||
if (frames > 0) return frames;
|
||||
|
||||
Logger.Log($"GetFrameCountAsync - Trying ffprobe demuxing.", true, false, "ffmpeg");
|
||||
frames = await ReadFrameCountFfprobe(inputFile); // Try reading frame count with ffprobe decoding
|
||||
if (frames > 0) return frames;
|
||||
|
||||
Logger.Log($"Failed to get frame count using ffprobe (frames = {frames}). Trying to read with ffmpeg.", true, false, "ffmpeg");
|
||||
frames = await ReadFrameCountFfmpegAsync(inputFile); // Try reading frame count with ffmpeg
|
||||
if (frames > 0) return frames;
|
||||
|
||||
|
||||
Logger.Log("Failed to get total frame count of video.", true);
|
||||
return 0;
|
||||
|
@ -218,8 +219,8 @@ namespace Flowframes
|
|||
|
||||
public static async Task<int> ReadFrameCountFfmpegAsync(string filePath)
|
||||
{
|
||||
string args = $" -loglevel panic -stats -i {filePath.Wrap()} -map 0:v:0 -c copy -f null - ";
|
||||
string info = await RunFfmpeg(args, LogMode.Hidden);
|
||||
string args = $"{filePath.GetConcStr()} -i {filePath.Wrap()} -map 0:v:0 -c copy -f null - ";
|
||||
string info = await RunFfmpeg(args, LogMode.Hidden, "panic");
|
||||
try
|
||||
{
|
||||
string[] lines = info.SplitIntoLines();
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace Flowframes.Media
|
|||
|
||||
if (inputIsFrames)
|
||||
{
|
||||
string concatFile = Path.Combine(Paths.GetDataPath(), "png-scndetect-concat-temp.ini");
|
||||
string concatFile = Path.Combine(Paths.GetSessionDataPath(), "png-scndetect-concat-temp.ini");
|
||||
FfmpegUtils.CreateConcatFile(inPath, concatFile, Filetypes.imagesInterpCompat.ToList());
|
||||
inArg = $"-f concat -safe 0 -i {concatFile.Wrap()}";
|
||||
}
|
||||
|
@ -212,7 +212,7 @@ namespace Flowframes.Media
|
|||
if (showLog) Logger.Log($"Importing images from {new DirectoryInfo(inPath).Name}...");
|
||||
Logger.Log($"ImportImages() - Alpha: {alpha} - Size: {size} - Format: {format}", true, false, "ffmpeg");
|
||||
IoUtils.CreateDir(outPath);
|
||||
string concatFile = Path.Combine(Paths.GetDataPath(), "import-concat-temp.ini");
|
||||
string concatFile = Path.Combine(Paths.GetSessionDataPath(), "import-concat-temp.ini");
|
||||
FfmpegUtils.CreateConcatFile(inPath, concatFile, Filetypes.imagesInterpCompat.ToList());
|
||||
|
||||
string inArg = $"-f concat -safe 0 -i {concatFile.Wrap()}";
|
||||
|
|
|
@ -11,6 +11,11 @@ namespace Flowframes.Media
|
|||
{
|
||||
private static Dictionary<QueryInfo, int> cache = new Dictionary<QueryInfo, int>();
|
||||
|
||||
public static async Task<int> GetFrameCountAsync(MediaFile mf, int retryCount = 3)
|
||||
{
|
||||
return await GetFrameCountAsync(mf.SourcePath, retryCount);
|
||||
}
|
||||
|
||||
public static async Task<int> GetFrameCountAsync(string path, int retryCount = 3)
|
||||
{
|
||||
Logger.Log($"Getting frame count ({path})", true);
|
||||
|
|
|
@ -148,12 +148,14 @@ namespace Flowframes.Os
|
|||
|
||||
public static async Task RunRifeCuda(string framesPath, float interpFactor, string mdl)
|
||||
{
|
||||
AI ai = Implementations.rifeCuda;
|
||||
|
||||
if (Interpolate.currentlyUsingAutoEnc) // Ensure AutoEnc is not paused
|
||||
AutoEncode.paused = false;
|
||||
|
||||
try
|
||||
{
|
||||
string rifeDir = Path.Combine(Paths.GetPkgPath(), Implementations.rifeCuda.PkgDir);
|
||||
string rifeDir = Path.Combine(Paths.GetPkgPath(), ai.PkgDir);
|
||||
string script = "rife.py";
|
||||
|
||||
if (!File.Exists(Path.Combine(rifeDir, script)))
|
||||
|
@ -176,11 +178,11 @@ namespace Flowframes.Os
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Log("Error running RIFE-CUDA: " + e.Message);
|
||||
Logger.Log($"Error running {ai.FriendlyName}: {e.Message}");
|
||||
Logger.Log("Stack Trace: " + e.StackTrace, true);
|
||||
}
|
||||
|
||||
await AiFinished("RIFE");
|
||||
await AiFinished(ai.NameShort);
|
||||
}
|
||||
|
||||
public static async Task RunRifeCudaProcess(string inPath, string outDir, string script, float interpFactor, string mdl)
|
||||
|
@ -221,12 +223,14 @@ namespace Flowframes.Os
|
|||
|
||||
public static async Task RunFlavrCuda(string framesPath, float interpFactor, string mdl)
|
||||
{
|
||||
AI ai = Implementations.flavrCuda;
|
||||
|
||||
if (Interpolate.currentlyUsingAutoEnc) // Ensure AutoEnc is not paused
|
||||
AutoEncode.paused = false;
|
||||
|
||||
try
|
||||
{
|
||||
string flavDir = Path.Combine(Paths.GetPkgPath(), Implementations.flavrCuda.PkgDir);
|
||||
string flavDir = Path.Combine(Paths.GetPkgPath(), ai.PkgDir);
|
||||
string script = "flavr.py";
|
||||
|
||||
if (!File.Exists(Path.Combine(flavDir, script)))
|
||||
|
@ -239,11 +243,11 @@ namespace Flowframes.Os
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Log("Error running FLAVR-CUDA: " + e.Message);
|
||||
Logger.Log($"Error running {ai.FriendlyName}: {e.Message}");
|
||||
Logger.Log("Stack Trace: " + e.StackTrace, true);
|
||||
}
|
||||
|
||||
await AiFinished("FLAVR");
|
||||
await AiFinished(ai.NameShort);
|
||||
}
|
||||
|
||||
public static async Task RunFlavrCudaProcess(string inPath, string outDir, string script, float interpFactor, string mdl)
|
||||
|
@ -279,23 +283,23 @@ namespace Flowframes.Os
|
|||
|
||||
public static async Task RunRifeNcnn(string framesPath, string outPath, float factor, string mdl)
|
||||
{
|
||||
AI ai = Implementations.rifeNcnn;
|
||||
processTimeMulti.Restart();
|
||||
|
||||
try
|
||||
{
|
||||
Logger.Log($"Running RIFE (NCNN){(await InterpolateUtils.UseUhd() ? " (UHD Mode)" : "")}...", false);
|
||||
|
||||
//await RunRifeNcnnMulti(framesPath, outPath, factor, mdl);
|
||||
await RunRifeNcnnProcess(framesPath, factor, outPath, mdl);
|
||||
await NcnnUtils.DeleteNcnnDupes(outPath, factor);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Log("Error running RIFE-NCNN: " + e.Message);
|
||||
Logger.Log($"Error running {ai.FriendlyName}: {e.Message}");
|
||||
Logger.Log("Stack Trace: " + e.StackTrace, true);
|
||||
}
|
||||
|
||||
await AiFinished("RIFE");
|
||||
await AiFinished(ai.NameShort);
|
||||
}
|
||||
|
||||
static async Task RunRifeNcnnProcess(string inPath, float factor, string outPath, string mdl)
|
||||
|
@ -335,6 +339,7 @@ namespace Flowframes.Os
|
|||
|
||||
public static async Task RunRifeNcnnVs(string framesPath, string outPath, float factor, string mdl, bool rt = false)
|
||||
{
|
||||
AI ai = Implementations.rifeNcnnVs;
|
||||
processTimeMulti.Restart();
|
||||
|
||||
try
|
||||
|
@ -346,11 +351,11 @@ namespace Flowframes.Os
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Log("Error running RIFE-NCNN-VS: " + e.Message);
|
||||
Logger.Log($"Error running {ai.FriendlyName}: {e.Message}");
|
||||
Logger.Log("Stack Trace: " + e.StackTrace, true);
|
||||
}
|
||||
|
||||
await AiFinished("RIFE", true);
|
||||
await AiFinished(ai.NameShort);
|
||||
}
|
||||
|
||||
static async Task RunRifeNcnnVsProcess(string inPath, float factor, string outPath, string mdl, Size res, bool rt = false)
|
||||
|
@ -418,6 +423,8 @@ namespace Flowframes.Os
|
|||
|
||||
public static async Task RunDainNcnn(string framesPath, string outPath, float factor, string mdl, int tilesize)
|
||||
{
|
||||
AI ai = Implementations.dainNcnn;
|
||||
|
||||
if (Interpolate.currentlyUsingAutoEnc) // Ensure AutoEnc is not paused
|
||||
AutoEncode.paused = false;
|
||||
|
||||
|
@ -428,11 +435,11 @@ namespace Flowframes.Os
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Log("Error running DAIN-NCNN: " + e.Message);
|
||||
Logger.Log($"Error running {ai.FriendlyName}: {e.Message}");
|
||||
Logger.Log("Stack Trace: " + e.StackTrace, true);
|
||||
}
|
||||
|
||||
await AiFinished("DAIN");
|
||||
await AiFinished(ai.NameShort);
|
||||
}
|
||||
|
||||
public static async Task RunDainNcnnProcess(string framesPath, string outPath, float factor, string mdl, int tilesize)
|
||||
|
@ -471,6 +478,8 @@ namespace Flowframes.Os
|
|||
|
||||
public static async Task RunXvfiCuda(string framesPath, float interpFactor, string mdl)
|
||||
{
|
||||
AI ai = Implementations.xvfiCuda;
|
||||
|
||||
if (Interpolate.currentlyUsingAutoEnc) // Ensure AutoEnc is not paused
|
||||
AutoEncode.paused = false;
|
||||
|
||||
|
@ -489,11 +498,11 @@ namespace Flowframes.Os
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Log("Error running XVFI-CUDA: " + e.Message);
|
||||
Logger.Log($"Error running {ai.FriendlyName}: {e.Message}");
|
||||
Logger.Log("Stack Trace: " + e.StackTrace, true);
|
||||
}
|
||||
|
||||
await AiFinished("XVFI");
|
||||
await AiFinished(ai.NameShort);
|
||||
}
|
||||
|
||||
public static async Task RunXvfiCudaProcess(string inPath, string outDir, string script, float interpFactor, string mdlDir)
|
||||
|
@ -533,6 +542,8 @@ namespace Flowframes.Os
|
|||
|
||||
public static async Task RunIfrnetNcnn(string framesPath, string outPath, float factor, string mdl)
|
||||
{
|
||||
AI ai = Implementations.ifrnetNcnn;
|
||||
|
||||
processTimeMulti.Restart();
|
||||
|
||||
try
|
||||
|
@ -544,11 +555,11 @@ namespace Flowframes.Os
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Log("Error running IFRNet-NCNN: " + e.Message);
|
||||
Logger.Log($"Error running {ai.FriendlyName}: {e.Message}");
|
||||
Logger.Log("Stack Trace: " + e.StackTrace, true);
|
||||
}
|
||||
|
||||
await AiFinished("IFRNet");
|
||||
await AiFinished(ai.NameShort);
|
||||
}
|
||||
|
||||
static async Task RunIfrnetNcnnProcess(string inPath, float factor, string outPath, string mdl)
|
||||
|
|
|
@ -34,10 +34,9 @@ namespace Flowframes
|
|||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Paths.Init();
|
||||
Config.Init();
|
||||
|
||||
if (Config.GetBool(Config.Key.delLogsOnStartup))
|
||||
IoUtils.DeleteContentsOfDir(Paths.GetLogPath()); // Clear out older logs from previous session
|
||||
Cleanup();
|
||||
|
||||
ServicePointManager.Expect100Continue = true;
|
||||
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
|
||||
|
@ -86,6 +85,49 @@ namespace Flowframes
|
|||
Clipboard.SetText(text);
|
||||
}
|
||||
|
||||
public static void Cleanup()
|
||||
{
|
||||
int keepLogsDays = 4;
|
||||
int keepSessionDataDays = 4;
|
||||
|
||||
try
|
||||
{
|
||||
foreach (DirectoryInfo dir in new DirectoryInfo(Paths.GetLogPath(true)).GetDirectories())
|
||||
{
|
||||
string[] split = dir.Name.Split('-');
|
||||
int daysOld = (DateTime.Now - new DateTime(split[0].GetInt(), split[1].GetInt(), split[2].GetInt())).Days;
|
||||
int fileCount = dir.GetFiles("*", SearchOption.AllDirectories).Length;
|
||||
|
||||
if (daysOld > keepLogsDays || fileCount < 1) // keep logs for 4 days
|
||||
{
|
||||
Logger.Log($"Cleanup: Log folder {dir.Name} is {daysOld} days old and has {fileCount} files - Will Delete", true);
|
||||
IoUtils.TryDeleteIfExists(dir.FullName);
|
||||
}
|
||||
}
|
||||
|
||||
IoUtils.DeleteContentsOfDir(Paths.GetSessionDataPath()); // Clear this session's temp files...
|
||||
|
||||
foreach (DirectoryInfo dir in new DirectoryInfo(Paths.GetSessionsPath()).GetDirectories())
|
||||
{
|
||||
string[] split = dir.Name.Split('-');
|
||||
int daysOld = (DateTime.Now - new DateTime(split[0].GetInt(), split[1].GetInt(), split[2].GetInt())).Days;
|
||||
int fileCount = dir.GetFiles("*", SearchOption.AllDirectories).Length;
|
||||
|
||||
if (daysOld > keepSessionDataDays || fileCount < 1) // keep temp files for 2 days
|
||||
{
|
||||
Logger.Log($"Cleanup: Session folder {dir.Name} is {daysOld} days old and has {fileCount} files - Will Delete", true);
|
||||
IoUtils.TryDeleteIfExists(dir.FullName);
|
||||
}
|
||||
}
|
||||
|
||||
IoUtils.GetFilesSorted(Paths.GetPkgPath(), false, "*.log*").ToList().ForEach(x => IoUtils.TryDeleteIfExists(x));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Log($"Cleanup Error: {e.Message}\n{e.StackTrace}");
|
||||
}
|
||||
}
|
||||
|
||||
static async Task DiskSpaceCheckLoop()
|
||||
{
|
||||
while (true)
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace Flowframes.Ui
|
|||
Program.mainForm.currInDuration = Interpolate.currentMediaFile.DurationMs;
|
||||
Program.mainForm.currInDurationCut = Program.mainForm.currInDuration;
|
||||
string fpsStr = "Not Found";
|
||||
Fraction fps = (await IoUtils.GetFpsFolderOrVideo(path));
|
||||
Fraction fps = Interpolate.currentMediaFile.VideoStreams.Count > 0 ? Interpolate.currentMediaFile.VideoStreams[0].Rate : new Fraction();
|
||||
Program.mainForm.currInFpsDetected = fps;
|
||||
fpsInTbox.Text = fps.GetString();
|
||||
|
||||
|
@ -136,7 +136,7 @@ namespace Flowframes.Ui
|
|||
|
||||
public static async Task<Image> GetThumbnail (string path)
|
||||
{
|
||||
string imgOnDisk = Path.Combine(Paths.GetDataPath(), "thumb-temp.jpg");
|
||||
string imgOnDisk = Path.Combine(Paths.GetSessionDataPath(), "thumb-temp.jpg");
|
||||
|
||||
try
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue