O'Reilly logo

QuickTime for Java: A Developer's Notebook by Chris Adamson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Building a Video Track from Raw Samples

You can create a video track “from scratch” by adding video samples, one by one, to the video media. This is perhaps the ultimate in low-level access to QuickTime video, because it makes you responsible for every pixel in every frame. One way to demonstrate this is by making a movie from a still image and using slightly different parts of it in each frame to suggest a camera moving across the image.

Tip

This concept is called the “Ken Burns Effect” in Apple’s iMovie, after the documentary filmmaker who used the technique extensively in documentaries like The Civil War, for which no film or video sources were available.

How do I do that?

To build a movie from samples taken from an image, use the following approach:

  1. Import an image.

  2. Pick source and destination rectangles.

  3. Calculate a series of rectangles between the source and destination. These represent which part of the source image will be used for each frame.

  4. Create an empty movie, new video track, and new video media.

  5. Use a Matrix to convert each source rectangle to the size of the movie.

  6. Compress each frame and add it to the VideoMedia.

You might already know how to do some of this; the new part is how to compress frames into a movie. Chapter 5 made use of the QTImage.compress( ) method to compress QDGraphics (a.k.a. GWorlds) into EncodedImages, but video is a little different in that you use a CSequence, short for compression sequence. The difference is that in many video compression formats, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required