Commit d92ef0c0 authored by ludwig's avatar ludwig
Browse files

another bugfix

git-svn-id: https://www2.in.tum.de/repos/ttt/trunk@100 0463f305-d864-43cb-8a47-61cf597d4139
parent c1c98365
...@@ -82,9 +82,22 @@ public class PodcastCreator { ...@@ -82,9 +82,22 @@ public class PodcastCreator {
* @throws Exception * @throws Exception
*/ */
public static boolean createPodcast(Recording recording, boolean batch) throws Exception { public static boolean createPodcast(Recording recording, boolean batch) throws Exception {
return createPodcast(recording, RESOLUTION_WIDTH, RESOLUTION_HEIGTH, FRAMES_PER_SEC, batch); return createPodcast(recording, RESOLUTION_WIDTH, RESOLUTION_HEIGTH, FRAMES_PER_SEC, batch, true);
} }
/**
* Creates podcast using default parameters
* @param recording
* @param batch
* @return True: Podcast created successfully.<br>False: Canceled by user.
* @throws Exception
*/
public static boolean createPodcast(Recording recording, boolean batch,boolean ShowProgressmonitor) throws Exception {
return createPodcast(recording, RESOLUTION_WIDTH, RESOLUTION_HEIGTH, FRAMES_PER_SEC, batch, ShowProgressmonitor);
}
/** /**
* Creates podcast * Creates podcast
* @param recording * @param recording
...@@ -95,7 +108,7 @@ public class PodcastCreator { ...@@ -95,7 +108,7 @@ public class PodcastCreator {
* @return True: Podcast created successfully.<br>False: Canceled by user * @return True: Podcast created successfully.<br>False: Canceled by user
* @throws Exception * @throws Exception
*/ */
public static boolean createPodcast(Recording recording, int resolutionWidth, int resolutionHeight, double framesPerSec, boolean batch) throws Exception { public static boolean createPodcast(Recording recording, int resolutionWidth, int resolutionHeight, double framesPerSec, boolean batch, final boolean ShowProgressmonitor) throws Exception {
if(TTT.verbose){ if(TTT.verbose){
System.out.println("----------------------------------------------"); System.out.println("----------------------------------------------");
System.out.println("PodcastCreator"); System.out.println("PodcastCreator");
...@@ -128,8 +141,15 @@ public class PodcastCreator { ...@@ -128,8 +141,15 @@ public class PodcastCreator {
int vFrames; //number of video frames of window movie int vFrames; //number of video frames of window movie
int i = 0; int i = 0;
int j; int j;
//TODO the handling of the ProgressMonitor is INSANELY dirty
final ProgressMonitor progressMonitor;
if(ShowProgressmonitor){
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
}else{
progressMonitor = null;
}
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(); final Exec exec = new Exec();
if(TTT.verbose){ if(TTT.verbose){
System.out.println("Building podcast video stream from messages"); System.out.println("Building podcast video stream from messages");
...@@ -154,7 +174,7 @@ public class PodcastCreator { ...@@ -154,7 +174,7 @@ public class PodcastCreator {
} }
outMovieLength += vFrames * frameLength; outMovieLength += vFrames * frameLength;
if (!batch && i < recording.messages.size()) { if (ShowProgressmonitor && !batch && i < recording.messages.size()) {
progressMonitor.setProgress(i); progressMonitor.setProgress(i);
} }
if(TTT.verbose){ if(TTT.verbose){
...@@ -177,13 +197,14 @@ public class PodcastCreator { ...@@ -177,13 +197,14 @@ public class PodcastCreator {
System.out.println(exec.getListenerStream());} System.out.println(exec.getListenerStream());}
throw new IOException("unable to create window movie using ffmpeg"); throw new IOException("unable to create window movie using ffmpeg");
} }
if (!batch && progressMonitor.isCanceled()) { if (ShowProgressmonitor & !batch && progressMonitor.isCanceled()) {
//canceled by user //canceled by user
windowMovieFile.delete(); windowMovieFile.delete();
outMovieFile.delete(); outMovieFile.delete();
outMovieTmpFile.delete(); outMovieTmpFile.delete();
windowImageFile.delete(); windowImageFile.delete();
progressMonitor.close(); if(ShowProgressmonitor){
progressMonitor.close();}
if(TTT.verbose){ if(TTT.verbose){
System.out.println("Canceled by user");} System.out.println("Canceled by user");}
windowMovieFile.delete(); windowMovieFile.delete();
...@@ -231,12 +252,14 @@ public class PodcastCreator { ...@@ -231,12 +252,14 @@ public class PodcastCreator {
if (!batch) { if (!batch) {
//the progress of the progress monitor is determined by the frame value ("frame= ") of the ffmpeg output //the progress of the progress monitor is determined by the frame value ("frame= ") of the ffmpeg output
final int nFrames = recording.getDuration()/1000; final int nFrames = recording.getDuration()/1000;
if(ShowProgressmonitor){
progressMonitor.setNote("adding audio stream to podcast"); progressMonitor.setNote("adding audio stream to podcast");
progressMonitor.setMaximum(nFrames); progressMonitor.setMaximum(nFrames);
progressMonitor.setProgress(0); progressMonitor.setProgress(0);
}
timer = new Timer(1000, new ActionListener() { timer = new Timer(1000, new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (progressMonitor.isCanceled()) { if (ShowProgressmonitor && progressMonitor.isCanceled()) {
exec.abort(); exec.abort();
} }
//get the value after "frame=" of the last line //get the value after "frame=" of the last line
...@@ -248,7 +271,8 @@ public class PodcastCreator { ...@@ -248,7 +271,8 @@ public class PodcastCreator {
if(TTT.verbose){ if(TTT.verbose){
System.out.println(" Frame (" + i + "/" + nFrames + ")"); System.out.println(" Frame (" + i + "/" + nFrames + ")");
} }
progressMonitor.setProgress(i); if(ShowProgressmonitor){
progressMonitor.setProgress(i);}
} }
exec.getListenerStream().reset(); exec.getListenerStream().reset();
} }
...@@ -261,7 +285,7 @@ public class PodcastCreator { ...@@ -261,7 +285,7 @@ public class PodcastCreator {
outMovieTmpFile.delete(); outMovieTmpFile.delete();
if (!batch) { if (!batch) {
timer.stop(); timer.stop();
if (progressMonitor.isCanceled()) { if (ShowProgressmonitor&&progressMonitor.isCanceled()) {
//canceled by user //canceled by user
windowMovieFile.delete(); windowMovieFile.delete();
outMovieFile.delete(); outMovieFile.delete();
...@@ -272,7 +296,8 @@ public class PodcastCreator { ...@@ -272,7 +296,8 @@ public class PodcastCreator {
} }
return false; return false;
} }
progressMonitor.close(); if(ShowProgressmonitor){
progressMonitor.close();}
} }
if (j != 0 || outMovieFile.length() == 0) { if (j != 0 || outMovieFile.length() == 0) {
//error while adding audio stream //error while adding audio stream
......
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