Skip to content

Writing QuickTime videos in pure Java

by werner on June 21st, 2008

Jeremy Woods wrote an article with some brilliant Java classes which can write QuickTime videos with JPEG encoded video frames.

I wanted to write a lossless QuickTime video encoder for a long time, so I couldn’t resist taking Jeremy’s code, and see whether it was possible to add support for PNG encoded video frames.

After tinkering with the code a bit, I decided rewriting it entirely by reusing designs I had seen in the Amiga IFF library. I also added support for large movie files (larger than 4 GB).

The QuickTimeOutputStream class is freely available as part of my CubeTwister source code.

You can download a small demo which only contains the QuickTimeOutputStream and all necessary sources here: QuickTimeDemo.jar. Running the demo will create a JPEG-encoded and a PNG-encoded QuickTime movie.

Update 2010-10-07: This article is obsolete. Please take a look at my new article “Writing QuickTime movies in pure Java”.

From → Image & Video, Java

12 Comments
  1. Melinda Squibb permalink

    Is it possible to use this code for an educational institution? What are the terms of your copyright license?

  2. Hi Melinda,

    QuickTimeDemo is free for all uses (personal, educational, commercial, …). The terms of the Creative Commons Attribution 3.0 license apply:
    http://creativecommons.org/licenses/by/3.0/

    If you download the QuickTimeDemo.jar again, you’ll find a file named license.html inside of it, which contains these license terms as well.

    With best regards,
    Werner

  3. Melinda Squibb permalink

    Thanks, this is a great help. A problem can arise in your code in ImageDirToMovMain.test if the first file in the directory is a hidden file.

  4. Thanks Melinda,
    I have fixed this now.
    Cheers,
    Werner

  5. According to the license—

    Attribution. You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work).

    How would you like to be referenced in the work???

  6. @AO,

    I would like licensors to keep the reference to me in the headers of my source files.
    That will do.

    Of course, if you do have a section in your program or accompanying documentation which mentions all software components it uses, I don’t mind being listed there.

    -Werner

  7. Jay permalink

    Hi Werner,

    Thanks for the work. It really works very well. Any plan to add audio support for the encoder ? I would think that sound would be more difficult to implement.

  8. Hi Jay,

    I have no plans for adding audio support to this class. I want to keep it simple.

    The Java Media Framework (JMF) provides a QuickTime multiplexer which can do what you need.

    Sound support is indeed a little bit more complex. Supporting uncompressed PCM data is not that hard though. The audio samples need to be fed in chunks to the output stream – for example, one second of audio data at a time – and the corresponding track headers need to be written.
    (Maybe writing compressed audio data is not much harder either – I think the chunks just need to be done at ‘frame’ boundaries of the compressed stream.)

    I have plans for writing a simple QuickTimeMultiplexer class which will support multiple video tracks. If you are willing to send me a bottle of good wine or an Amazon gift certificate, I can include support for uncompressed audio tracks as well, and publish it here in an article.

  9. Jay permalink

    Hi Werner,

    Can you send me an email ?

Trackbacks & Pingbacks

  1. Werner Randelshofer’s Blog » Blog Archive » Writing AVI videos using pure Java
  2. Writing AVI videos in pure Java | Werner Randelshofer's Blog
  3. Writing QuickTime movies in pure Java | Werner Randelshofer's Blog

Comments are closed.