Flattening a Movie

Saving a movie can mean different things in QuickTime: saving a reference movie, saving a self-contained movie, or exporting to a different format. Typically, though, the idea of creating a self-contained movie is what users think of as “saving”—they want a single file that doesn’t depend on any others, so they can put it on a server, email it to mom, etc. This process is called “flattening.”

Note

"Flattening” is also an old Mac OS term for turning a file with both a resource fork and a data fork into a single-fork file, suitable for use on non-Mac disk formats. In this book, we use “flatten” only in its QuickTime sense.

How do I do that?

The FlattenableQTEditor is similar to the SaveableQTEditor, adding the menu item and its typical GUI and action-handling support. The flattening is done in a doFlatten( ) method:

public void doFlatten( ) throws QTException { // always attempts to save to a new location, // so prompt for filename FileDialog fd = new FileDialog (this, "Flatten...", FileDialog.SAVE); fd.setVisible(true); // blocks if ((fd.getDirectory( ) = = null) || (fd.getFile( ) = = null)) return; QTFile flatFile = new QTFile (new File (fd.getDirectory( ), fd.getFile( ))); if (flatFile.exists( )) { // JOptionPane is a bit of cheat-for-clarity here, // building a working AWT dialog would be punitive int choice = JOptionPane.showConfirmDialog (this, "Overwrite " + flatFile.getName( ) + "?", "Flatten", JOptionPane.OK_CANCEL_OPTION); if (choice != JOptionPane.OK_OPTION) ...

Get QuickTime for Java: A Developer's Notebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.