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:
Import an image.
Pick source and destination rectangles.
Calculate a series of rectangles between the source and destination. These represent which part of the source image will be used for each frame.
Create an empty movie, new video track, and new video media.
Use a
Matrixto convert each source rectangle to the size of the movie.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, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access