Skip to content

Commit

Permalink
Improve Export Video GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
GetGet99 committed Jun 27, 2022
1 parent f90350f commit 2ca4bc8
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
44 changes: 36 additions & 8 deletions PhotoToys/Custom UI/SimpleUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,31 @@ where pa is ImageParameter impa && impa.IsVideoMode
var totalFrames = vidcapture.FrameCount;
var dialog = new ContentDialog
{
Content = new ProgressBar
Content = new FluentVerticalStack
{
//Value = 50,
}.Assign(out var progressRing),
Children =
{
new ProgressBar
{
//Value = 50,
}.Assign(out var progressBar),
new TextBlock
{

}.Assign(out var PercentageProgress),
new TextBlock
{

}.Assign(out var AverageRenderSpeed),
new TextBlock
{

}.Assign(out var EstimatedTime)
}
},
XamlRoot = Result.XamlRoot,
};
DateTime dateTime;
async Task RunLoop()
{
await Task.Run(async delegate
Expand All @@ -267,11 +286,19 @@ await Task.Run(async delegate
for (int i = 0; i < totalFrames; i++)
{
video.PosFrames = i;
if (i % 10 == 0)
dialog.DispatcherQueue.TryEnqueue(delegate
{
progressRing.Value = (double)(i+1) / totalFrames * 100;
});
//if (i % 10 == 0)
dialog.DispatcherQueue.TryEnqueue(delegate
{
var progress = (double)(i + 1) / totalFrames * 100;
progressBar.Value = progress;
var renderFPS = i / (DateTime.Now - dateTime).TotalSeconds;
var estimatedseconds = (totalFrames - i) / (renderFPS + 1e-3);
const double onedayinseconds = 60 * 60 * 24;

PercentageProgress.Text = $"{progress:N2}% ({i + 1}/{totalFrames})";
AverageRenderSpeed.Text = $"Average Render Speed: {renderFPS:N2} frames per second";
EstimatedTime.Text = $"Estimated Time left: {(estimatedseconds > onedayinseconds ? "More than a day" : TimeSpan.FromSeconds((totalFrames - i) / (renderFPS + 1e-3))):c}";
});
if (video.Result is null) break;
TaskCompletionSource<Mat> result = new();
OnExecute?.Invoke(x =>
Expand All @@ -284,6 +311,7 @@ await Task.Run(async delegate
writer.Release();
});
};
dateTime = DateTime.Now;
_ = dialog.ShowAsync();

await RunLoop();
Expand Down
2 changes: 1 addition & 1 deletion PhotoToys/PhotoToys.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<AppxAutoIncrementPackageRevision>False</AppxAutoIncrementPackageRevision>
<AppxSymbolPackageEnabled>True</AppxSymbolPackageEnabled>
<GenerateTestArtifacts>True</GenerateTestArtifacts>
<AppxBundle>Auto</AppxBundle>
<AppxBundle>Always</AppxBundle>
<AppxBundlePlatforms>x86|x64|arm64</AppxBundlePlatforms>
<HoursBetweenUpdateChecks>0</HoursBetweenUpdateChecks>
<GenerateTemporaryStoreCertificate>True</GenerateTemporaryStoreCertificate>
Expand Down

0 comments on commit 2ca4bc8

Please sign in to comment.