This tutorial shows how you can record a single matrix or a sequence of matrices to disk as a QuickTime movie. We'll demonstrate the use of the jit.qt.record
object for recording in real time and non-real time. Along the way, we'll also show you how to adjust some of the settings of the output movie.
Like most Jitter objects, the jit.qt.record
object operates according to an event-driven model rather than a time-driven one -- frames sent to a record-enabled jit.qt.record
object are appended to the movie in progress as "the next frame" based on the timing characteristics of the output movie, without regard for the relative time between the arriving frames. This results in very smooth movies with consistent timing between frames, but it requires some preparation before recording.
object also offers a time-driven (realtime) method of recording in addition to the default mode described in this tutorial. Although the realtime mode might seem simpler to use, the recorded output won't be as smooth because frames of the incoming movie will usually be dropped fairly regularly during recording. You can set the time-driven mode for the jit.qt.record
object by using the message, but it is quite different from the realtime operation described in this tutorial.
Each and every matrix that arrives at a recording jit.qt.record
object must be compressed before becoming part of your output movie. The speed of this compression depends on several factors: the speed of your processor and your disk drive, and -- most importantly -- the type of compression used (referred to as the codec
, short for co
ompression). The examples in this tutorial will use the Photo-JPEG codec. It should yield fairly consistent results from machine to machine without a lot of high CPU usage and disk access. On older or slower systems, it's possible that you'll notice some timing inaccuracy with the first set of examples for this tutorial. If you do, don't worry; the second part of this tutorial will show you how to achieve excellent results on even the most modest system by working in non-realtime mode.
The first example shows a very basic recording setup. Notice that the jit.qt.record
object takes two arguments ( and ) that specify the width and height of any movies we record with this object.
• Click the message
box that says to load a movie into the jit.qt.movie
object, and start the metro
object by clicking on the toggle
box connected to its inlet. You will see the movie's image appear in the jit.pwindow
object, since the jit.qt.record
object passes any matrices it receives out its left outlet. (The jit.robcross
object in this patch is a simple edge detector that we're using to process the matrices passing through it).
• Click the message
box that says . to start writing the movie (we'll look at the contents of the message
box in more detail in a moment). A file Dialog Box will appear, prompting you for a file name. When you enter a valid name and click the Save button, recording begins to the filename you've chosen (For the purposes of example, let's assume you've named your movie myfilename.mov
.). Click the message
box to stop recording.
object sends a message out its right outlet after a write operation to confirm that the movie was successfully written. Since we've connected that outlet to a print
object in our patch , we can see the results by looking at the Max Window. If everything went as expected, you should see in the Max Window. If there was a problem, the number after the filename will not be a .
• Click the message
box attached to the jit.qt.movie
object and read in the movie you just recorded. How does it look?
Let's examine the jit.qt.record
object for a moment. The message puts jit.qt.record
into a record-enabled mode. The actual recording doesn't begin until the object receives a matrix in its inlet. The message can take several optional arguments to specify a file name, frame rate, the codec type, the codec quality and the timescale for the output movie. In this example we're only using two arguments ( and ) to specify the frame rate ( indicates 15 frames per second) and the codec type ( indicates Photo-JPEG) of the output movie. For a full description of all the arguments for the message, see the Object Reference entry for the jit.qt.record
message to the
Note that we have the metro
object set to send a message every 66.67 milliseconds. This is done to match the input movie's frame rate. If you change the metro
object's rate and record a few more movies, you will see that a faster metro
rate causes the movie to be longer and slower, while a slower metro
rate results in a shorter, faster movie. This happens because of the event-driven model being used by jit.qt.record
The second example patch is a little more complicated, but it has two important additions (and several minor ones).
Same idea, different patch
First, we're automatically detecting the frame rate of the original movie (using the metro
object driving jit.qt.record
and the output movie's frame rate, as well. Let's look at that portion of the patch in detail:
message), and using it to set both the rate of the
• When a movie is successfully loaded into jit.qt.movie
, the object sends the message out its right outlet (if the operation is unsuccessful, the number will not be 1). We're using the route
object to retrieve this message.
• The unpack
object breaks up the remaining elements of the message. We're not interested in the file name, only in the success or failure of the read operation, so we've attached nothing to the left outlet of unpack
, and attached a select
object, which tests for the integer 1, to the right outlet. If our operation was successful, the select
object will output a .
• The jit.qt.movie
, which will respond by sending the message out its right outlet. The message element is a floating-point number representing the movie's frame rate. This value is sent from the route
object's middle outlet, and used to set the metro
object's speed and the output movie's frame rate.
is used to send the message to
This patch includes a second improvement. Rather than locking the entire patch to the frame rate of the original movie, we've added a jit.matrix
object with turned off to "collect" the output of the patch, and we're using a second metro
to send it messages at the correct frame rate for jit.qt.record
. This permits the rest of our patch to operate independently, at as fast or slow a rate as we want, with only the very last part of the patch specifically timed to the recording process.
Finally, we've added a neat crosshatching filter (the jit.hatch
object) with its own editing control (the number
box and the message
box). You can use this to modify your movie while you're recording it and watch the effects on playback. You can substitute any kind of Jitter object or patch you want at this point in the recording patch and modify what you record in real time.
Both of the previous patches have a problem: under high processor loads, these patches will drop frames. In many cases, this is not a problem, and the patches we've looked at are well suited to recording in any context, including live performance.
But how can we record a sequence in which every frame in an original movie has a corresponding frame in the output movie? How do you render movies in Jitter so that, even under heavy processor or disk load, every processed frame is captured?
There is a way. The jit.qt.movie
object's message offers a non-realtime playback mode that works perfectly with jit.qt.record
• Scroll all the way down in the Patcher window to see the third example.
Non-realtime recording with
On first inspection, the third example patch may not seem a lot more complicated than the previous one. But don't be fooled -- this unassuming patch will bring even the speediest computer to its knees.
• Click the message
box to load a movie into the jit.qt.movie
object, start the metro
object by clicking on the toggle
box connected to its inlet and watch the jit.fpsgui
object's framerate output display located at the bottom of the patch. If you get more than 10 fps, you have a much nicer computer than we do.
While this patch runs slowly in real time, it does a great job of creating a QuickTime movie in non-realtime. Using the jit.qt.movie
object's message and the jit.qt.record
object, the patch will capture every frame of the original movie, process it, and produce an output movie of identical length.
Here's how it works: the jit.qt.movie
object to stop playing its movie, and then sends each frame out, one at a time. (N.B. You don't need to send a or message to the jit.qt.movie
object for the frames to be sent.) Because of the way the Max scheduler works, a new frame will not be sent until the previous frame has been fully processed and recorded. Let's try it out.
message tells the
• Click on the toggle
box connected to the inlet of the metro
object to turn it off. (Sending a to jit.qt.movie
during the framedump operation will cause an extra frame to be sent, which is not what we want.) We've connected the button
on the top left corner of the patch to both the pack
object that sends the message, and the message. Press the button
, enter a file name when the File Dialog appears, and wait for the movie to render. When the framedump is finished, the jit.qt.movie
object sends the message from its right outlet. The example patch uses that message to trigger a message to jit.qt.record
The example patch also takes advantage of the fact that the jit.qt.record
object sends a matrix out its left outlet after recording a frame. We're using that frame to trigger a message to a counter
object that is driving the attribute of the jit.hatch
filter. This creates a repeatable sequence of processing changes that happen as the QuickTime movie is captured.
• Click on the "message
box to open the movie you've just created. Turn on the metro
to display the movie. Click on the toggle
box connected to the gate
object to see your new movie. This switches the jit.qt.movie
object's output directly to the jit.pwindow
, instead of through the processing objects.
object provides event-driven ways to record Jitter matrices as QuickTime movies. You can record the output of a Jitter patch in real time as you manipulate your patch, or out of real time, in render-like operation. You can use the jit.qt.movie
object's message to process an entire movie file without dropping any frames. This method lets you record high quality movies regardless of the load being placed on your computer's processor.