Skip to content

Writing QuickTime movies in pure Java

by werner on October 7th, 2010

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:

Screenshot of the QuickTimeWriter demo application.

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:

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.

From → Image & Video, Java

  1. This looks great! And its very timely as QTJ has left us.

  2. This is really awesome. I want write some mp4 files so I started going through the QT file format spec. This demo and source looks like it will save me a lot of time.

  3. Mauricio Rubio permalink

    Hello, I’m trying to implement your class to use in a Android project, but as there is missing libraries from Java in Android SDK I can’t make it work. Do you think it is easy to port it for Android? What’s the possibility that you help me to do that?


  4. Hi Mauricio,

    I have no experience with Android. But from looking at the Android API, I think a port to Android can be done in a few hours. It looks like there are corresponding classes in Android for everything that the QuickTimeWriter needs.

    Contact me by e-mail if you would like me to help, and you are willing to spend an amazon gift card or a bottle of wine for my services.

  5. Dale Stammen permalink

    Hi Werner,

    Your java quicktime file writer looks perfect for an Android project I am about to start. I would be happy to contribute an Amazon gift card or great bottle of wine to have the class work for Android.



  6. Jamie permalink

    Your screen recorder demo look and works great! But there doesn’t seem to be any source code in that JAR. Is that intentional?

  7. Hi Jamie,

    The screen recorder demo is obsolete. Please take a look at the Monte Media Library for newer versions of this class.

Trackbacks & Pingbacks

  1. Writing QuickTime videos in pure Java | Werner Randelshofer's Blog

Comments are closed.