MovieMaker Processing Library

Update: MovieMaker is now part of Processing’s core video library so this post is now irrelevant!

Based on some code from Shawn Van Every and Dan O’Sullivan, I’ve created a Processing library that allows you to take any pixel array (from the window or from a PImage) and create a quicktime movie.

  • It might be buggy if the movie file already exists. In theory, it should delete the file and rewrite a new one, but this is not always working.
  • You must call finishMovie() yourself. You might try calling it in stop() or destroy() but it doesn’t seem to work consistently so in my example below, I just call it in mousePressed(). Ultimately, I’d like to have the library call it automatically when the applet quits. . .
  • Need to implement more codecs (you can actually pass in any available constants, i just made nice little variables for a few.)
  • This needs to be tested on Windows. In theory, the library checks your OS and flips pixels if you are using Windows, but haven’t tested it yet. Oh, and there might be a problem on intel macs if they think like windows in terms of pixels.
  •  
    E-mail me bug reports, questions, comments, etc.!

    Example code:

    import moviemaker.*;
     
    MovieMaker mm;
    float theta = 0;
     
    void setup() {
      size(200,200);
      mm = new MovieMaker(this,width,height,"p5test.mov", MovieMaker.JPEG, MovieMaker.HIGH,30);
    }
     
    void draw() {
      background(sin(theta)*127+127,255,cos(theta)*127+127);
      theta += 0.05;
      loadPixels();
      mm.addFrame(pixels,width,height);
    }
     
    public void mousePressed() {
      mm.finishMovie();
    }

    Available constants:
    code: RAW, JPEG, CINEPAK, SORENSON, VIDEO
    quality: LOW, MEDIUM, HIGH, BEST

    • http://www.shiffman.net Daniel
    • Ted

      Wow, this is great.
      any chance it’ll be expanded to loading movie files or producing a different file type?

    • http://www.sines.eu mark

      Dear Daniel

      I receive the following message and am unable to finish off the movie :

      quicktime.std.StdQTException[QTJava:6.1.6g],-2014=invalidDuration,QT.vers:7168000
      at quicktime.std.StdQTException.checkError(StdQTException.java:38)

      I’m a new comer and a little lost. That said I have got it to work with your example code above

    • Fox

      Stefan and all, I recall reading recently something about the constants for the H.264 codec and another (MPEG4 maybe?) are now included in the Quicktime for Java libraries.

      Of course I can’t find the page anymore, but there’s a little info here that is relevant from Chris Adamson who contributes to O’Reilly: http://lists.apple.com/archives/QuickTime-java/2005/Aug/msg00049.html

    • http://www.mrogalsky.net matt rogalsky

      Great work!

      Have you experimented with generating NTSC or PAL dimension movies and importing them into Final Cut or other video editing software? I’m about to try this…

      best
      Matt Rogalsky

    • http://www.thoughtandmemory.org diN0bot

      Hi,

      I am using a MacBook with tiger 10.4.

      When I run the example code in
      http://www.processing.org/reference/libraries/video/MovieMaker.html
      I get this error:

      The specified codec is not supported, please ensure that the parameters are valid, and in the correct order.

      I’ve tried different constants: StdQTConstants.kH263CodecType, and all the MovieMaker ones.

      I have quicktime 7, updated to the latest version as of today.

      I can’t figure out where the codec lives on my computer or how to not get this error…

      Thank you for your help,

      diN0bot

    • Emre Rona

      Hello,

      I’m having a similar problem with the message posted on 4th January 2007 (question no.2).

      When I’m creating a movie, the rendered version is much faster than it normally is, probably because of a frameRate issue. I declare the framerate as 30 in the setup and 30 again when creating the new MovieMaker object, but the resulting animation is almost four times faster than my original intentions.

      I’m not very confident with coding so i don’t know if this is because of something that I’m doing wrong, can you help me out please?

      Besides this, animations look great!

      By the way, I’m using an intel macbook, OSX 10.4.8.

      Thank you,

      Emre.

    • laraB

      Hey,
      I used the library to make a video, but it doesn’t work if when i export it: there’s just an empty screen.
      Is it generally possible to export applets when you work with videos?

    • kostya

      Hi everyone! I’m try to use this but NetBeans 7.1.2 writes something..(image). I’ve imported:

      import processing.app.tools.*;
      import processing.core.*;

      How I can use library?