MeekMark
Newbie
United States
Joined: Jun 12, 2022
Post Count: 1
Status:
Offline
|
|
"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?
|