1. Install QuickTime 7
http://www.apple.com/quicktime/
2. Copy QTJava.zip
Source : C:\Program Files (x86)\QuickTime\QTSystem\QTJava.zip
Destination : ${JAVA_HOME}/jre/lib/ext
--------------------------------------------------------------------------------
* sample code
--------------------------------------------------------------------------------
package quicktime;
import java.io.File;
import org.apache.commons.lang.time.StopWatch;
import quicktime.io.IOConstants;
import quicktime.io.OpenMovieFile;
import quicktime.io.QTFile;
import quicktime.std.StdQTConstants;
import quicktime.std.movies.Movie;
import quicktime.std.qtcomponents.MovieExporter;
import quicktime.util.QTUtils;
public class QtjConverter {
public static void main(String[] args) {
String src = "c:\\temp\\Wildlife.mov";
String dest = "c:\\temp\\Wildlife.mp4";
StopWatch sw = new StopWatch();
sw.start();
try {
boolean result = qtjConvert(src, dest);
System.out.println("result="+result);
}
catch ( Exception e ) {
e.printStackTrace();
}
sw.stop();
long time = sw.getTime();
System.out.println("time="+time);
}
public static boolean qtjConvert(String src, String dest) throws Exception {
boolean result = false;
QTSession.open();
try {
QTFile movieFile = new QTFile(src);
Movie movie = Movie.fromFile (OpenMovieFile.asRead(movieFile));
//MovieExporter
//new Thread (new Exporter(movie)).start();
QTFile destFile = new QTFile (new File (dest));
// int flags = StdQTConstants.createMovieFileDeleteCurFile |
// StdQTConstants.createMovieFileDontCreateResFile |
// StdQTConstants.showUserSettingsDialog;
int flags = StdQTConstants.createMovieFileDontCreateResFile;
// int type = StdQTConstants.kQTFileTypeMovie;
// type = QTUtils.toOSType("mpg4");
// type = QTUtils.toOSType("MooV");
// MovieExporter exporter = new MovieExporter (StdQTConstants.kQTFileTypeMovie);
// movie.convertToFile(null, destFile, StdQTConstants.kQTFileTypeMovie,
// StdQTConstants.kMoviePlayer, IOConstants.smSystemScript,
// StdQTConstants.showUserSettingsDialog | StdQTConstants.movieToFileOnlyExport
// | StdQTConstants.movieFileSpecValid, exporter);
// movie.convertToFile(destFile, StdQTConstants.kQTFileTypeMovie, 0, 0);
// movie.convertToFile(destFile, StdQTConstants.kQTFileTypeMovie, StdQTConstants.kMoviePlayer, IOConstants.smAllScripts, flags);
// movie.convertToFile(destFile, StdQTConstants.kQTFileTypeMovie, StdQTConstants.kMoviePlayer, IOConstants.smSystemScript, flags);
// movie.convertToFile(destFile, QTUtils.toOSType("MooV"), 0, 0);
movie.convertToFile(destFile, QTUtils.toOSType("mpg4"), 0, 0);
result = true;
}
catch ( Exception e ) {
throw e;
}
QTSession.close();
return result;
}
}
댓글 없음:
댓글 쓰기