From 7c43db13b82be6cdc741ba9b3301ae1bff59e1e0 Mon Sep 17 00:00:00 2001 From: Alkl58 Date: Sun, 19 Dec 2021 16:37:55 +0100 Subject: [PATCH] Add Estimated FPS and Estimated Time of Arrival --- NotEnoughAV1Encodes/MainWindow.xaml | 15 ++++++--- NotEnoughAV1Encodes/MainWindow.xaml.cs | 33 +++++++++++++++---- .../resources/lang/Strings.Designer.cs | 27 +++++++++++++++ .../resources/lang/Strings.resx | 9 +++++ 4 files changed, 73 insertions(+), 11 deletions(-) diff --git a/NotEnoughAV1Encodes/MainWindow.xaml b/NotEnoughAV1Encodes/MainWindow.xaml index 77d7303..998fe09 100644 --- a/NotEnoughAV1Encodes/MainWindow.xaml +++ b/NotEnoughAV1Encodes/MainWindow.xaml @@ -930,6 +930,7 @@ + @@ -938,20 +939,24 @@ - - - - + + + + + + + + - + diff --git a/NotEnoughAV1Encodes/MainWindow.xaml.cs b/NotEnoughAV1Encodes/MainWindow.xaml.cs index 596eb77..67d0469 100644 --- a/NotEnoughAV1Encodes/MainWindow.xaml.cs +++ b/NotEnoughAV1Encodes/MainWindow.xaml.cs @@ -1552,8 +1552,9 @@ private async Task MainStartAsync(CancellationToken _cancelToken) await Task.Run(() => queueElement.GetVFRTimeStamps(), _cancelToken); // Starts "a timer" for eta / fps calculation + DateTime startTime = DateTime.Now; System.Timers.Timer aTimer = new(); - aTimer.Elapsed += (sender, e) => { UpdateProgressBar(queueElement); }; + aTimer.Elapsed += (sender, e) => { UpdateProgressBar(queueElement, startTime); }; aTimer.Interval = 1000; aTimer.Start(); @@ -1589,8 +1590,9 @@ private async Task MainStartAsync(CancellationToken _cancelToken) Shutdown(); } - private static void UpdateProgressBar(Queue.QueueElement queueElement) + private static void UpdateProgressBar(Queue.QueueElement queueElement, DateTime startTime) { + TimeSpan timeSpent = DateTime.Now - startTime; long encodedFrames = 0; long encodedFramesSecondPass = 0; @@ -1621,12 +1623,31 @@ private static void UpdateProgressBar(Queue.QueueElement queueElement) // Progress 2nd-Pass of 2-Pass Encoding queueElement.ProgressSecondPass = Convert.ToDouble(encodedFramesSecondPass); - // Divide by 2 - try { encodedFrames /= 2; } catch { } - try { encodedFramesSecondPass /= 2; } catch { } + string estimatedFPS1stPass = ""; + string estimatedFPS2ndPass = ""; + string estimatedTime1stPass = ""; + string estimatedTime2ndPass = ""; + if (encodedFrames != queueElement.FrameCount) + { + estimatedFPS1stPass = " - ~" + Math.Round(encodedFrames / timeSpent.TotalSeconds, 2).ToString() + "fps"; + estimatedTime1stPass = " - ~" + Math.Round(((timeSpent.TotalSeconds / encodedFrames) * (queueElement.FrameCount - encodedFrames)) / 60, MidpointRounding.ToEven) + LocalizedStrings.Instance["QueueMinLeft"]; + } + + if(encodedFramesSecondPass != queueElement.FrameCount) + { + estimatedFPS2ndPass = " - ~" + Math.Round(encodedFramesSecondPass / timeSpent.TotalSeconds, 2).ToString() + "fps"; + estimatedTime2ndPass = " - ~" + Math.Round(((timeSpent.TotalSeconds / encodedFramesSecondPass) * (queueElement.FrameCount - encodedFramesSecondPass)) / 60, MidpointRounding.ToEven) + LocalizedStrings.Instance["QueueMinLeft"]; + } + + queueElement.Status = LocalizedStrings.Instance["Queue1stPass"] + " " + ((decimal)encodedFrames / queueElement.FrameCount).ToString("0.00%") + estimatedFPS1stPass + estimatedTime1stPass + " - " + LocalizedStrings.Instance["Queue2ndPass"] + " " + ((decimal)encodedFramesSecondPass / queueElement.FrameCount).ToString("0.00%") + estimatedFPS2ndPass + estimatedTime2ndPass; } + else + { + string estimatedFPS = " - ~" + Math.Round(encodedFrames / timeSpent.TotalSeconds, 2).ToString() + "fps"; + string estimatedTime = " - ~" + Math.Round(((timeSpent.TotalSeconds / encodedFrames) * (queueElement.FrameCount - encodedFrames)) / 60, MidpointRounding.ToEven) + LocalizedStrings.Instance["QueueMinLeft"]; - queueElement.Status = "Encoded: " + ((decimal)(encodedFrames + encodedFramesSecondPass) / queueElement.FrameCount).ToString("0.00%"); + queueElement.Status = "Encoded: " + ((decimal)encodedFrames / queueElement.FrameCount).ToString("0.00%") + estimatedFPS + estimatedTime; + } } #endregion diff --git a/NotEnoughAV1Encodes/resources/lang/Strings.Designer.cs b/NotEnoughAV1Encodes/resources/lang/Strings.Designer.cs index b373b09..5fbbad2 100644 --- a/NotEnoughAV1Encodes/resources/lang/Strings.Designer.cs +++ b/NotEnoughAV1Encodes/resources/lang/Strings.Designer.cs @@ -942,6 +942,24 @@ public static string ProgramSettings { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die 1st Pass: ähnelt. + /// + public static string Queue1stPass { + get { + return ResourceManager.GetString("Queue1stPass", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die 2nd Pass: ähnelt. + /// + public static string Queue2ndPass { + get { + return ResourceManager.GetString("Queue2ndPass", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die Edit ähnelt. /// @@ -951,6 +969,15 @@ public static string QueueMenuItemEdit { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die min left ähnelt. + /// + public static string QueueMinLeft { + get { + return ResourceManager.GetString("QueueMinLeft", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die Resume ähnelt. /// diff --git a/NotEnoughAV1Encodes/resources/lang/Strings.resx b/NotEnoughAV1Encodes/resources/lang/Strings.resx index ee5ccad..f6b9797 100644 --- a/NotEnoughAV1Encodes/resources/lang/Strings.resx +++ b/NotEnoughAV1Encodes/resources/lang/Strings.resx @@ -412,9 +412,18 @@ Settings + + 1st Pass: + + + 2nd Pass: + Edit + + min left + Resume