Skip to content

Commit

Permalink
#240 logic fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Anime4000 committed Jul 7, 2024
1 parent 3e5cfac commit 6e99fbf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
22 changes: 10 additions & 12 deletions IFME/MediaEncoding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -416,25 +416,23 @@ internal static void Video(MediaQueue queue, string tempDir)
float fps = 0;
float numFrames = 0;

if (item.Quality.FrameRate > 0)
fps = item.Info.FrameRate;
if (item.Quality.FrameRate == 0)
fps = item.Info.FrameRateAvg;
else
fps = item.Quality.FrameRate;

if (item.Info.FrameRateAvg > 0)
fps = item.Info.FrameRateAvg;

numFrames = (int)(queue.Duration * fps);

if (item.Quality.FrameCount > 0)
numFrames = item.Quality.FrameCount;
numFrames = queue.Duration * fps;

if (queue.Trim.Enable)
numFrames = (int)(TimeSpan.Parse(queue.Trim.Duration).TotalMilliseconds / (1000 / fps));
numFrames = (float)(TimeSpan.Parse(queue.Trim.Duration).TotalMilliseconds / (1000 / fps));

var framecount = (int)Math.Ceiling(numFrames);

en_framecount = $"{vc.Args.FrameCount} {numFrames}";
if (numFrames > 0)
en_framecount = $"{vc.Args.FrameCount} {framecount}";

RealFrameCount = (int)numFrames;
RealFrameCount = framecount;
item.Quality.FrameCount = framecount;
}

// Copy Streams
Expand Down
14 changes: 7 additions & 7 deletions IFME/ProcessManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ private void Proc_DataReceived(object sender, DataReceivedEventArgs e)
return;
}

var regexPattern = @"( \d+ bits )|( \d+ seconds)|(\d+/\d{3})|(size=[ ]{1,}\d+)|(frame[ ]{1,}\d+)|(\d+.\d+[ ]{1,}kb/s)|(\d+.\d+[ ]{1,}fps)|(\d+[ ]{1,}frames:\s\d+.\d+[ ]{1,}fps,\s\d+.\d+[ ]{1,}kb/s,\sGPU\s\d+%,\sVE\s\d+%)";
Match m = Regex.Match(e.Data, regexPattern, RegexOptions.IgnoreCase);
if (m.Success)
frmMain.PrintProgress(e.Data);
else
frmMain.PrintLog(e.Data);

var patterns = new[]
{
@"vvenc \[info\]: stats: frame=\s*(\d+) .* avg_fps=\s*([\d\.]+) .* avg_bitrate=\s*([\d\.]+) kbps", // Fraunhofer VVC
Expand Down Expand Up @@ -181,13 +188,6 @@ private void Proc_DataReceived(object sender, DataReceivedEventArgs e)
return;
}
}

var regexPattern = @"( \d+ bits )|( \d+ seconds)|(\d+/\d{3})|(size=[ ]{1,}\d+)|(frame[ ]{1,}\d+)|(\d+.\d+[ ]{1,}kb/s)|(\d+.\d+[ ]{1,}fps)|(\d+[ ]{1,}frames:\s\d+.\d+[ ]{1,}fps,\s\d+.\d+[ ]{1,}kb/s,\sGPU\s\d+%,\sVE\s\d+%)";
Match m = Regex.Match(e.Data, regexPattern, RegexOptions.IgnoreCase);
if (m.Success)
frmMain.PrintProgress(e.Data);
else
frmMain.PrintLog(e.Data);
}
}

Expand Down

0 comments on commit 6e99fbf

Please sign in to comment.