Creating One-Source Effects (Filters)

Filtering a video track by applying an effect to it is a critically important tool for doing color correction, adding special effects like lens flare, or offering novelties such as converting the video to black and white or pseudo-antique sepia tone. The technique of creating the effect is effectively the same as with zero-source effects, although in this case you need to create an object that tells the effect where its video source comes from.

How do I do that?

You create a one-source effect just like you do the zero-source version—create a track, create video media, get an EffectsList (this time of one-source effects), and get an AtomContainer describing an effect from a ParameterDialog.

But before adding the AtomContainer as the effects media sample, you need to map it to a video source, which is another video track in the movie. You do this by creating an input map, which is an AtomContainer indicating the sources that are inputs to an effect. Next, create a track modifier reference to redirect the track’s output to the effect. You use the reference in building up the Atoms in the input map. Once built, the input map is set on the effect’s media with setInputMap() .

Example 9-4 exercises this technique by opening a movie, getting its first video track, and applying a user-selected filter to it.

Note

Run this example with ant run-ch09-filtertrackbuilder.ks.

Example 9-4. Creating a one-source effect (filter)

package com.oreilly.qtjnotebook.ch09; ...

Get QuickTime for Java: A Developer's Notebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.