mirror of
https://github.com/n00mkrad/flowframes.git
synced 2025-12-23 03:39:26 +01:00
Fix various issues with image sequence inputs & batch processing
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
using Flowframes.Data.Streams;
|
using Flowframes.Data.Streams;
|
||||||
using Flowframes.Forms;
|
using Flowframes.Forms;
|
||||||
using Flowframes.IO;
|
using Flowframes.IO;
|
||||||
|
using Flowframes.Main;
|
||||||
using Flowframes.Media;
|
using Flowframes.Media;
|
||||||
using Flowframes.MiscUtils;
|
using Flowframes.MiscUtils;
|
||||||
using System;
|
using System;
|
||||||
@@ -56,11 +57,7 @@ namespace Flowframes.Data
|
|||||||
Format = "Folder";
|
Format = "Folder";
|
||||||
|
|
||||||
if (requestFpsInputIfUnset && InputRate == null)
|
if (requestFpsInputIfUnset && InputRate == null)
|
||||||
{
|
InputRate = InterpolateUtils.AskForFramerate(Name);
|
||||||
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
|
else
|
||||||
{
|
{
|
||||||
@@ -105,7 +102,7 @@ namespace Flowframes.Data
|
|||||||
await InitializeSequence();
|
await InitializeSequence();
|
||||||
|
|
||||||
await LoadFormatInfo(ImportPath);
|
await LoadFormatInfo(ImportPath);
|
||||||
AllStreams = await FfmpegUtils.GetStreams(ImportPath, progressBar, StreamCount, (Fraction)InputRate, countFrames);
|
AllStreams = await FfmpegUtils.GetStreams(ImportPath, progressBar, StreamCount, InputRate, countFrames);
|
||||||
VideoStreams = AllStreams.Where(x => x.Type == Stream.StreamType.Video).Select(x => (VideoStream)x).ToList();
|
VideoStreams = AllStreams.Where(x => x.Type == Stream.StreamType.Video).Select(x => (VideoStream)x).ToList();
|
||||||
AudioStreams = AllStreams.Where(x => x.Type == Stream.StreamType.Audio).Select(x => (AudioStream)x).ToList();
|
AudioStreams = AllStreams.Where(x => x.Type == Stream.StreamType.Audio).Select(x => (AudioStream)x).ToList();
|
||||||
SubtitleStreams = AllStreams.Where(x => x.Type == Stream.StreamType.Subtitle).Select(x => (SubtitleStream)x).ToList();
|
SubtitleStreams = AllStreams.Where(x => x.Type == Stream.StreamType.Subtitle).Select(x => (SubtitleStream)x).ToList();
|
||||||
|
|||||||
@@ -371,6 +371,9 @@
|
|||||||
<Compile Include="Forms\BigPreviewForm.Designer.cs">
|
<Compile Include="Forms\BigPreviewForm.Designer.cs">
|
||||||
<DependentUpon>BigPreviewForm.cs</DependentUpon>
|
<DependentUpon>BigPreviewForm.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Forms\CustomForm.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Forms\DebugForm.cs">
|
<Compile Include="Forms\DebugForm.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|||||||
32
Code/Form1.Designer.cs
generated
32
Code/Form1.Designer.cs
generated
@@ -94,6 +94,7 @@
|
|||||||
this.comboxOutputFormat = new System.Windows.Forms.ComboBox();
|
this.comboxOutputFormat = new System.Windows.Forms.ComboBox();
|
||||||
this.comboxOutputEncoder = new System.Windows.Forms.ComboBox();
|
this.comboxOutputEncoder = new System.Windows.Forms.ComboBox();
|
||||||
this.comboxOutputQuality = new System.Windows.Forms.ComboBox();
|
this.comboxOutputQuality = new System.Windows.Forms.ComboBox();
|
||||||
|
this.textboxOutputQualityCust = new System.Windows.Forms.TextBox();
|
||||||
this.comboxOutputColors = new System.Windows.Forms.ComboBox();
|
this.comboxOutputColors = new System.Windows.Forms.ComboBox();
|
||||||
this.aiInfoBtn = new HTAlt.WinForms.HTButton();
|
this.aiInfoBtn = new HTAlt.WinForms.HTButton();
|
||||||
this.outSpeedCombox = new System.Windows.Forms.ComboBox();
|
this.outSpeedCombox = new System.Windows.Forms.ComboBox();
|
||||||
@@ -143,7 +144,6 @@
|
|||||||
this.cancelBtn = new System.Windows.Forms.Button();
|
this.cancelBtn = new System.Windows.Forms.Button();
|
||||||
this.menuStripQueue = new System.Windows.Forms.ContextMenuStrip(this.components);
|
this.menuStripQueue = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||||
this.addCurrentConfigurationToQueueToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.addCurrentConfigurationToQueueToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.textboxOutputQualityCust = new System.Windows.Forms.TextBox();
|
|
||||||
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();
|
||||||
@@ -962,7 +962,7 @@
|
|||||||
this.flowLayoutPanel1.Controls.Add(this.comboxOutputColors);
|
this.flowLayoutPanel1.Controls.Add(this.comboxOutputColors);
|
||||||
this.flowLayoutPanel1.Location = new System.Drawing.Point(281, 157);
|
this.flowLayoutPanel1.Location = new System.Drawing.Point(281, 157);
|
||||||
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
|
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
|
||||||
this.flowLayoutPanel1.Size = new System.Drawing.Size(508, 23);
|
this.flowLayoutPanel1.Size = new System.Drawing.Size(614, 23);
|
||||||
this.flowLayoutPanel1.TabIndex = 46;
|
this.flowLayoutPanel1.TabIndex = 46;
|
||||||
//
|
//
|
||||||
// comboxOutputFormat
|
// comboxOutputFormat
|
||||||
@@ -1025,6 +1025,21 @@
|
|||||||
this.comboxOutputQuality.TabIndex = 48;
|
this.comboxOutputQuality.TabIndex = 48;
|
||||||
this.comboxOutputQuality.SelectedIndexChanged += new System.EventHandler(this.comboxOutputQuality_SelectedIndexChanged);
|
this.comboxOutputQuality.SelectedIndexChanged += new System.EventHandler(this.comboxOutputQuality_SelectedIndexChanged);
|
||||||
//
|
//
|
||||||
|
// textboxOutputQualityCust
|
||||||
|
//
|
||||||
|
this.textboxOutputQualityCust.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
||||||
|
this.textboxOutputQualityCust.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||||
|
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.MaxLength = 3;
|
||||||
|
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.Text = "24";
|
||||||
|
this.textboxOutputQualityCust.Visible = false;
|
||||||
|
//
|
||||||
// comboxOutputColors
|
// comboxOutputColors
|
||||||
//
|
//
|
||||||
this.comboxOutputColors.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
this.comboxOutputColors.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
||||||
@@ -1725,19 +1740,6 @@
|
|||||||
this.addCurrentConfigurationToQueueToolStripMenuItem.Text = "Add Current Configuration to Queue";
|
this.addCurrentConfigurationToQueueToolStripMenuItem.Text = "Add Current Configuration to Queue";
|
||||||
this.addCurrentConfigurationToQueueToolStripMenuItem.Click += new System.EventHandler(this.addCurrentConfigurationToQueueToolStripMenuItem_Click);
|
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
|
// Form1
|
||||||
//
|
//
|
||||||
this.AllowDrop = true;
|
this.AllowDrop = true;
|
||||||
|
|||||||
@@ -17,8 +17,6 @@ using Flowframes.MiscUtils;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using Flowframes.Media;
|
|
||||||
using Flowframes.Utilities;
|
|
||||||
|
|
||||||
#pragma warning disable IDE1006
|
#pragma warning disable IDE1006
|
||||||
|
|
||||||
@@ -249,6 +247,7 @@ namespace Flowframes
|
|||||||
{
|
{
|
||||||
inputTbox.Text = entry.inPath;
|
inputTbox.Text = entry.inPath;
|
||||||
MainUiFunctions.SetOutPath(outputTbox, entry.outPath);
|
MainUiFunctions.SetOutPath(outputTbox, entry.outPath);
|
||||||
|
fpsInTbox.Text = entry.inFps.ToString();
|
||||||
interpFactorCombox.Text = entry.interpFactor.ToString();
|
interpFactorCombox.Text = entry.interpFactor.ToString();
|
||||||
aiCombox.SelectedIndex = Implementations.NetworksAvailable.IndexOf(Implementations.NetworksAvailable.Where(x => x.NameInternal == entry.ai.NameInternal).FirstOrDefault());
|
aiCombox.SelectedIndex = Implementations.NetworksAvailable.IndexOf(Implementations.NetworksAvailable.Where(x => x.NameInternal == entry.ai.NameInternal).FirstOrDefault());
|
||||||
SetFormat(entry.outSettings.Format);
|
SetFormat(entry.outSettings.Format);
|
||||||
@@ -830,6 +829,8 @@ namespace Flowframes
|
|||||||
|
|
||||||
if (!cust)
|
if (!cust)
|
||||||
textboxOutputQualityCust.Text = "";
|
textboxOutputQualityCust.Text = "";
|
||||||
|
else
|
||||||
|
textboxOutputQualityCust.Focus();
|
||||||
|
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -158,6 +158,10 @@ namespace Flowframes.Forms
|
|||||||
|
|
||||||
current.inFpsDetected = await IoUtils.GetFpsFolderOrVideo(path);
|
current.inFpsDetected = await IoUtils.GetFpsFolderOrVideo(path);
|
||||||
current.inFps = current.inFpsDetected;
|
current.inFps = current.inFpsDetected;
|
||||||
|
|
||||||
|
if(current.inFps.GetFloat() <= 0)
|
||||||
|
current.inFps = InterpolateUtils.AskForFramerate(Name, false);
|
||||||
|
|
||||||
current.outFps = current.inFps * current.interpFactor;
|
current.outFps = current.inFps * current.interpFactor;
|
||||||
|
|
||||||
Program.batchQueue.Enqueue(current);
|
Program.batchQueue.Enqueue(current);
|
||||||
|
|||||||
64
Code/Forms/CustomForm.cs
Normal file
64
Code/Forms/CustomForm.cs
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
using Flowframes.Ui;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace Flowframes.Forms
|
||||||
|
{
|
||||||
|
public class CustomForm : Form
|
||||||
|
{
|
||||||
|
public Control FocusedControl { get { return this.GetControls().Where(c => c.Focused).FirstOrDefault(); } }
|
||||||
|
|
||||||
|
public bool AllowTextboxTab { get; set; } = true;
|
||||||
|
public bool AllowEscClose { get; set; } = true;
|
||||||
|
|
||||||
|
private List<Control> _tabOrderedControls;
|
||||||
|
|
||||||
|
public void TabOrderInit(List<Control> tabOrderedControls, int defaultFocusIndex = 0)
|
||||||
|
{
|
||||||
|
_tabOrderedControls = tabOrderedControls;
|
||||||
|
this.GetControls().ForEach(control => control.TabStop = false);
|
||||||
|
|
||||||
|
if (defaultFocusIndex >= 0 && tabOrderedControls != null && tabOrderedControls.Count > 0)
|
||||||
|
tabOrderedControls[defaultFocusIndex].Focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void TabOrderNext()
|
||||||
|
{
|
||||||
|
if (_tabOrderedControls == null || _tabOrderedControls.Count <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var focused = FocusedControl;
|
||||||
|
|
||||||
|
if (_tabOrderedControls.Contains(focused))
|
||||||
|
{
|
||||||
|
int index = _tabOrderedControls.IndexOf(focused);
|
||||||
|
Control next = null;
|
||||||
|
|
||||||
|
while (_tabOrderedControls.Where(x => x.Visible && x.Enabled).Any() && (next == null || !next.Visible || !next.Enabled))
|
||||||
|
{
|
||||||
|
index++;
|
||||||
|
next = _tabOrderedControls.ElementAt(index >= _tabOrderedControls.Count ? 0 : index);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (next != null)
|
||||||
|
next.Focus();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_tabOrderedControls.First().Focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
|
||||||
|
{
|
||||||
|
if (keyData == Keys.Escape && AllowEscClose)
|
||||||
|
Close();
|
||||||
|
|
||||||
|
if (keyData == Keys.Tab && !(FocusedControl is TextBox && AllowTextboxTab))
|
||||||
|
TabOrderNext();
|
||||||
|
|
||||||
|
return base.ProcessCmdKey(ref msg, keyData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -392,12 +392,16 @@ namespace Flowframes.IO
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (path.IsConcatFile())
|
||||||
|
path = ReadFileFirstLine(path).Split('\'')[1].Split('\'')[0];
|
||||||
|
|
||||||
size = FfmpegCommands.GetSize(path);
|
size = FfmpegCommands.GetSize(path);
|
||||||
Logger.Log($"Detected video size of {Path.GetFileName(path)} as {size.Width}x{size.Height}", true);
|
Logger.Log($"Detected video size of {Path.GetFileName(path)} as {size.Width}x{size.Height}", true);
|
||||||
}
|
}
|
||||||
catch
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logger.Log("Failed to read video size!");
|
Logger.Log("Failed to read video size!");
|
||||||
|
Logger.Log(ex.ToString(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
@@ -892,6 +896,19 @@ namespace Flowframes.IO
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static long GetPathSize(string path)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
bool isFile = File.Exists(path);
|
||||||
|
return isFile ? GetFilesize(path) : GetDirSize(path, true);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static long GetFilesize(string path)
|
public static long GetFilesize(string path)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -960,5 +977,32 @@ namespace Flowframes.IO
|
|||||||
List<string> exts = fileInfos.Select(x => x.Extension).ToList();
|
List<string> exts = fileInfos.Select(x => x.Extension).ToList();
|
||||||
return exts.Select(x => x).Distinct().ToArray();
|
return exts.Select(x => x).Distinct().ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string ReadFile(string path)
|
||||||
|
{
|
||||||
|
using (var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||||
|
{
|
||||||
|
using (var streamReader = new StreamReader(fileStream))
|
||||||
|
{
|
||||||
|
return streamReader.ReadToEnd();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string[] ReadFileLines(string path)
|
||||||
|
{
|
||||||
|
return ReadFile(path).SplitIntoLines();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string ReadFileFirstLine(string path)
|
||||||
|
{
|
||||||
|
using (var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||||
|
{
|
||||||
|
using (var streamReader = new StreamReader(fileStream))
|
||||||
|
{
|
||||||
|
return streamReader.ReadLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,15 +81,13 @@ namespace Flowframes.Main
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string fname = Path.GetFileName(entry.inPath);
|
MediaFile mf = new MediaFile(entry.inPath, false);
|
||||||
if (IoUtils.IsPathDirectory(entry.inPath)) fname = Path.GetDirectoryName(entry.inPath);
|
mf.InputRate = entry.inFps;
|
||||||
Logger.Log($"Queue: Processing {fname} ({entry.interpFactor}x {entry.ai.NameShort}).");
|
|
||||||
|
|
||||||
MediaFile mf = new MediaFile(entry.inPath);
|
|
||||||
await mf.Initialize();
|
await mf.Initialize();
|
||||||
|
|
||||||
Interpolate.currentMediaFile = mf;
|
Interpolate.currentMediaFile = mf;
|
||||||
|
|
||||||
|
Logger.Log($"Queue: Processing {mf.Name} ({entry.interpFactor}x {entry.ai.NameShort}).");
|
||||||
|
|
||||||
Program.mainForm.LoadBatchEntry(entry); // Load entry into GUI
|
Program.mainForm.LoadBatchEntry(entry); // Load entry into GUI
|
||||||
Interpolate.currentSettings = entry;
|
Interpolate.currentSettings = entry;
|
||||||
Program.mainForm.runBtn_Click(null, null);
|
Program.mainForm.runBtn_Click(null, null);
|
||||||
@@ -99,7 +97,7 @@ namespace Flowframes.Main
|
|||||||
|
|
||||||
Program.batchQueue.Dequeue();
|
Program.batchQueue.Dequeue();
|
||||||
Program.mainForm.SetWorking(false);
|
Program.mainForm.SetWorking(false);
|
||||||
Logger.Log($"Queue: Done processing {fname} ({entry.interpFactor}x {entry.ai.NameShort}).");
|
Logger.Log($"Queue: Done processing {mf.Name} ({entry.interpFactor}x {entry.ai.NameShort}).");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetBusy(bool state)
|
static void SetBusy(bool state)
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ using System.Windows.Forms;
|
|||||||
using I = Flowframes.Interpolate;
|
using I = Flowframes.Interpolate;
|
||||||
using Padding = Flowframes.Data.Padding;
|
using Padding = Flowframes.Data.Padding;
|
||||||
using static Flowframes.Magick.Dedupe;
|
using static Flowframes.Magick.Dedupe;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace Flowframes.Main
|
namespace Flowframes.Main
|
||||||
{
|
{
|
||||||
@@ -362,5 +363,13 @@ namespace Flowframes.Main
|
|||||||
else
|
else
|
||||||
return factor.RoundToInt();
|
return factor.RoundToInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Fraction AskForFramerate (string mediaName, bool isImageSequence = true)
|
||||||
|
{
|
||||||
|
string text = $"Please enter a frame rate to use for{(isImageSequence ? " the image sequence" : "")} '{mediaName.Trunc(80)}'.";
|
||||||
|
PromptForm form = new PromptForm("Enter Frame Rate", text, "15");
|
||||||
|
form.ShowDialog();
|
||||||
|
return new Fraction(form.EnteredText);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ using System.Drawing;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Win32Interop.Enums;
|
|
||||||
using static Flowframes.Data.Enums.Encoding;
|
using static Flowframes.Data.Enums.Encoding;
|
||||||
using static Flowframes.Media.GetVideoInfo;
|
using static Flowframes.Media.GetVideoInfo;
|
||||||
using Stream = Flowframes.Data.Streams.Stream;
|
using Stream = Flowframes.Data.Streams.Stream;
|
||||||
@@ -31,12 +30,15 @@ namespace Flowframes.Media
|
|||||||
return output.SplitIntoLines().Where(x => x.MatchesWildcard("*Stream #0:*: *: *")).Count();
|
return output.SplitIntoLines().Where(x => x.MatchesWildcard("*Stream #0:*: *: *")).Count();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<List<Stream>> GetStreams(string path, bool progressBar, int streamCount, Fraction defaultFps, bool countFrames)
|
public static async Task<List<Stream>> GetStreams(string path, bool progressBar, int streamCount, Fraction? defaultFps, bool countFrames)
|
||||||
{
|
{
|
||||||
List<Stream> streamList = new List<Stream>();
|
List<Stream> streamList = new List<Stream>();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (defaultFps == null)
|
||||||
|
defaultFps = new Fraction(30, 1);
|
||||||
|
|
||||||
string output = await GetFfmpegInfoAsync(path, "Stream #0:");
|
string output = await GetFfmpegInfoAsync(path, "Stream #0:");
|
||||||
string[] streams = output.SplitIntoLines().Where(x => x.MatchesWildcard("*Stream #0:*: *: *")).ToArray();
|
string[] streams = output.SplitIntoLines().Where(x => x.MatchesWildcard("*Stream #0:*: *: *")).ToArray();
|
||||||
|
|
||||||
@@ -61,7 +63,7 @@ namespace Flowframes.Media
|
|||||||
Size res = await GetMediaResolutionCached.GetSizeAsync(path);
|
Size res = await GetMediaResolutionCached.GetSizeAsync(path);
|
||||||
Size sar = SizeFromString(await GetFfprobeInfoAsync(path, showStreams, "sample_aspect_ratio", idx));
|
Size sar = SizeFromString(await GetFfprobeInfoAsync(path, showStreams, "sample_aspect_ratio", idx));
|
||||||
Size dar = SizeFromString(await GetFfprobeInfoAsync(path, showStreams, "display_aspect_ratio", idx));
|
Size dar = SizeFromString(await GetFfprobeInfoAsync(path, showStreams, "display_aspect_ratio", idx));
|
||||||
Fraction fps = path.IsConcatFile() ? defaultFps : await IoUtils.GetVideoFramerate(path);
|
Fraction fps = path.IsConcatFile() ? (Fraction)defaultFps : await IoUtils.GetVideoFramerate(path);
|
||||||
int frameCount = countFrames ? await GetFrameCountCached.GetFrameCountAsync(path) : 0;
|
int frameCount = countFrames ? await GetFrameCountCached.GetFrameCountAsync(path) : 0;
|
||||||
VideoStream vStream = new VideoStream(lang, title, codec, codecLong, pixFmt, kbits, res, sar, dar, fps, frameCount);
|
VideoStream vStream = new VideoStream(lang, title, codec, codecLong, pixFmt, kbits, res, sar, dar, fps, frameCount);
|
||||||
vStream.Index = idx;
|
vStream.Index = idx;
|
||||||
@@ -457,25 +459,14 @@ namespace Flowframes.Media
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
Directory.CreateDirectory(outputPath.GetParentDir());
|
Directory.CreateDirectory(outputPath.GetParentDir());
|
||||||
|
validExtensions = validExtensions ?? new List<string>();
|
||||||
if (validExtensions == null)
|
validExtensions = validExtensions.Select(x => x.Remove(".").Lower()).ToList(); // Ignore "." in extensions
|
||||||
validExtensions = new List<string>();
|
var validFiles = IoUtils.GetFilesSorted(inputFilesDir).Where(f => validExtensions.Contains(Path.GetExtension(f).Replace(".", "").Lower()));
|
||||||
|
string fileContent = string.Join(Environment.NewLine, validFiles.Select(f => $"file '{f.Replace(@"\", "/")}'"));
|
||||||
validExtensions = validExtensions.Select(x => x.Remove(".").ToLowerInvariant()).ToList(); // Ignore "." in extensions
|
|
||||||
string concatFileContent = "";
|
|
||||||
string[] files = IoUtils.GetFilesSorted(inputFilesDir);
|
|
||||||
int fileCount = 0;
|
|
||||||
|
|
||||||
IoUtils.TryDeleteIfExists(outputPath);
|
IoUtils.TryDeleteIfExists(outputPath);
|
||||||
StreamWriter concatFile = new StreamWriter(outputPath, append: true);
|
File.WriteAllText(outputPath, fileContent);
|
||||||
|
|
||||||
foreach (string file in files.Where(x => validExtensions.Contains(Path.GetExtension(x).Replace(".", "").ToLower())))
|
return validFiles.Count();
|
||||||
{
|
|
||||||
fileCount++;
|
|
||||||
concatFile.WriteLine($"file '{file.Replace(@"\", "/")}'\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
return fileCount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Size SizeFromString(string str, char delimiter = ':')
|
public static Size SizeFromString(string str, char delimiter = ':')
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Flowframes.Data;
|
using Flowframes.Data;
|
||||||
using Flowframes.IO;
|
using Flowframes.IO;
|
||||||
@@ -20,7 +21,7 @@ namespace Flowframes.Media
|
|||||||
{
|
{
|
||||||
Logger.Log($"Getting frame count ({path})", true);
|
Logger.Log($"Getting frame count ({path})", true);
|
||||||
|
|
||||||
long filesize = IoUtils.GetFilesize(path);
|
long filesize = IoUtils.GetPathSize(path);
|
||||||
QueryInfo hash = new QueryInfo(path, filesize);
|
QueryInfo hash = new QueryInfo(path, filesize);
|
||||||
|
|
||||||
if (filesize > 0 && CacheContains(hash))
|
if (filesize > 0 && CacheContains(hash))
|
||||||
@@ -36,11 +37,22 @@ namespace Flowframes.Media
|
|||||||
int frameCount;
|
int frameCount;
|
||||||
|
|
||||||
if (IoUtils.IsPathDirectory(path))
|
if (IoUtils.IsPathDirectory(path))
|
||||||
frameCount = IoUtils.GetAmountOfFiles(path, false);
|
{
|
||||||
|
frameCount = IoUtils.GetAmountOfFiles(path, false); // Count frames based on image file amount
|
||||||
|
}
|
||||||
else
|
else
|
||||||
frameCount = await FfmpegCommands.GetFrameCountAsync(path);
|
{
|
||||||
|
if (path.IsConcatFile())
|
||||||
|
{
|
||||||
|
var lines = IoUtils.ReadFileLines(path);
|
||||||
|
var filtered = lines.Where(l => l.StartsWith("file '"));
|
||||||
|
frameCount = filtered.Count(); // Count frames from concat file
|
||||||
|
}
|
||||||
|
else
|
||||||
|
frameCount = await FfmpegCommands.GetFrameCountAsync(path); // Count frames from video stream
|
||||||
|
}
|
||||||
|
|
||||||
if(frameCount > 0)
|
if (frameCount > 0)
|
||||||
{
|
{
|
||||||
Logger.Log($"Adding hash with value {frameCount} to cache.", true);
|
Logger.Log($"Adding hash with value {frameCount} to cache.", true);
|
||||||
cache.Add(hash, frameCount);
|
cache.Add(hash, frameCount);
|
||||||
@@ -80,7 +92,7 @@ namespace Flowframes.Media
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Clear ()
|
public static void Clear()
|
||||||
{
|
{
|
||||||
cache.Clear();
|
cache.Clear();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Flowframes.Data;
|
using Flowframes.Data;
|
||||||
@@ -15,7 +14,7 @@ namespace Flowframes.Media
|
|||||||
{
|
{
|
||||||
Logger.Log($"Getting media resolution ({path})", true);
|
Logger.Log($"Getting media resolution ({path})", true);
|
||||||
|
|
||||||
long filesize = IoUtils.GetFilesize(path);
|
long filesize = IoUtils.GetPathSize(path);
|
||||||
QueryInfo hash = new QueryInfo(path, filesize);
|
QueryInfo hash = new QueryInfo(path, filesize);
|
||||||
|
|
||||||
if (filesize > 0 && CacheContains(hash))
|
if (filesize > 0 && CacheContains(hash))
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ namespace Flowframes.Media
|
|||||||
|
|
||||||
static async Task<string> GetOutputCached(string path, Process process, bool noCache = false)
|
static async Task<string> GetOutputCached(string path, Process process, bool noCache = false)
|
||||||
{
|
{
|
||||||
long filesize = IoUtils.GetFilesize(path);
|
long filesize = IoUtils.GetPathSize(path);
|
||||||
QueryInfo hash = new QueryInfo(path, filesize, process.StartInfo.Arguments);
|
QueryInfo hash = new QueryInfo(path, filesize, process.StartInfo.Arguments);
|
||||||
|
|
||||||
if (!noCache && filesize > 0 && CacheContains(hash, ref cmdCache))
|
if (!noCache && filesize > 0 && CacheContains(hash, ref cmdCache))
|
||||||
|
|||||||
@@ -21,5 +21,14 @@ namespace Flowframes.Ui
|
|||||||
{
|
{
|
||||||
LockWindowUpdate(IntPtr.Zero);
|
LockWindowUpdate(IntPtr.Zero);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<Control> GetControls(this Control control)
|
||||||
|
{
|
||||||
|
List<Control> list = new List<Control>();
|
||||||
|
var controls = control.Controls.Cast<Control>().ToList();
|
||||||
|
list.AddRange(controls);
|
||||||
|
controls.ForEach(c => list.AddRange(c.GetControls()));
|
||||||
|
return list;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user