fixed moviemaker for 0125

This commit is contained in:
benfry
2007-06-24 05:06:33 +00:00
parent eb5fc6d87f
commit 22e1ba3409
2 changed files with 90 additions and 85 deletions
+49 -24
View File
@@ -55,14 +55,56 @@ X no longer default to sketchbook folder on open
0125p4 (in progress)
_ keywords/reference
_ map is going to null reference, not colored properly
_ general issue when reference not found, going to 'null' reference
_ do a trim() on the selection for find in reference
_ ocd is broken - do a better error message for this
_ moviemaker is broken
X map is going to null reference, not colored properly
X add beginRaw, endRaw, map to keywords.txt
X general issue when reference not found, going to 'null' reference
X do a trim() on the selection for find in reference
X reorganize find in reference commands
X add setDTR() method from tom hulbert
X moviemaker is broken
_ made changes to keywords.txt, but this is broken--it's autogenerated
_ ocd is broken in 0125 - do a better error message for this
_ save/saveas should use modal dialog
_ only use the bottom bar for naming
_ "Object" example isn't using tabs.. others?
_ object example is also much too complicated
X implement sortCompare() and sortSwap()
_ discuss this with casey
_ also could be using Arrays.sort(blah) with Comparable (1.2+)
_ sort functions to be made public?
_ find in reference problems
_ ? doesn't work with find in reference (actually came up as 'null')
_ "find in ref" on XMLElement brings up ref for null (ha)
_ should we use if() or if in the reference
_ disallow .java tabs with same name as the sketch
_ a .java tab with same name as the sketch is allowed (oog!)
_ particularly look at "save as" scenario
_ http://dev.processing.org/bugs/show_bug.cgi?id=543
_ bug report:
_ create a new sketch, write something in it
_ create a new tab, name it "something.java", write something into it
_ rename main tab (sketch) to "something" (without ".java")
_ the contents in the files are not the same, but the main-tab is
_ showing the contents of the .java tab, so if you press save
_ you will overwrite your original code from the main-tab.
// from color sorting example
float sortCompare(int a, int b) {
return bright[a] - bright[b];
}
void sortSwap(int a, int b) {
int t1 = bright[a];
bright[a] = bright[b];
bright[b] = t1;
Tuple t2 = captureColors[a];
captureColors[a] = captureColors[b];
captureColors[b] = t2;
}
new bugs
@@ -88,25 +130,6 @@ _ tho charset + gzip would be a problem
_ hint(ENABLE_AUTO_GUNZIP) or rather hint(DISABLE_AUTO_GUNZIP)
_ ? doesn't work with find in reference
_ actually came up as 'null'
_ should we use if() or if in the reference
_ disallow .java tabs with same name as the sketch
_ a .java tab with same name as the sketch is allowed (oog!)
_ particularly look at "save as" scenario
_ http://dev.processing.org/bugs/show_bug.cgi?id=543
_ bug report:
_ create a new sketch, write something in it
_ create a new tab, name it "something.java", write something into it
_ rename main tab (sketch) to "something" (without ".java")
_ the contents in the files are not the same, but the main-tab is
_ showing the contents of the .java tab, so if you press save
_ you will overwrite your original code from the main-tab.
_ "find in ref" on XMLElement brings up ref for null (ha)
LIBRARIES / Net
_ move the useful serial buffering fxns into net library
@@ -115,6 +138,8 @@ _ http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Syntax;action=displ
_ add an event to Server that notifies when a Client disconnects
_ proccessing.net.Client.write(int) terminates sketch when client disconnects.
_ http://dev.processing.org/bugs/show_bug.cgi?id=537
_ is this the same issue?
_ http://processing.org/discourse/yabb_beta/YaBB.cgi?board=LibraryProblems;action=display;num=1180713192
_ Server.write(bytes[]) hangs sketch on client disconnect.
_ http://dev.processing.org/bugs/show_bug.cgi?id=538
+41 -61
View File
@@ -4,6 +4,7 @@
Part of the Processing project - http://processing.org
Copyright (c) 2006 Daniel Shiffman
With minor modifications by Ben Fry for Processing 0125+
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -23,6 +24,8 @@
package processing.video;
import java.io.File;
import quicktime.Errors;
import quicktime.QTException;
import quicktime.QTSession;
@@ -64,8 +67,8 @@ import processing.core.*;
*
* // Create MovieMaker object with size, filename,
* // compression codec and quality, framerate
* mm = new MovieMaker(this, width, height, "drawing.mov",
* MovieMaker.H263, MovieMaker.HIGH, 30);
* mm = new MovieMaker(this, width, height, "drawing.mov", 30,
* MovieMaker.H263, MovieMaker.HIGH);
* background(160, 32, 32);
* }
*
@@ -85,7 +88,7 @@ import processing.core.*;
* void keyPressed() {
* // Finish the movie if space bar is pressed!
* if (key == ' ') {
* mm.stop();
* mm.finish();
* }
* }
* </PRE>
@@ -93,7 +96,6 @@ import processing.core.*;
public class MovieMaker {
public static final int RAW = StdQTConstants.kRawCodecType;
public static final int ANIMATION = StdQTConstants.kAnimationCodecType;
public static final int BASE = StdQTConstants.kBaseCodecType;
public static final int BMP = StdQTConstants.kBMPCodecType;
@@ -102,6 +104,10 @@ public class MovieMaker {
public static final int CMYK = StdQTConstants.kCMYKCodecType;
public static final int GIF = StdQTConstants.kGIFCodecType;
public static final int GRAPHICS = StdQTConstants.kGraphicsCodecType;
public static final int H261 = StdQTConstants.kH261CodecType;
public static final int H263 = StdQTConstants.kH263CodecType;
// H.264 encoding, added because no constant is available in QTJava
public static final int H264 = QTUtils.toOSType("avc1");
public static final int JPEG = StdQTConstants.kJPEGCodecType;
public static final int MS_VIDEO = StdQTConstants.kMicrosoftVideo1CodecType;
public static final int MOTION_JPEG_A = StdQTConstants.kMotionJPEGACodecType;
@@ -109,11 +115,6 @@ public class MovieMaker {
public static final int SORENSON = StdQTConstants.kSorensonCodecType;
public static final int VIDEO = StdQTConstants.kVideoCodecType;
public static final int H261 = StdQTConstants.kH261CodecType;
public static final int H263 = StdQTConstants.kH263CodecType;
// H.264 encoding, added because no constant is available in QTJava
public static final int H264 = QTUtils.toOSType ("avc1");
public static final int WORST = StdQTConstants.codecMinQuality;
public static final int LOW = StdQTConstants.codecLowQuality;
public static final int MEDIUM = StdQTConstants.codecNormalQuality;
@@ -192,22 +193,14 @@ public class MovieMaker {
height = _h;
rate = _rate;
// Start QT
//if (!QTSession.isInitialized()) { // [fry]
try {
QTSession.open();
} catch (QTException e1) {
e1.printStackTrace();
}
//}
// Create GWorld
try {
// Broken on intel?
// ImageDescription imgD =
// new ImageDescription(QDConstants.k32ARGBPixelFormat);
ImageDescription imgD = null;
// Intel fix, could it be?? I think this takes care of Windows too?!?!?
if (quicktime.util.EndianOrder.isNativeLittleEndian()) {
imgD = new ImageDescription(QDConstants.k32BGRAPixelFormat);
} else {
@@ -230,20 +223,9 @@ public class MovieMaker {
private void initMovie(String filename) {
// If nothing has been specified
if (codecType == 0) {
System.out.println("No code type specified, using default of RAW");
codecType = RAW;
}
if (codecQuality == 0) {
System.out.println("No code quality specified, using default of HIGH");
codecQuality = HIGH;
}
try {
String path = parent.savePath(filename);
System.out.println("Creating movie file: " + path);
movFile = new QTFile (new java.io.File(path));
movFile = new QTFile(new File(path));
movie = Movie.createMovieFile(movFile, StdQTConstants.kMoviePlayer, StdQTConstants.createMovieFileDeleteCurFile);
int timeScale = TIME_SCALE; // 100 units per second
videoTrack = movie.addTrack(width, height, 0);
@@ -259,16 +241,22 @@ public class MovieMaker {
readyForFrames = true;
} catch (QTException e) {
// if it's a -8961 error, do it the other way
if (e.errorCode() == Errors.noCodecErr) {
//System.out.println("Temporal compression not supported, switching modes. ");
temporalSupported = false;
readyForFrames = true;
if (imageHandle == null) {
// This means QTImage.getMaxCompressionSize() failed
System.err.println("The specified codec is not supported, " +
"please ensure that the parameters are valid, " +
"and in the correct order.");
} else {
// If it's a -8961 error, quietly do it the other way
// (this happens when RAW is specified)
temporalSupported = false;
readyForFrames = true;
}
} else if (e.errorCode() == Errors.fBsyErr) {
System.err.println("Movie file already exists. " +
"Please delete it first. " +
"(DS to solve this eventually.)");
System.err.println("The movie file already exists. " +
"Please delete it first.");
} else {
e.printStackTrace();
@@ -285,11 +273,6 @@ public class MovieMaker {
public void addFrame(int[] _pixels, int w, int h) {
// Now that I fixed the intel mac bug in the constructor, I think windows
// is covered too so the code below is unnecessary. I think. I hope.
//boolean windows = false;
//String os = System.getProperty("os.name");
//if (os.charAt(0) == 'w' || os.charAt(0) == 'W') windows = true;
if (readyForFrames){
RawEncodedImage pixelData = gw.getPixMap().getPixelData();
int rowBytes = pixelData.getRowBytes() / 4;
@@ -298,12 +281,9 @@ public class MovieMaker {
for (int j = 0; j < h; j++) {
if (i < w) {
newpixels[i+j*rowBytes] = _pixels[i+j*w];
// We can skip this now, right?!?!?!?
// On windows, we have to flip the pixels (i think)
//if (!windows) newpixels[i+j*rowBytes] = _pixels[i+j*w];
//else newpixels[i+j*rowBytes] = EndianOrder.flipBigEndianToNative32(_pixels[i+j*w]);
} else {
newpixels[i+j*rowBytes] = 0;
}
else newpixels[i+j*rowBytes] = 0;
}
}
pixelData.setInts(0,newpixels);
@@ -332,27 +312,27 @@ public class MovieMaker {
/**
* Close out and finish the movie file.
*/
public void stop() {
System.out.println("Finishing movie file.");
public void finish() {
try {
readyForFrames = false;
videoMedia.endEdits();
videoTrack.insertMedia(0, 0, videoMedia.getDuration(), 1);
OpenMovieFile omf = OpenMovieFile.asWrite(movFile);
movie.addResource(omf, StdQTConstants.movieInDataForkResID,
movFile.getName());
} catch (StdQTException e) {
e.printStackTrace();
} catch (QTException e) {
e.printStackTrace();
if (readyForFrames) {
//System.out.println("Finishing movie file.");
readyForFrames = false;
videoMedia.endEdits();
videoTrack.insertMedia(0, 0, videoMedia.getDuration(), 1);
OpenMovieFile omf = OpenMovieFile.asWrite(movFile);
movie.addResource(omf, StdQTConstants.movieInDataForkResID,
movFile.getName());
}
} catch (StdQTException se) {
se.printStackTrace();
} catch (QTException qe) {
qe.printStackTrace();
}
// Causes windows to hang??
//QTSession.close();
}
public void dispose() {
if (readyForFrames) stop();
if (readyForFrames) finish();
try {
QTSession.close();