Writing QuickTime movies in pure Java
In my article ‘Writing QuickTime videos in pure Java’, I said I would integrate audio support if I would get the right incentives (wine or books). This has happened, and so I have implemented an all new class named QuickTimeWriter, which supports writing of audio and video data into a QuickTime Movie file in pure java.
The JavaDoc of the QuickTimeWriter class is available here.
The class is still in a very early stage. Right now, it can be used for combining a single audio track with a single video track.
Audio has to be encoded before it can be written. I tried to make this as simple as possible by supporting javax.sound.sampled.AudioFormat in one of the addAudioTrack() methods.
As with my previous implementation, QuickTimeWriter provides a minimal set of encoders for video data. It includes encoders for the following compression formats: PNG, Photo-JPEG, Apple Animation (RLE) and None (Raw). Other encodings are possible, but you have to encode the frames by yourself.
QuickTimeWriter stores samples in the same sequence in the movie file as they are written. If a movie is created for further processing, the samples can be written in any order. If the movie shall be playable, samples of multiple tracks should be interleaved about twice per second. I have described this in more detail in the class comments.
I have also created a small demo program which shows how to put it all together:
The demo along with all the source files can be downloaded here: QuickTimeDemo2.jar.
The code can be licensed under Creative Commons Attribution 3.0.
Update 2012-02-04: The demo code described in this article is obsolete. The latest version of the code is available on the following page: http://www.randelshofer.ch/monte
Update 2011-01-07: Supports now web-optimized movies with compressed header at the start of the file.
Update 2011-01-06: Supports now Apple Animation (RLE) compression.
Update 2011-01-04: Supports now MP3 sound files.