From 781663ca89d8a54569946710c670907a1f47b2d6 Mon Sep 17 00:00:00 2001 From: Frank Skare Date: Thu, 25 Feb 2021 13:36:44 +0100 Subject: [PATCH] customized progress optimization --- General/ProcController.vb | 41 ++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/General/ProcController.vb b/General/ProcController.vb index ad957d0f..bcceda10 100644 --- a/General/ProcController.vb +++ b/General/ProcController.vb @@ -17,8 +17,9 @@ Public Class ProcController Private LogAction As Action = New Action(AddressOf LogHandler) Private StatusAction As Action(Of String) = New Action(Of String)(AddressOf StatusHandler) - Private CustomProgressFailure As Boolean = False Private CustomProgressInfoSeparator As String = ", " + Private UseFirstExpression As Boolean = True + Private FailCounter As Integer Shared Property Procs As New List(Of ProcController) Shared Property Aborted As Boolean @@ -107,17 +108,22 @@ Public Class ProcController value = value.Trim() - If s.ProgressOutputCustomize AndAlso Not CustomProgressFailure Then + If s.ProgressOutputCustomize AndAlso FailCounter < 9 Then Dim pattern As String Dim match As Match If Proc.Package Is Package.x264 Then - 'Mod by DJATOM since x264 161, using header - pattern = "\[\s*((\d+)\.?(\d*))%\]\s+((\d+)/(\d+))\s+((\d+)\.?(\d*))\s+((\d+)\.?(\d*))\s+(\d+:\d+:\d+)\s+(\d+:\d+:\d+)\s+((\d+)\.(\d+))\s([a-z]{1,2})\s+((\d+)\.(\d+))\s([a-z]{1,2})" - match = Regex.Match(value, pattern, RegexOptions.IgnoreCase) + If UseFirstExpression Then + 'Mod by DJATOM since x264 161, using header + pattern = "\[\s*((\d+)\.?(\d*))%\]\s+((\d+)/(\d+))\s+((\d+)\.?(\d*))\s+((\d+)\.?(\d*))\s+(\d+:\d+:\d+)\s+(\d+:\d+:\d+)\s+((\d+)\.(\d+))\s([a-z]{1,2})\s+((\d+)\.(\d+))\s([a-z]{1,2})" + match = Regex.Match(value, pattern, RegexOptions.IgnoreCase) - If match.Success Then - value = $"[{match.Groups(2).Value,2}.{match.Groups(3).Value}%] {match.Groups(5).Value.PadLeft(match.Groups(6).Value.Length)}/{match.Groups(6).Value} frames @ {match.Groups(8).Value}.{match.Groups(9).Value} fps{CustomProgressInfoSeparator}{match.Groups(11).Value,4} kb/s{CustomProgressInfoSeparator}{match.Groups(16).Value} {match.Groups(18).Value} ({match.Groups(20).Value}.{match.Groups(21).Value} {match.Groups(22).Value}){CustomProgressInfoSeparator}{match.Groups(13).Value} (-{match.Groups(14).Value})" + If match.Success Then + value = $"[{match.Groups(2).Value,2}.{match.Groups(3).Value}%] {match.Groups(5).Value.PadLeft(match.Groups(6).Value.Length)}/{match.Groups(6).Value} frames @ {match.Groups(8).Value}.{match.Groups(9).Value} fps{CustomProgressInfoSeparator}{match.Groups(11).Value,4} kb/s{CustomProgressInfoSeparator}{match.Groups(16).Value} {match.Groups(18).Value} ({match.Groups(20).Value}.{match.Groups(21).Value} {match.Groups(22).Value}){CustomProgressInfoSeparator}{match.Groups(13).Value} (-{match.Groups(14).Value})" + Else + UseFirstExpression = Not UseFirstExpression + FailCounter += 1 + End If Else 'Mod by Patman pattern = "\[((\d+)\.?(\d*))%\]\s+((\d+)/(\d+)(\sframes)),\s((\d+)\.?(\d*)(\sfps)),\s((\d+)\.?(\d*)\s([a-z]{2}/s)),\s(\d+)\.(\d+)\s([a-z]{1,2}),\seta\s(\d+:\d+:\d+),\sest\.size\s(\d+)\.(\d+)\s([a-z]{1,2})" @@ -126,16 +132,22 @@ Public Class ProcController If match.Success Then value = $"[{match.Groups(2).Value,2}.{match.Groups(3).Value}%] {match.Groups(5).Value.PadLeft(match.Groups(6).Value.Length)}/{match.Groups(6).Value} frames @ {match.Groups(9).Value}.{match.Groups(10).Value} fps{CustomProgressInfoSeparator}{match.Groups(13).Value,4} {match.Groups(15).Value}{CustomProgressInfoSeparator}{match.Groups(16).Value} {match.Groups(18).Value} ({match.Groups(20).Value} {match.Groups(22).Value}){CustomProgressInfoSeparator}-{match.Groups(19).Value}" Else - CustomProgressFailure = True + UseFirstExpression = Not UseFirstExpression + FailCounter += 1 End If End If ElseIf Proc.Package Is Package.x265 Then - 'Mod by Patman since x265 3.5-RC1 - pattern = "\[(\d+)(\.?\d*)%\]\s+(\d+)/(\d+)\sframes\s@\s(\d+)(\.?\d*)\sfps\s\|\s(\d+)(\.?\d*)\s([a-z]{2}/s)\s\|\s(\d+:\d+:\d+)\s\[-(\d+:\d+:\d+)\]\s\|\s(\d+)(\.\d+)\s([a-z]{1,2})\s\[(\d+)(\.\d+)\s([a-z]{1,2})\]" - match = Regex.Match(value, pattern, RegexOptions.IgnoreCase) + If UseFirstExpression Then + 'Mod by Patman since x265 3.5-RC1 + pattern = "\[(\d+)(\.?\d*)%\]\s+(\d+)/(\d+)\sframes\s@\s(\d+)(\.?\d*)\sfps\s\|\s(\d+)(\.?\d*)\s([a-z]{2}/s)\s\|\s(\d+:\d+:\d+)\s\[-(\d+:\d+:\d+)\]\s\|\s(\d+)(\.\d+)\s([a-z]{1,2})\s\[(\d+)(\.\d+)\s([a-z]{1,2})\]" + match = Regex.Match(value, pattern, RegexOptions.IgnoreCase) - If match.Success Then - value = $"[{match.Groups(1).Value,2}{match.Groups(2).Value}%] {match.Groups(3).Value.PadLeft(match.Groups(4).Value.Length)}/{match.Groups(4).Value} frames @ {match.Groups(5).Value}{match.Groups(6).Value} fps{CustomProgressInfoSeparator}{match.Groups(7).Value,4} {match.Groups(9).Value}{CustomProgressInfoSeparator}{match.Groups(12).Value}{match.Groups(13).Value} {match.Groups(14).Value} ({match.Groups(15).Value} {match.Groups(17).Value}){CustomProgressInfoSeparator}{match.Groups(10).Value} (-{match.Groups(11).Value})" + If match.Success Then + value = $"[{match.Groups(1).Value,2}{match.Groups(2).Value}%] {match.Groups(3).Value.PadLeft(match.Groups(4).Value.Length)}/{match.Groups(4).Value} frames @ {match.Groups(5).Value}{match.Groups(6).Value} fps{CustomProgressInfoSeparator}{match.Groups(7).Value,4} {match.Groups(9).Value}{CustomProgressInfoSeparator}{match.Groups(12).Value}{match.Groups(13).Value} {match.Groups(14).Value} ({match.Groups(15).Value} {match.Groups(17).Value}){CustomProgressInfoSeparator}{match.Groups(10).Value} (-{match.Groups(11).Value})" + Else + UseFirstExpression = Not UseFirstExpression + FailCounter += 1 + End If Else 'Mod by DJATOM since x265 3.4+65, including progress-frames pattern = "\[((\d+)\.?(\d*))%\]\s+((\d+)(\(\d+\))?/(\d+)(\sframes)),\s((\d+)\.?(\d*)(\sfps)),\s((\d+)\.?(\d*)\s([a-z]{2}/s)),\selapsed:\s(\d+:\d+:\d+),\seta:\s(\d+:\d+:\d+),\ssize:\s(\d+)\.(\d+)\s([a-z]{1,2}),\sest\.\ssize:\s(\d+)\.(\d+)\s([a-z]{1,2})" @@ -144,7 +156,8 @@ Public Class ProcController If match.Success Then value = $"[{match.Groups(2).Value,2}.{match.Groups(3).Value}%] {match.Groups(5).Value.PadLeft(match.Groups(7).Value.Length)}{match.Groups(6).Value}/{match.Groups(7).Value} frames @ {match.Groups(10).Value}.{match.Groups(11).Value} fps{CustomProgressInfoSeparator}{match.Groups(14).Value,4} {match.Groups(16).Value}{CustomProgressInfoSeparator}{match.Groups(19).Value} {match.Groups(21).Value} ({match.Groups(22).Value} {match.Groups(24).Value}){CustomProgressInfoSeparator}{match.Groups(17).Value} (-{match.Groups(18).Value})" Else - CustomProgressFailure = True + UseFirstExpression = Not UseFirstExpression + FailCounter += 1 End If End If End If