mirror of
https://github.com/n00mkrad/flowframes.git
synced 2026-09-01 19:51:28 +02:00
async frame counting
This commit is contained in:
@@ -129,7 +129,7 @@ namespace Flowframes.Forms
|
||||
|
||||
InterpSettings current = Program.mainForm.GetCurrentSettings();
|
||||
current.UpdatePaths(path, path.GetParentDir());
|
||||
current.inFps = GetFramerate(path);
|
||||
current.inFps = await GetFramerate(path);
|
||||
current.outFps = current.inFps * current.interpFactor;
|
||||
Program.batchQueue.Enqueue(current);
|
||||
RefreshGui();
|
||||
@@ -137,10 +137,10 @@ namespace Flowframes.Forms
|
||||
}
|
||||
}
|
||||
|
||||
float GetFramerate (string path)
|
||||
async Task<float> GetFramerate (string path)
|
||||
{
|
||||
float fps = Interpolate.current.inFps;
|
||||
float fpsFromFile = IOUtils.GetFpsFolderOrVideo(path);
|
||||
float fpsFromFile = await IOUtils.GetFpsFolderOrVideo(path);
|
||||
if (fpsFromFile > 0)
|
||||
return fpsFromFile;
|
||||
|
||||
|
||||
4
Code/Forms/SettingsForm.Designer.cs
generated
4
Code/Forms/SettingsForm.Designer.cs
generated
@@ -1244,9 +1244,9 @@
|
||||
this.label58.Location = new System.Drawing.Point(420, 301);
|
||||
this.label58.Margin = new System.Windows.Forms.Padding(10, 10, 10, 7);
|
||||
this.label58.Name = "label58";
|
||||
this.label58.Size = new System.Drawing.Size(255, 13);
|
||||
this.label58.Size = new System.Drawing.Size(221, 13);
|
||||
this.label58.TabIndex = 65;
|
||||
this.label58.Text = "Lower is better. Use slightly higher values than h265!";
|
||||
this.label58.Text = "Lower is better. Use higher values than h265!";
|
||||
//
|
||||
// vp9Crf
|
||||
//
|
||||
|
||||
@@ -300,7 +300,7 @@ namespace Flowframes.IO
|
||||
}
|
||||
}
|
||||
|
||||
public static float GetVideoFramerate (string path)
|
||||
public static async Task<float> GetVideoFramerate (string path)
|
||||
{
|
||||
float fps = 0;
|
||||
try
|
||||
@@ -316,7 +316,7 @@ namespace Flowframes.IO
|
||||
Logger.Log("Failed to read FPS - Trying alternative method...", true);
|
||||
try
|
||||
{
|
||||
fps = FfmpegCommands.GetFramerate(path);
|
||||
fps = await FfmpegCommands.GetFramerate(path);
|
||||
Logger.Log("Detected FPS of " + Path.GetFileName(path) + " as " + fps + " FPS", true);
|
||||
}
|
||||
catch
|
||||
@@ -478,19 +478,21 @@ namespace Flowframes.IO
|
||||
return null;
|
||||
}
|
||||
|
||||
public static float GetFpsFolderOrVideo(string path)
|
||||
public static async Task<float> GetFpsFolderOrVideo(string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (IsPathDirectory(path))
|
||||
{
|
||||
float dirFps = GetVideoFramerateForDir(path);
|
||||
|
||||
if (dirFps > 0)
|
||||
return dirFps;
|
||||
}
|
||||
else
|
||||
{
|
||||
float vidFps = GetVideoFramerate(path);
|
||||
float vidFps = await GetVideoFramerate(path);
|
||||
|
||||
if (vidFps > 0)
|
||||
return vidFps;
|
||||
}
|
||||
@@ -499,6 +501,7 @@ namespace Flowframes.IO
|
||||
{
|
||||
Logger.Log("GetFpsFolderOrVideo() Error: " + e.Message);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -61,23 +61,32 @@ namespace Flowframes
|
||||
return FormatUtils.MsFromTimestamp(info);
|
||||
}
|
||||
|
||||
public static float GetFramerate(string inputFile)
|
||||
public static async Task<float> GetFramerate(string inputFile)
|
||||
{
|
||||
Logger.Log("Reading FPS using ffmpeg.", true, false, "ffmpeg");
|
||||
string args = $" -i {inputFile.Wrap()}";
|
||||
string output = GetFfmpegOutput(args);
|
||||
string[] entries = output.Split(',');
|
||||
foreach (string entry in entries)
|
||||
Logger.Log($"GetFramerate('{inputFile}')", true, false, "ffmpeg");
|
||||
|
||||
try
|
||||
{
|
||||
if (entry.Contains(" fps") && !entry.Contains("Input ")) // Avoid reading FPS from the filename, in case filename contains "fps"
|
||||
string args = $" -i {inputFile.Wrap()}";
|
||||
string output = await GetFfmpegOutputAsync(args);
|
||||
string[] entries = output.Split(',');
|
||||
|
||||
foreach (string entry in entries)
|
||||
{
|
||||
Logger.Log("[FFCmds] FPS Entry: " + entry, true);
|
||||
string num = entry.Replace(" fps", "").Trim().Replace(",", ".");
|
||||
float value;
|
||||
float.TryParse(num, NumberStyles.Any, CultureInfo.InvariantCulture, out value);
|
||||
return value;
|
||||
if (entry.Contains(" fps") && !entry.Contains("Input ")) // Avoid reading FPS from the filename, in case filename contains "fps"
|
||||
{
|
||||
string num = entry.Replace(" fps", "").Trim().Replace(",", ".");
|
||||
float value;
|
||||
float.TryParse(num, NumberStyles.Any, CultureInfo.InvariantCulture, out value);
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Logger.Log("GetFramerate Error: " + e.Message, true, false);
|
||||
}
|
||||
|
||||
return 0f;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Flowframes.UI
|
||||
int frameCount = await InterpolateUtils.GetInputFrameCountAsync(path);
|
||||
|
||||
string fpsStr = "Not Found";
|
||||
float fps = IOUtils.GetFpsFolderOrVideo(path);
|
||||
float fps = await IOUtils.GetFpsFolderOrVideo(path);
|
||||
fpsInTbox.Text = fps.ToString();
|
||||
|
||||
if (fps > 0)
|
||||
|
||||
Reference in New Issue
Block a user