fix formatting of output, make Movie Maker progress window larger

This commit is contained in:
Ben Fry
2021-06-27 14:31:04 -04:00
parent d515178699
commit 48923b76ac
2 changed files with 23 additions and 5 deletions
+4 -2
View File
@@ -608,7 +608,7 @@ color_chooser.select = Select
movie_maker = Movie Maker
movie_maker.two.title = Movie Maker II: The Revenge
movie_maker.two.blurb = <html><b>This tool creates an MPEG movie or Animated GIF from a sequence of images.</b><br><br>To avoid artifacts caused by re-compressing images as video,<br> use TIFF, TGA, or PNG images as the source.<br><br>TIFF and TGA will save more quickly in a sketch, but require more disk:<br><tt>saveFrame("frames/####.tif");</tt><br><tt>saveFrame("frames/####.tga");</tt><br><br>PNG images are smaller, but your sketch will run more slowly:<br><tt>saveFrame("frames/####.png");</tt><br><br><font color="#808080">Formerly QuickTime Movie Maker by Werner Randelshofer,<br/>this was rewritten completely to use FFmpeg for Processing 4.</font>
movie_maker.two.blurb = <html><b>Create an MPEG movie or Animated GIF from a sequence of images</b><br><br>To avoid artifacts caused by re-compressing images as video,<br> use TIFF, TGA, or PNG images as the source.<br><br>TIFF and TGA will save more quickly in a sketch, but require more disk:<br><tt>saveFrame("frames/####.tif");</tt><br><tt>saveFrame("frames/####.tga");</tt><br><br>PNG images are smaller, but your sketch will run more slowly:<br><tt>saveFrame("frames/####.png");</tt><br><br><font color="#808080">Formerly QuickTime Movie Maker by Werner Randelshofer,<br/>this was mostly rewritten to use FFmpeg for Processing 4.</font>
movie_maker.image_folder_help_label = Drag a folder with image files into the field below:
movie_maker.choose_button = Choose...
movie_maker.select_image_folder = Select image folder...
@@ -634,7 +634,9 @@ movie_maker.error.no_images_found = No image files found.
movie_maker.error.sorry = Sorry
movie_maker.error.unknown_tga_format = Unknown .tga file format for %s.
movie_maker.progress.creating_file_name = Creating %s.
movie_maker.progress.creating_file_name = Combining images into movie file %s.
movie_maker.progress.creating_output_file = Creating output file
movie_maker.progress.initializing = Initializing...
movie_maker.progress.processing = Processing %s.
movie_maker.progress.handling_frame = Converting frame %s of %s...
@@ -6,6 +6,7 @@ import processing.app.Platform;
import javax.swing.*;
import java.awt.Component;
import java.io.*;
import java.text.NumberFormat;
import java.util.List;
import java.util.ArrayList;
import java.util.function.Consumer;
@@ -161,15 +162,18 @@ class FFmpegEngine {
}
cmd.add(outputPath);
//final String outputName = new File(outputPath).getName();
final String outputName = new File(outputPath).getName();
// pass cmd to Runtime exec
// read the output and set the progress bar
// show a message (success/failure) when complete
final String maxCount = nfc(imgFiles.length);
final ProgressMonitor progress = new ProgressMonitor(parent,
Language.interpolate("movie_maker.progress.creating_file_name", movieFile.getName()),
Language.text("movie_maker.progress.creating_output_file"),
Language.interpolate("movie_maker.progress.creating_file_name", outputName),
//Language.text("movie_maker.progress.creating_output_file"),
//Language.interpolate("movie_maker.progress.handling_frame", 0, imgFiles.length),
Language.interpolate("movie_maker.progress.handling_frame", maxCount, maxCount),
0, imgFiles.length);
// https://stackoverflow.com/a/33386692
@@ -183,6 +187,8 @@ class FFmpegEngine {
int frameCount = Integer.parseInt(m.group(1));
// this was used to show which (input) image file was being handled
//progress.setNote(Language.interpolate("movie_maker.progress.processing", inputName));
progress.setNote(Language.interpolate("movie_maker.progress.handling_frame",
nfc(frameCount + 1), nfc(imgFiles.length)));
// System.out.println(frameCount + " of " + imgFiles.length);
progress.setProgress(frameCount);
// } else {
@@ -218,4 +224,14 @@ class FFmpegEngine {
new BufferedReader(new InputStreamReader(inputStream)).lines().forEach(consumeInputLine);
}
}
static NumberFormat formatter = NumberFormat.getInstance();
static String nfc(int num) {
// if (formatter == null) {
// formatter = NumberFormat.getInstance();
// }
return formatter.format(num);
}
}