Commit c028f8b1 authored by ludwig's avatar ludwig

Added a new 'verbosity if' around several system.out.prints

git-svn-id: https://www2.in.tum.de/repos/ttt/trunk@96 0463f305-d864-43cb-8a47-61cf597d4139
parent c251df2e
......@@ -64,6 +64,7 @@ public class AudioVideoPlayer {
inputs = ((Codec)instance).getSupportedInputFormats();
outputs = ((Codec)instance).getSupportedOutputFormats(null);
boolean success = PlugInManager.addPlugIn("com.sun.media.codec.audio.mp3.JavaDecoder", inputs, outputs, PlugInManager.CODEC);
if(TTT.verbose)
System.out.println("initialized MP3 decoder plugin: "+success);
} catch (Exception e) {
String message = "Error initializing MP3 decoder plugin";
......@@ -113,6 +114,7 @@ public class AudioVideoPlayer {
TTT.showMessage(message, "TTT Audio Player", JOptionPane.ERROR_MESSAGE);
} catch (FileNotFoundException e) {
if(TTT.verbose)
System.out.println("No audio found (" + e);
}
......@@ -125,8 +127,10 @@ public class AudioVideoPlayer {
videoPlayer = Manager.createRealizedPlayer(videoFile);
video_duration = (int) (videoPlayer.getDuration().getNanoseconds() / 1000000);
} catch (MediaException e) {
if(TTT.verbose)
System.out.println("Can't play video: " + e);
} catch (FileNotFoundException e) {
if(TTT.verbose)
System.out.println("No video found (" + e);
}
......@@ -222,7 +226,9 @@ public class AudioVideoPlayer {
}
public void setReplayRatio(double ratio) {
if(TTT.verbose){
System.out.println("Audio replay ratio: " + ratio);
}
replayRatio = ratio;
}
......
......@@ -66,11 +66,12 @@ public class LameEncoder {
* @return True: Conversion succeeded.<br>False: Canceled by user
*/
public static boolean convertAudioFile(File inFile, File outFile, String options, boolean batch) throws Exception {
if(TTT.verbose){
System.out.println("----------------------------------------------");
System.out.println("LameEncoder");
System.out.println("----------------------------------------------");
System.out.println("Encoding mp3 file");
}
long startTime = System.currentTimeMillis(); //time measurement
String lameCmd = Exec.getCommand(LAME); //get lame command
if (lameCmd == null) {
......@@ -109,7 +110,9 @@ public class LameEncoder {
if (progressMonitor.isCanceled()) {
progressMonitor.close();
outFile.delete(); //delete the partly encoded outFile
if(TTT.verbose){
System.out.println("Canceled by user");
}
return false;
}
progressMonitor.close();
......@@ -121,13 +124,17 @@ public class LameEncoder {
}
if (i != 0 || outFile.length() == 0) { //check success
if(TTT.verbose){
System.out.println("Unable to encode audio file using lame:");
}
System.out.println(exec.getListenerStream());
outFile.delete();
throw new IOException("unable to encode audio file using lame");
}
if(TTT.verbose){
System.out.println("Done in " + Constants.getStringFromTime((int)(System.currentTimeMillis()-startTime)));
System.out.println("----------------------------------------------");
}
return true;
}
......
......@@ -652,7 +652,7 @@ public class Index {
if (mode == 0)
return true;
if(TTT.verbose){
// print information
System.out.print("Computing ");
if ((mode & ScriptCreator.THUMBNAILS) != 0)
......@@ -664,16 +664,17 @@ public class Index {
if ((mode & ScriptCreator.OCR_OPTIMIZED) != 0)
System.out.print("OCR input . ");
System.out.println();
}
// print file names
String name = recording.getDirectory() + recording.getFileBase();
if(TTT.verbose){
if ((mode & ScriptCreator.PDF_SCRIPT) != 0)
System.out.println(name + ".pdf");
if ((mode & ScriptCreator.HTML_SCRIPT) != 0)
System.out.println(name + ".html");
if ((mode & ScriptCreator.OCR_OPTIMIZED) != 0)
System.out.println(name + ".ocr");
}
ProgressMonitor progressMonitor = null;
if (!batch && ShowProgressMonitor) {
// show progress
......@@ -697,7 +698,9 @@ public class Index {
try {
pdfHelper = new PDFHelper(recording);
} catch (Exception e) {
if(TTT.verbose){
System.out.println("Cannot create PDF:");
}
e.printStackTrace();
JOptionPane.showMessageDialog(null, "Cannot generate pdf script: " + e, "Error...",
JOptionPane.ERROR_MESSAGE);
......@@ -730,7 +733,9 @@ public class Index {
Constants.deleteDirectory(new File(name+".html"));
if ((mode & ScriptCreator.OCR_OPTIMIZED) != 0)
Constants.deleteDirectory(new File(name+".ocr"));
if(TTT.verbose){
System.out.println("Cancelled by user");
}
isCanceled = true;
break;
} else if (TTT.verbose) {
......@@ -738,9 +743,9 @@ public class Index {
progressMonitor.setProgress(i);
}
}
if(TTT.verbose){
System.out.print(".");
}
// set time of index
IndexEntry indexEntry = index.get(i);
recording.setTime(indexEntry.getTimestamp());
......@@ -780,7 +785,9 @@ public class Index {
try {
pdfHelper.writeNextIndex(i, screenshot);
} catch (Exception e) {
if(TTT.verbose) {
System.out.println("Cannot create PDF:");
}
e.printStackTrace();
JOptionPane.showMessageDialog(null, "Cannot generate pdf script: " + e, "Error...",
JOptionPane.ERROR_MESSAGE);
......@@ -796,7 +803,9 @@ public class Index {
try {
pdfHelper.close();
} catch (Exception e) {
if(TTT.verbose){
System.out.println("Cannot create PDF:");
}
e.printStackTrace();
JOptionPane.showMessageDialog(null, "Cannot generate pdf script: " + e, "Error...",
JOptionPane.ERROR_MESSAGE);
......@@ -806,9 +815,9 @@ public class Index {
}
t = System.currentTimeMillis() - t;
if(TTT.verbose){
System.out.println(" done in " + Constants.getStringFromTime((int) t));
}
// remove process monitor
if (progressMonitor != null)
progressMonitor.close();
......@@ -874,8 +883,9 @@ public class Index {
}
}
t = System.currentTimeMillis() - t;
if(TTT.verbose){
System.out.println(Constants.getStringFromTime((int) t));
}
recording.graphicsContext.paint_to_offscreen_image = true;
recording.graphicsContext.enableRefresh(true);
}
......@@ -1126,7 +1136,7 @@ public class Index {
in.read(characters);
boolean last_was_blank = false;
if(TTT.verbose){
for (int i = 0; i < characters.length; i++) {
// page devider
if (characters[i] == 12) {
......@@ -1152,7 +1162,7 @@ public class Index {
System.out.print(characters[i]);
}
}
}
} catch (IOException e) {
System.out.println("failed (" + e + ")");
}
......
......@@ -1109,7 +1109,9 @@ public class PostProcessorPanel extends GradientPanel {
// store changes if needed
if (modified) {
if(TTT.verbose){
System.out.println("writing changes to recording");
}
recording.store();
modified = false;
}
......
......@@ -349,11 +349,17 @@ public class ScriptCreator {
return directory.isDirectory();
else
try {
if(TTT.verbose)
System.out.print("create directory: " + directory.getCanonicalPath());
if (!directory.mkdir())
if (!directory.mkdir()){
if(TTT.verbose)
System.out.println(" - FAILED");
}
else
{
if(TTT.verbose)
System.out.println();
}
} catch (IOException e) {}
return directory.exists();
}
......
......@@ -144,12 +144,15 @@ public class FlashContext extends FlashActionHelper {
protected void initialize() throws IOException {
intervalMsec = (double) 1000 / frameRate;
if(TTT.verbose){
System.out.println(" flash frame rate: " + frameRate);
}
if (!batch)
progressMonitor.setProgress(6);
if(TTT.verbose){
// retrieve thumbnailWidth and thumbnailHeight to compute the Frame size
System.out.println(" handle thumbnails");
}
if (!recording.thumbnailsAvailable()) {
if (!batch) {
progressMonitor.setProgress(10);
......@@ -224,18 +227,26 @@ public class FlashContext extends FlashActionHelper {
//if the audio file was renamed from *.mp3 to *.mp3.mp2 and the audio encoding failed undo renaming
file.renameTo(new File(file.getAbsolutePath().substring(0,file.getAbsolutePath().length()-4)));
}
if(TTT.verbose){
System.out.println(" audio failed - cannot create flash movie");
}
throw new IOException("Cannot transcode audio to flash");
}
}
protected void getSoundStreamHead(File file) throws IOException {
if(TTT.verbose){
System.out.println(" loading audio from " + file);
}
FileInputStream mp3 = new FileInputStream(file);
blocks = new ArrayList();
if(TTT.verbose){
System.out.print(" transform audio to flash ... ");
}
head = MP3Helper.streamingBlocks(mp3, frameRate, blocks);
if(TTT.verbose){
System.out.println("done");
}
mp3.close();
}
......@@ -953,8 +964,9 @@ public class FlashContext extends FlashActionHelper {
// ceate the main movieclip
Movie movie = new Movie(recording.prefs.framebufferWidth + thumbnailWidth + 3,
recording.prefs.framebufferHeight + 40, frameRate, FLASH_VERSION, null);
if(TTT.verbose) {
System.out.println(" output movie size: " + movie.getWidth() + "x" + movie.getHeight());
}
// movie.appendFrame();
// the main timeline contain only one frame
Frame frameMovie = movie.appendFrame();
......@@ -1134,8 +1146,10 @@ public class FlashContext extends FlashActionHelper {
void check16000Frames() throws IOException {
if (frameNumb == 16000) {
if(TTT.verbose){
System.out.println(" frame limit reached - split at "
+ Constants.getStringFromTime((int) thumbnailTimestampBy16000Frames));
}
nc = nc + 1;
Frame beforeLastFrame = movieClip.getFrame(frameNumb - 1);
......
......@@ -96,12 +96,12 @@ public class PodcastCreator {
* @throws Exception
*/
public static boolean createPodcast(Recording recording, int resolutionWidth, int resolutionHeight, double framesPerSec, boolean batch) throws Exception {
if(TTT.verbose){
System.out.println("----------------------------------------------");
System.out.println("PodcastCreator");
System.out.println("----------------------------------------------");
System.out.println("Creating mp4 podcast");
}
//check whether the necessary applications are available
String ffmpegCmd = Exec.getCommand(FFMPEG);
if (ffmpegCmd == null) {
......@@ -131,13 +131,16 @@ public class PodcastCreator {
final ProgressMonitor progressMonitor = new ProgressMonitor(TTT.getRootComponent(), null, "building podcast video stream", 0, recording.messages.size()); //time per frame is roughly the same for video and audio encoding
final Exec exec = new Exec();
if(TTT.verbose){
System.out.println("Building podcast video stream from messages");
}
recording.whiteOut();
while (i < recording.messages.size()) {
//draw all messages of the next frame
while (i < recording.messages.size() && recording.messages.get(i).getTimestamp() - outMovieLength <= frameLength) {
recording.deliverMessage(recording.messages.get(i++));
}
//the number of video frames depends on the timestamp of the succeeding message
//if the next message occurs in x frames relative to the current frame, the next window lasts x-1 frames because nothing happens
......@@ -154,8 +157,9 @@ public class PodcastCreator {
if (!batch && i < recording.messages.size()) {
progressMonitor.setProgress(i);
}
if(TTT.verbose){
System.out.println(" Message (" + i + "/" + recording.messages.size() + ")");
}
//create window movie using ffmpeg
//write scaled window image
ImageIO.write(ImageCreator.getScaledInstance(recording.getGraphicsContext().getScreenshot(), resolutionWidth, resolutionHeight, RenderingHints.VALUE_INTERPOLATION_BICUBIC, true), "png", windowImageFile);
......@@ -168,8 +172,9 @@ public class PodcastCreator {
outMovieFile.delete();
outMovieTmpFile.delete();
windowImageFile.delete();
if(TTT.verbose){
System.out.println("Unable to create window movie using ffmpeg:");
System.out.println(exec.getListenerStream());
System.out.println(exec.getListenerStream());}
throw new IOException("unable to create window movie using ffmpeg");
}
if (!batch && progressMonitor.isCanceled()) {
......@@ -179,7 +184,8 @@ public class PodcastCreator {
outMovieTmpFile.delete();
windowImageFile.delete();
progressMonitor.close();
System.out.println("Canceled by user");
if(TTT.verbose){
System.out.println("Canceled by user");}
windowMovieFile.delete();
outMovieFile.delete();
outMovieTmpFile.delete();
......@@ -201,8 +207,9 @@ public class PodcastCreator {
outMovieFile.delete();
outMovieTmpFile.delete();
windowImageFile.delete();
if(TTT.verbose){
System.out.println("Unable join slide movies using MP4Box:");
System.out.println(exec.getListenerStream());
System.out.println(exec.getListenerStream());}
throw new IOException("unable join slide movies using MP4Box");
}
}
......@@ -216,8 +223,10 @@ public class PodcastCreator {
outMovieFile.delete();
windowImageFile.delete();
if(TTT.verbose){
//audio encoding with ffmpeg. The audio stream must be converted via aac to achieve ipod compatibility
System.out.println("Adding audio stream to podcast");
}
Timer timer = null;
if (!batch) {
//the progress of the progress monitor is determined by the frame value ("frame= ") of the ffmpeg output
......@@ -236,7 +245,9 @@ public class PodcastCreator {
scanner.useDelimiter("[ ]+");
if (scanner.findInLine("frame=") != null && scanner.hasNextInt()){
int i = scanner.nextInt();
if(TTT.verbose){
System.out.println(" Frame (" + i + "/" + nFrames + ")");
}
progressMonitor.setProgress(i);
}
exec.getListenerStream().reset();
......@@ -256,7 +267,9 @@ public class PodcastCreator {
outMovieFile.delete();
outMovieTmpFile.delete();
windowImageFile.delete();
if(TTT.verbose){
System.out.println("Canceled by user");
}
return false;
}
progressMonitor.close();
......@@ -264,12 +277,16 @@ public class PodcastCreator {
if (j != 0 || outMovieFile.length() == 0) {
//error while adding audio stream
outMovieFile.delete();
if(TTT.verbose){
System.out.println("Unable add audio stream using ffmpeg:");
System.out.println(exec.getListenerStream());
}
throw new IOException("unable to add audio stream using ffmpeg");
}
if(TTT.verbose){
System.out.println("Podcast created in " + Constants.getStringFromTime((int)(System.currentTimeMillis()-startTime)));
System.out.println("----------------------------------------------");
}
return true;
}
......
......@@ -888,6 +888,7 @@ public void setExtensions(ArrayList<byte[]> ext){
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Writing failed.", "Error:", JOptionPane.ERROR_MESSAGE);
if(TTT.verbose)
System.out.println("Error: Writing failed. " + e.getMessage());
e.printStackTrace();
return false;
......@@ -993,20 +994,20 @@ public void setExtensions(ArrayList<byte[]> ext){
public void createFlash(boolean batch) throws IOException {
pause();
int previousTime = getTime();
if(TTT.verbose){
System.out.println("----------------------------------------------");
System.out.println("TTT2Flash Converter");
System.out.println("----------------------------------------------");
}
long t = System.currentTimeMillis();
FlashContext.createFlash(this, batch);
t = System.currentTimeMillis() - t;
if(TTT.verbose){
System.out.println(" done in " + Constants.getStringFromTime((int) t));
System.out.println("----------------------------------------------");
}
// reset playback
// TODO: reset mode pause/play
setTime(previousTime);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment