private void FFmpeg_ProgressUpdated(object sender, FFmpeg.StatusUpdatedEventArgs e) { if (manager.AppExited) { return; } Dispatcher.Invoke(() => { FFmpegProcess Proc = sender as FFmpegProcess; long Frames = 0; for (int i = 0; i < hosts.Count; i++) { if (hosts[i].LastStatusReceived != null) { Frames += hosts[i].LastStatusReceived.Frame; } } WorkProgressBar.Value = FrameDone + Frames; PercentText.Text = (WorkProgressBar.Value / WorkProgressBar.Maximum).ToString("p1"); SetPageTitle(PercentText.Text); // FpsText.Text = e.Status.Fps.ToString(); // Time left will be updated only once per 2 updates to prevent changing too quickly EstimatedTimeLeftToggle = (EstimatedTimeLeftToggle + 1) % 2; if (EstimatedTimeLeftToggle == 0 && timeCalc != null) { timeCalc.Calculate(Frames); if (timeCalc.ResultTimeLeft > TimeSpan.Zero) { TimeLeftText.Text = timeCalc.ResultTimeLeft.ToString(timeCalc.ResultTimeLeft.TotalHours < 1 ? "m\\:ss" : "h\\:mm\\:ss"); FpsText.Text = timeCalc.ResultFps.ToString("0.0"); } } }); }
private void FFmpeg_StatusUpdated(object sender, FFmpeg.StatusUpdatedEventArgs e) { Dispatcher.Invoke(() => { WorkProgressBar.Value = e.Status.Frame + host.Options.ResumePos; PercentText.Text = (WorkProgressBar.Value / WorkProgressBar.Maximum).ToString("p1"); SetPageTitle(PercentText.Text); FpsText.Text = e.Status.Fps.ToString(); // Time left will be updated only 1 out of 2 to prevent changing too quick. EstimatedTimeLeftToggle = !EstimatedTimeLeftToggle; if (EstimatedTimeLeftToggle) { TimeSpan TimeLeft = timeCalc?.Calculate(e.Status.Frame + host.Options.ResumePos) ?? TimeSpan.Zero; if (TimeLeft > TimeSpan.Zero) { TimeLeftText.Text = TimeLeft.ToString(TimeLeft.TotalHours < 1 ? "m\\:ss" : "h\\:mm\\:ss"); } } }); }