Tutorial 12: Movie Playback
Introduction
In this tutorial, we will be focused on the display of movies using Apple’s QuickTime video playback tools. We will also learn about using Max’s built-in file browser to find useful video content, and learn a few ways to manipulate movie playback in realtime.
Apple’s QuickTime system is well-known as a movie-playing mechanism, but it also provides software developers with a rich toolbox for playback and manipulation of many types of media content. The QuickTime developer tools were used to create several objects for Max; one of the most important is the imovie object, which displays video content inside of a patcher. We will use imovie to load and play videos as well as manipulate the playback speed and playback location. We will also learn to load and switch between videos, opening the door for interactive performance patches.
While the imovie object provides a lot of functionality for working with video media within Max, the Jitter set of object extensions for Max provide much more. Once you get comfortable with imovie, you'll find it easy to use its Jitter equivalent jit.qt.movie, which allows you to not only play video but sent it into the Jitter matrix processing system to dynamically add effects, perform compositing operations, and develop more advanced video-based systems.
Basic imovie operation
Open the tutorial.
This file loads with a number of small patches and one large display area - this should initially be showing a number inside cross-hairs. This display area is actually the imovie object, and it allows you to embed a QuickTime movie clip directly inside a patcher. The number with crosshairs is a video clip that the object has loaded when we opened the patcher; it's called countdown15.mov. We will use this instance of imovie, along with several control messages, to display and control QuickTime movie playback.
Just above the imovie object is an array of message boxes that sends commands to the object. The top four messages provide some basic commands: the read message will read in a specified movie file; start will cause it to begin playing; stop will cease playing the file; dispose will remove the current movie from the imovie object's memory. Once you have disposed of the movie, you can reload it again using the read command. Try clicking these message boxes. Note that start begins the movie at the beginning every time you send that message.
Next is a vertical set of five different rate messages. The rate message tells the imovie object to change the playback speed of the movie clip, where the value 1. means normal (forward) playback. A rate of -1. will play the movie backwards at normal speed; rate 0.5 moves the clip forwards at ½ speed. Start the movie's playback (with the start message), then click on the rate messages to see the alteration. Note that sending the message rate 0. pauses the movie where it is. A subsequent rate 1. message (or any other speed) will pick things up where it left off.
When the movie reaches the end, you can click the start message again to restart it. However, just to the right of the rate messages, we can see an alternative to constant restarting: using the loop message to cause the video file to loop over and over. Click on the toggle box to turn on looping. Now you can see that the movie, upon reaching its end, will restart at the beginning – running forever.
The imovie object can also tell us things about the QuickTime movie currently playing. There are many different messages that can be used to query imovie information; you can find out about them in the reference manual pages. One of the most important pieces of information is the duration of the movie – the amount of time for a single iteration of a movie’s playback. This could be used to generate a music score, or just set up a display that helps show where we are in the film. In any case, sending the duration message causes imovie to send the movie’s duration (in milliseconds) out the leftmost outlet of the object.
Using the File Browser
The messages we’ve just tried give us basic control of the imovie object, but having to change the read message any time that we want to add a new file would be rather onerous. One option is to change it to a read message with no argument; this will open a dialog box that lets you pick any file on your computer system. However, perhaps the easiest way to add a new movie to your imovie object is to use the file browser.
You can open a file browser window by selecting New File Browser from the File menu. This presents a window with file names, file types, modification dates, and custom tags – all files that Max determined might be useful for your patcher programming.
Displaying “everything” (the default option) may not be that helpful, but if you search for specific files, you can normally zero into the contents you need. For example, in the search box at the top right of the browser, enter in the file suffix .mov. This is the file extension often used for QuickTime movies; searching for this text will display all of the files with .mov as part of their name.
The browser is also able to do a search based on the type of file you need (rather than just its name). Clear out the search box, then hit the + button to its right. Another pane of search criteria is displayed at the top of the window. The drop-down menu at the left lets you choose the field to search – if we change it to “Kind”, then select “moviefile”, we quickly get the list of all movies, whether using the .mov extension or some other movie identifier. If this is a search you are going to use often, you can add it to the file browser window by clicking on the + button at the bottom of the window; this allows us to save searches for use later.
Now that we have the list of available movies displayed, we can grab a movie by name and drag it onto the imovie object to open it. Click on one of the files by name (or any other column, really) and drag it to the patcher window. When you hover over the imovie object, you should see a blueish border appear in the object – this means that it can be a recipient of the file you are dragging. Releasing the mouse at this point will load the movie file into the imovie object.
Using the mouse to alter rate
During our first experiments with this patch, we used rate messages to determine the speed of playback; we also noted that rates greater than 0. caused forward playback while rates less than 0. caused reverse playback. We are going to use this concept, along with some mouse-tracking, to perform some realtime video scrubbing/scratching.
In the section of the patch labeled 1, you will see that a metro is set up to poll a mousestate object, and the second outlet (the horizontal location of the mouse) is being used. The value is displayed and scaled (through a scale object) into a value that will range from -2. to 2. (or greater, if your screen is wider than 1024 pixels wide). The result is used to create a rate message that is sent to the imovie.
If we turn on the metro with the toggle box, we will see the horizontal mouse location being tracked in this portion of the patch. Start the movie (with the start message) and turn on looping (with the toggle box connected to the loop $1 message). Move the mouse across the screen – you will see it speed up, slow down and reverse direction depending on the current mouse position. Going “through zero” (producing positive numbers that move through zero and back into higher negative numbers) produces the typical scratching function we’ve come to identify as a useful VJ manipulation.
Using the mouse to alter playback point
Turn off the metro in section 1, and turn on the metro in section 2. This small sub-patch is very similar to the first – we are tracking mouse movements and turning them into video playback messages. In this case, we are using the vertical mouse location to set the current playback position. In order for this to work correctly, you will need the duration of the current movie, which you can get by clicking on the duration message box (found just above the loop selector at the top of the patch).
Once the proper duration has be communicated to our patch, we can see that changes to the vertical mouse position will be scaled to the range 010000 (for the "countdown" video) and sent to the imovie inlet. The imovie object treats incoming integers as “current position” settings, and the movie will immediately jump to that position.
By default, however, once the position is set it will just keep playing at its current speed. The behavior of QuickTime movies is that they are always running at their current rate; if you want to completely control the playback location of the movie, you will need to start by setting the rate to 0. If we do this (using the rate 0. message box), vertical mouse moves will now allow us to maneuver through the movie in frame-by-frame steps.
Switching between several movies
Another way that we can control the imovie output is by loading and switching between several movies. Unlike many other media-related objects, imovie can load several different movie files, then can use the switch message to jump among the files to determine which one is active.
The segment of the patch labeled 3 is the area that shows how to load and cue multiple videos. In this case, four files are pulled from the search path and read into the imovie object through the message box at the top. Next, we have a key object watching user keyboard entry; the letters “a”, “s”, “d” and “f” (ASCII 97, 115, 100, and 102, respectively) are each mapped using the select object to a switch statement (followed by a start message to restart the video). If you click on the four-part read message box, you can see that the videos have been loaded. Now, using one of the 4 files, type “a”, “s”, “d” or “f” on the keyboard to select the movie you want to display. You can do this as rapidly as you wish; since the movie files are already loaded into the imovie object, there will be little latency when switching between them.
Conclusion
We’ve focused on the imovie object, which allows us to play and manipulate video content. In addition to simply playing and stopping movies, we’ve learned to alter the playback speed with messages and with mouse movement; we’ve also learned how to use mouse movement to change the current playback position. Finally, we learned that imovie can have many movies loaded, and a simple patch can accept keyboard input and perform high-speed movie switching. All of this builds on the simple commands provided by the imovie object.

See Also

Name Description
imovie Play a QuickTime movie in a patcher window