Makin' Multiplatform Movies
Dispatch 18
While QuickTime has always let you create movie files which can be
used on any platform, prior to QuickTime 3.0 most movie files created
by QuickTime could only be played on Mac OS based computers. This was
because part of the movie file, the movie resource, was stored in the
file's resource fork. Resource forks are only supported on the Mac OS
platform, so when these files are moved to another platform, such as
Windows, they are unplayable. Prior to QuickTime 3.0, in order to
create a movie which could be played on any platform, it was
necessary to first create the movie file in a Mac OS format, and then
to make a copy of the movie file by calling
FlattenMovieData. While this process is effective, it
was time consuming because a a second copy of the movie had to be
made.
QuickTime 3.0 provides comprehensive support for creating
QuickTime movie files on the Windows platform. Because Windows
doesn't support a file with more than one fork, it isn't possible to
store any part of the movie in the resource fork. Therefore,
QuickTime 3.0 contains several enhancements which enable one step
creation of a single fork movie rather than requiring an extra step,
potentially time consuming, step.
Definin' Those Terms
Before getting into the details of how a multiplatform movie is
made, it is necessary to define the different options for saving a
movie.
- Single fork: This is a movie file which doesn't store
any of its information, typically the movie resource, in its
resource fork. In order for a file to be multi-platform, it must
be single fork.
- Self contained: This is a movie file that doesn't
depend on any external files. A QuickTime movie can reference
media data in more than one file. If a QuickTime movie file
references any media external to the movie file itself, that movie
is not self contained.
- Reference: This is a movie file which does depend on
one or more external files. This is the opposite of a self
contained movie.
- Flat, or flattened: These are other terms for
"self contained".
- Interleaved: This is a movie file that is optimized for
playback in real time. It means that the video and audio (and any
other media data, such as text) are arranged in the file in, more
or less, temporal order. For example, the file begins with the
first second of sound, followed by the first second of video,
followed by the second second of sound, and the second second of
video, etc. A non-interleaved file may store all the video, and
then all the audio. Interleaving is necessary for efficient
playback from a CD-ROM or the Internet.
- Fast Start: This refers to a movie file where the movie
resource is stored (a) in the data fork and (b) as the first atom
in the data fork. Because of the condition that the movie resource
be stored in the data fork, every Fast Start movie is by
definition a single fork movie. In order for a movie to be
streamed on the Internet, i.e. to be able to start playing before
the entire movie is downloaded, it is necessary for the movie to
be stored in Fast Start format.
Some Common Situations
Strictly speaking, for a QuickTime movie file to be usable on
multiple platforms it only needs to be single fork. QuickTime 3.0 is
able to correctly play back movies which contain external references
on all supported platforms. Interleaving and Fast Start will improve
performance in some cases, but they are not required to make the file
portable. However, previous versions of QuickTime for Windows didn't
support reference movies. Therefore, when most people refer to a
multiplatform or cross platform movie, they actually mean a single
fork, self contained movie file.
For sharing of movie files between platforms in an authoring
situation, it is necessary to create single fork movies. If some of
your users will be using an older version of QuickTime to access the
content, you may also want to create self contained movie files.
There is no need in this situation to create a movie which is
interleaved or Fast Start.
If the movie file is to be played from a CD-ROM or DVD-ROM, it
should be created as a single fork, self contained movie. The file
should also be interleaved. While not required, there is a small
performance advantage when opening the movie, if it is a Fast Start
movie.
If the movie file is to be posted on an Internet web site, it
should be created as a single fork, self contained, interleaved Fast
Start movie. This will ensure that the movie can start playing as
quickly as possible after data starts transferring to the users'
machine. (Note that it is actually possible to create valid, well
performing, QuickTime movies for the Internet that have external
references. However, this is not typically done.)
Makin' Movies with AddMovieResource
Many applications create QuickTime movies by calling
CreateMovieFile, followed by a number of calls to
AddMediaSample to add video and sound samples to the
movie, and then AddMovieResource to add the movie
resource to the movie file. Prior to QuickTime 3.0,
AddMovieResource would always place the movie resource
in the movie file's resource fork. In QuickTime 3.0, your application
can now request that the movie resource be placed in the data fork.
Movie's created in this way will be single fork. Depending on the
order that the application added the media data to the file, it may
or may not be interleaved. Because the movie resource is written
after all the media data, the file will not be a Fast Start
movie.
short resourceID = movieInDataForkResID;
AddMovieResource(theMovie, resourceFileRef, &resourceID, nil);
In the past, most applications have either passed in nil for the
resourceID parameter, or they have passed in a pointer
to a resource ID of 128. Note that passing in a resource ID of
movieInDataForkResID in versions of QuickTime prior to
3.0 will not result in the movie resource being put in the data fork.
Also note that even though the resourceFileRef may refer to the
resource fork, particularly on the Mac OS platform, that when
AddMovieResource is called with a resource ID of
movieInDataForkResID, the movie resource will be placed
in the data fork.
AddMovieResource can also be used to create single
fork reference movies as well. By calling
CreateMovieFile, followed by
AddMovieResource as shown above, it is possible to
create a QuickTime reference movie that contains none of its media
data. This can be useful to quickly create snap-shots of an edit
state or media composition.
Makin' Movies with the QuickTime Movie Exporter
QuickTime 3.0 provides an easier way for many applications to
create QuickTime movie files. The new Movie Export API,
MovieExportFromDataProcs, allows an application to
create a QuickTime movie from a set of video frames and audio data.
The major advantage of using MovieExportFromDataProcs is
that QuickTime takes care of all the details of compressing the data,
writing it to the file, and optionally providing the user interface
for configuration of the compression. The same
MovieExportFromDataProcs API can also be used to create
other kinds of files, such DV, Wave, AU, and AIFF.
MovieExportFromDataProcs always creates single fork,
interleaved movie files. As an option, the file can also be created
as a Fast Start movie, although this typically requires duplicating
the data after compression is complete.
Makin' Movies with the Sequence Grabber
QuickTime's sequence grabber API allows QuickTime movie files to
be created by live capture from video digitizers, audio digitizers,
and MIDI inputs. Under QuickTime 3.0, captured movie files are always
created as single fork files. If the application using the sequence
grabber hasn't requested that the movie data be placed in multiple
files, the captured movies will also be self contained. While most
files created with the sequence grabber are interleaved, the way in
which they are interleaved is acceptable for playback from hard disk,
but they are not suitable for playback from CD-ROM or DVD-ROM. Movies
which have been created by live capture should be re-interleaved
using FlattenMovieData before being distributed on a
CD-ROM or DVD-ROM.
Flattenin', Interleavin' and Fast Startin'
If you have an existing movie and want to put it into a particular
format, QuickTime's FlattenMovieData routine can help.
FlattenMovieData will take any movie and optionally make
it self-contained, interleaved, and Fast Start. Note that QuickTime's
Movie Toolbox also provides the FlattenMovie function.
If you want to create multiplatform QuickTime movies, you shouldn't
use FlattenMovie, as it always puts a copy of the movie
resouce in the resource fork.
To create a self contained, single fork, interleaved, and Fast
Start movie, call FlattenMovieData as follows.
Movie aMovie;
aMovie = FlattenMovieData(theMovie,
flattenAddMovieToDataFork | flattenForceMovieResourceBeforeMovieData,
&theOutputFile, OSTypeConst('TVOD'), smSystemScript,
createMovieFileDeleteCurFile | createMovieFileDontCreateResFile);
DisposeMovie(aMovie);
If it isn't necessary to create a Fast Start movie, it may be
somewhat faster to not request this option. This is shown below.
Movie aMovie;
aMovie = FlattenMovieData(theMovie,
flattenAddMovieToDataFork,
&theOutputFile, OSTypeConst('TVOD'), smSystemScript,
createMovieFileDeleteCurFile | createMovieFileDontCreateResFile);
DisposeMovie(aMovie);
See Also
Inside Macintosh: QuickTime - Movie Toolbox
Inside Macintosh: QuickTime Components - Sequence Grabber
Inside Macintosh: QuickTime Components - Movie Export
Components
QuickTime File Format
Change History
6/3/98 - jph - First published
|