Saving a Movie with Dependencies

The opposite of flattening is saving a movie with dependencies. In this type of a save, the resulting file just contains pointers to the sources of the media in each track. The file typically is tiny, usually just 8 KB or less.

How do I do that?

The RefSaveableQTEditor example extends the FlattenableQTEditor with a “Save w/Refs” menu item that calls doRefSave():

public void doRefSave( ) throws QTException {
  // if no home file, then prompt for one
  if (file =  = null) {
      FileDialog fd = new FileDialog (this,
                                      "Save...",
                                      FileDialog.SAVE);
      fd.setVisible(true); // blocks
      if ((fd.getDirectory( ) =  = null) ||
          (fd.getFile( ) =  = null))
          return;
      file = new QTFile (new File (fd.getDirectory( ),
                                   fd.getFile( )));
  }
  // save ref movie to file
  if (! file.exists( )) {
      file.createMovieFile(StdQTConstants.kMoviePlayer,
                           StdQTConstants.createMovieFileDontCreateResFile);
  }
  OpenMovieFile outFile =
      OpenMovieFile.asWrite(file);
  movie.updateResource (outFile,
                        StdQTConstants.movieInDataForkResID,
                        null);
}

Note

Compile and run this example with ant run-ch03-refsaveableqt-editor.

When run, this creates a movie file that, despite its tiny size, behaves exactly like any other movie file. Double-click it and it will open in QuickTime Player, just like a self-contained movie. QuickTime completely isolates the user from the fact that the file contains nothing more than metadata and pointers to the source media files.

Of course, there are limits to what QuickTime can do if those pointers ...

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.