1. NodeBox 1
    1. Homepage
    2. NodeBox 3Node-based app for generative design and data visualization
    3. NodeBox OpenGLHardware-accelerated cross-platform graphics library
    4. NodeBox 1Generate 2D visuals using Python code (Mac OS X only)
  2. Gallery
  3. Documentation
  4. Forum
  5. Blog



The NodeBox Quicktime library adds movie (and audio) support to NodeBox. You can use it to grab image frames from a movie and display them in NodeBox or manipulate them with Core Image. Furthermore, you can use the library to play audio in NodeBox, make audio selections, and control the volume and rate from your script.


downloadquicktime.zip (1.5MB)
Last updated for NodeBox 1.9.0
Author: Tom De Smedt



How to get the library up and running

Put the downloaded quicktime folder in ~/Library/Application Support/NodeBox/ or in the same folder as your script so NodeBox can find the library. Then import the library in your script:

quicktime = ximport("quicktime")


Movie frames

The library has a movie() command that opens a movie from a given location. You can open any type of movie you could normally open with the Quicktime application:


The command returns a Movie object with a number of useful properties:

  • movie.path: the source path.
  • movie.duration: the length of the movie in seconds.
  • movie.has_video: True if the movie has a video track.
  • movie.has_audio: True if the movie has an audio track.
  • movie.width: the width of the movie in pixels.
  • movie.height: the height of the movie in pixels.

The returned movie object has two methods to grab image frames:

movie.frames(n=10, start=0, stop=None)

The frame() method returns a MovieFrame object with image data at the given time (in seconds) in the movie. The frames() command returns a list of n MovieFrame objects between the given start and stop time (in seconds). The start and stop parameters are optional.

A movie frame object has the following properties:

  • frame.data: the image data which can be passed to the image() command.
  • frame.time: the time where the frame appears in the movie.
  • frame.src: the source path of the movie to which this frame belongs.
  • frame.width
  • frame.height

Displaying frames in NodeBox is really very easy. The following script loops through all the frames in an animation:

movie = quicktime.movie("twisted_world.mp4")
size(movie.width, movie.height)
def draw():
    frame = movie.frame(FRAME*0.1)
    image(None, 0, 0, data=frame.data, width=frame.width)


Movie frames in Core Image

The Quicktime library and the Core Image library play really well together. A MovieFrame object returned from movie.frame() or the movie.frames() list can be passed to the canvas.layer() method in Core Image. Then you can apply all sorts of filters and effects to it:

coreimage = ximport("coreimage")
quicktime = ximport("quicktime")
movie = quicktime.movie("twisted_world.mp4")
frame = movie.frame(1.0)
canvas = coreimage.canvas(movie.width, movie.height)
l = canvas.layer(frame)



Audio playback

The library has an audio() command that opens a sound from a given location. You can open any type of sound you could normally open with the Quicktime application:


The command returns an Audio object with a number of useful properties:

  • audio.path: the source path.
  • audio.duration: the length of the movie in seconds.
  • audio.has_video: True if the movie has a video track.
  • audio.has_audio: True if the movie has an audio track.
  • audio.volume: the volume at which the audio is playing (between 0.0 and 2.0).
  • audio.time: the current time (in seconds) when the audio is playing.
  • audio.rate: the rate or speed at which the audio is playing (between 0.25 and 5.0).
  • audio.paused: True when the audio playback is paused, but not stopped.

The returned audio object also has a number of methods that control the playback:


The audio.is_playing() method returns True as long as the sound is playing in NodeBox. While the sound is playing you can adjust its volume and rate. It will begin playing at its time property. The audio.reset() method resets the volume, time and rate to the default values (0, 0 and 1 respectively).

The library does not have any functionality to export audio from NodeBox.


Copying and pasting selections

Sometimes you may want to work with a selection of a movie instead of the whole movie, or a one-second sample of the audio that you are going to loop. For these purposes, both the Movie and the Audio object have a selection() method:

media.selection(start=0, stop=None)

It returns a new movie or a new audio object ranged between the given start and stop time. For example, here's how to create a short loop from an audio fragment:

audio = quicktime.audio("modron_cube.mp3")
audio = audio.selection(start=0, stop=7.2)
def draw():
    if not audio.is_playing: