Download

Online

Gallery

Blog

  Index  | Recent Threads  | List Attachments  | Search
 Welcome Guest  |  Register  |  Login
Login Name  Password
 

Sweet Home 3D Forum



No member browsing this thread
Thread Status: Active
Total posts in this thread: 2
[ Jump to Last Post ]
Post new Thread
Author
Previous Thread This topic has been viewed 1834 times and has 1 reply Next Thread
MeekMark
Newbie
Member's Avatar

United States
Joined: Jun 12, 2022
Post Count: 1
Status: Offline
Reply to this Post  Reply with Quote 
"Create Video" dialog - "Estimated remaining time" text

My first post, novice user of Sweet Home. My first design of my house, I got carried away in the "Create Video" dialog. I created lots (maybe 100) of camera locations, which yielded maybe 2,300 frames.

The "Estimated remaining time" when it started sounded fast, maybe 1 hour remaining. Well several hours later, it was maybe 58 minutes remaining and only maybe 50% through the 2,300 frames.

So I hunted down the code, and saw this in sweethome3d-code-r8307-trunk\SweetHome3D\src\com\eteks\sweethome3d\swing\VideoPanel.java:



this.progressBar = new JProgressBar();
this.progressBar.setIndeterminate(true);
this.progressBar.getModel().addChangeListener(new ChangeListener() {
private long timeAfterFirstImage;

public void stateChanged(ChangeEvent ev) {
int progressValue = progressBar.getValue();
progressBar.setIndeterminate(progressValue <= progressBar.getMinimum() + 1);
if (progressValue == progressBar.getMinimum()
|| progressValue == progressBar.getMaximum()) {
progressLabel.setText("");
if (progressValue == progressBar.getMinimum()) {
int framesCount = progressBar.getMaximum() - progressBar.getMinimum();
String progressLabelFormat = preferences.getLocalizedString(VideoPanel.class, "progressStartLabel.format");
progressLabel.setText(String.format(progressLabelFormat, framesCount,
formatDuration(framesCount * 1000 / controller.getFrameRate())));
}
} else if (progressValue == progressBar.getMinimum() + 1) {
this.timeAfterFirstImage = System.currentTimeMillis();
} else {
// Update progress label once the second image is generated
// (the first one can take more time because of initialization process)
String progressLabelFormat = preferences.getLocalizedString(VideoPanel.class, "progressLabel.format");
long estimatedRemainingTime = (System.currentTimeMillis() - this.timeAfterFirstImage)
/ (progressValue - 1 - progressBar.getMinimum())
* (progressBar.getMaximum() - progressValue - 1);
String estimatedRemainingTimeText = formatDuration(estimatedRemainingTime);
progressLabel.setText(String.format(progressLabelFormat,
progressValue, progressBar.getMaximum(), estimatedRemainingTimeText));
}
}


So, I saw it takes a snapshot of the elapsed time in milliseconds for the second image. But what I think is happening (at least in my situation) is the first 100 or so images are pretty basic, viewpoint of just a portion of the exterior.

So here's some (untested) code that would look at the elapsed time of the rendering of the tenth image and use that as the basis of the average time, to calculate the estimated remaining time.

I would imagine that a better implementation would be to use the total number of images being rendered (IE: progressBar.getMaximum() ), and see the elapsed time of an image perhaps 5% into the render, and use that:


this.progressBar = new JProgressBar();
this.progressBar.setIndeterminate(true);
this.progressBar.getModel().addChangeListener(new ChangeListener() {
private long timeAfterFirstImage;
// MeekMark Begin
private long timeAfter10Images;
private long timeAfter11Images;
private long timeEstimate;
// MeekMark End

public void stateChanged(ChangeEvent ev) {
int progressValue = progressBar.getValue();
progressBar.setIndeterminate(progressValue <= progressBar.getMinimum() + 1);
if (progressValue == progressBar.getMinimum()
|| progressValue == progressBar.getMaximum()) {
progressLabel.setText("");
if (progressValue == progressBar.getMinimum()) {
int framesCount = progressBar.getMaximum() - progressBar.getMinimum();
String progressLabelFormat = preferences.getLocalizedString(VideoPanel.class, "progressStartLabel.format");
progressLabel.setText(String.format(progressLabelFormat, framesCount,
formatDuration(framesCount * 1000 / controller.getFrameRate())));
}
// MeekMark Begin
} else if (progressValue == progressBar.getMinimum() + 11) {
this.timeAfter11Images = System.currentTimeMillis();
this.timeEstimate = timeAfter11Images - timeAfter10Images;
} else if (progressValue == progressBar.getMinimum() + 10) {
this.timeAfter10Images = System.currentTimeMillis();
} else if (progressValue == progressBar.getMinimum() + 1) {
this.timeAfterFirstImage = System.currentTimeMillis();
this.timeEstimate = this.timeAfterFirstImage;
} else {
// Update progress label once the second image is generated
// (the first FEW?? can take more time because of initialization process)
String progressLabelFormat = preferences.getLocalizedString(VideoPanel.class, "progressLabel.format");
long estimatedRemainingTime = (System.currentTimeMillis() - this.timeEstimate)
/ (progressValue - 1 - progressBar.getMinimum())
* (progressBar.getMaximum() - progressValue - 1);
// MeekMark End
String estimatedRemainingTimeText = formatDuration(estimatedRemainingTime);
progressLabel.setText(String.format(progressLabelFormat,
progressValue, progressBar.getMaximum(), estimatedRemainingTimeText));
}
}



Now I'd love to load up Eclipse on my home computer and test it out, but... not enough time...


Thoughts?
[Jun 12, 2022, 11:48:11 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Daniels118
Advanced Member
Member's Avatar

Italy
Joined: Nov 17, 2021
Post Count: 398
Status: Offline
Reply to this Post  Reply with Quote 
Re: "Create Video" dialog - "Estimated remaining time" text

I think the best estimate can be obtained by averaging the elapsed of all frames rendered so far. This has the drawback that the ETA is quite unstable at first, however it gains stability as more frames are included in the average.
[Jun 13, 2022, 4:33:29 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
[ Jump to Last Post ]
Show Printable Version of Thread  Post new Thread

    Get Sweet Home 3D at SourceForge.net. Fast, secure and Free Open Source software downloads
   
© Copyright 2006-2024 eTeks - All rights reserved