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


    58 Responses to “MovieMaker Processing Library”  

    1. 1 jesús gollonet

      wow, that’s great news daniel.

      I’ve just done a quick test on windows with your code and as far as I see everything works nicely. I’ve done another sketch trying to record from a webcam and there seem to be some drops, but I have to test it deeper.

      anyway, this is a great tool. Thanks very much for sharing.

    2. 2 Ram Subramanian

      Good resource Dan,

      I started writing some code myself based on http://www.onjava.com/pub/a/onjava/2003/02/19/qt_file_format.html?page=1

      but ill put that on hold and test this out. ill let you know how it goes.

      Ram

    3. 3 steve cooley

      Awesome! I was just telling one of my best friends last night that I think looking at art made in processing is cool, but watching it being made is cooler. Processing programs that run over night might become more interesting if you can timelapse the rendering process. :) this seems like it could make that a little easier.

    4. 4 douglas edric stanley

      Brilliant! This is exactly what we need over here. Like Ram (great name), we actually started building a Quicktime movie exporter, but got distracted from another library project. Let us know if you want some code help, we’ll send over our efforts.

      I’m doing some experiments right now, everything works well, except I keep getting “Temporal compression not supported. Switching modes”. I’m on a Mac OS 10.4.4, Processing 0115, Quicktime 7.0.4.

    5. 5 Daniel

      Ah, oops, yes, the “Temporal compression not supported. Switching modes” message is on purpose. I should take it out, was just for my own debugging. What I’m doing is determining what type of compression is being used and then adding frames to the movie with code based on that determination. I’m out of town this weekend, but I’ll be cleaning / fixing up the code next week when I get back!

    6. 6 Huw

      Hi,
      Sorry if this isn’t too relevent but you guys seemed to be sensible people to ask. I’m using ubuntu, and I’ve written a patch for pure data (pdp) to play and synch two video streams, but it doesn’t like my quicktime files - it tells me it doesn’t support the codec. They are just the standard output from finalcut pro 5, totally uncompressed. I’ve tried loads of things but nothing works. Any ideas? Would your exporter dp the trick?

    7. 7 Claudio Midolo

      Gr8 tool! thanks Daniel! i’ll try it soon on a project!

    8. 8 Stefan Kreitmayer

      This makes the world better - Thanks Daniel!

    9. 9 Dan

      Thanks for the library! One problem: my movies are washed out in blue. Frame rate is great though. Any thoughts?

    10. 10 Dan

      Doh. I’m runing a macbook 2.0 (mactel).

    11. 11 Corrado Alesso

      It works well Dan on my windows, the only problem I have is that the resulting video is always at great fps… doesn’t matter, I’ll slow down them externally. Anyway it’s a great library, very useful for processing.

    12. 12 Daniel

      Thanks for all the comments, I\’ve been traveling a lot this summer, but I\’m back now and plan on updating the library and documentation soon. Suggestions, bug reports, etc. welcome!

    13. 13 saikaL

      Hello,greetings from Greece.
      I just downloaded processing and your moviemaker.
      I am not a programmer but i like to experiment with moving images and staff.
      I would like to export the things i see in the processing but i can’t understand how. Would you have the patiens to explain to me what i hane to do?

      Thank you in advance

    14. 14 hansi

      i need that so often but i’ve been too lazy try understand the horribly documented quicktime api, i’m happy you did :)
      thanks sooooo much for this!

    15. 15 Tomaso

      Fantastic Daniel!

      Greetings from Italy.

    16. 16 Planche

      I’ve just downloaded the library, and I’m running a test with LiveInput, this is a small piece of code that captures inputed sound and makes graphics react to this input. While trying to use MovieMaker to record the movements, the app runs to slow and the quicktime seems to be corrupted.
      Any work around for this?

      By the way I think it’s a great development.

    17. 17 Daniel

      Can you let me know what OS you are using (and the resolution of your app)? It will indeed make the applet run slower, especially if it is high resolution (640×480 or more.) As far as the quicktime being corrupted, did you include a call to the \”finishMovie()\” method? The qt won\’t work unless that function gets called. . .

      Someday soon I will update and work on this library more!!!!

    18. 18 Planche

      Well I’m using Mac OS X Version 10.4.5
      I’ve tested this with a smaller applet, mine was 1024×768, and I think the problem was wright there because now it runs well :) Is there a excellent codec that export a high quality movie, I’m using VIDEO and BEST as the values and still get a litle bad quicktime.

      thks again ;)

    19. 19 antonio stilo

      I’ve report this bug:

      2006-09-25 10:53:36.731 java[327] *** -[NSBundle load]: Error loading code /Library/InputManagers/MagicMenuEnabler/MagicMenuEnabler.bundle/Contents/MacOS/MagicMenuEnabler for bundle /Library/InputManagers/MagicMenuEnabler/MagicMenuEnabler.bundle, error code 2 (link edit error code 0, error number 0 ())

      then the .mov saving start but the .mov produced present only the BLUE channel saved in… maybe

      i’ll check properly anyway i’m running MacOsX 10.4 shouldn’t be a problem but i’got a MAC INTEL UNIVERSAL

      thanks for this library!

    20. 20 Daniel

      Hmmmm, I’ll have to test this on Mac Intel at some point and see if I can get it working. Oh, and regarding codecs, you can use any of the constants available in StdQTConstants (I just need to implement them all in the library. . ).

    21. 21 hibernia

      thanks a lot, daniel, for this great library.
      is there any reference somewhere to deepen this useful tool?

      hibernia

    22. 22 stefan kreitmayer

      hi daniel,

      i’ve been using movie maker a lot and simply love it.
      do you have an idea if it’s possible to get the h.264 codec working?
      i’m wondering if java is the limit.. (currently running osx 10.4.8)

      thanks for all

      greetings from germany
      stefan

    23. 23 Daniel

      Hmmm, yes, I’d like to support all codecs. Currently, I’m getting the available codecs as constants from StdQTConstants. I don’t see one for H.264, but there is one for H.263.

      I will implement it at some point as part of the library, but for now you should be able to do this:

      mm = new MovieMaker(this,width,height,”p5test.mov”, StdQTConstants.kH263CodecType, MovieMaker.HIGH,30);

      You will likely need to import StdQTConstants:

      import quicktime.std.StdQTConstants;

      Let me know if it works! I’ll add more codecs soon!

    24. 24 stefan kreitmayer

      hi daniel,

      yes thanks, well i’ve had a look into your code meanwhile and simply added the h.263 to the other VARIABLES, which is so comfortable. (personal hack, hope that’s alright for you - i definitely won’t spread it around)

      it helps a lot to know you didn’t find the h.264 either, because now i know it’s really not there. i was thinking that maybe i’ve got an old version of java - and since i’m such a bloody java rookie, i don’t even know where to look up my version number :-)
      hopefully apple will add h.264 for java soon, because after comparing a lot of codecs recently i found it’s so much better than everything else in almost any respect..

      respect
      stefan

    25. 25 stefan kreitmayer

      who is responsible anyway, for bringing h.264 into java? sun?

    26. 26 Liav

      I just installed this on the very fast, but very locked-down Dell PCs in our school’s computer lab. Works like a charm. Will give it a try on my toshiba crap-top when it gets back from the shop.

      Thanks! This is a particularly useful library for those of use interested in producing video art in Processing.

      .Liav

    27. 27 jean-pierre hebert

      with mac intel 10.4.8 (NVIDIA GeForce 7600) with processing 119:
      my qt test come out with wrong colors (switching from magenta to white),
      under all parameter values. any suggestion? thank you!

    28. 28 charles mezak

      Hey, thanks for the library!

      I’m very excited to get using it, but I’m having the same problem as some others: the exported movies are washed out it blue. looks like the blue channel only, I think. I’m runinng an intel macbook. OSX 10.4.8

      Good luck!!
      chuck

    29. 29 Daniel

      I’m going to fix this bug this weekend, stay tuned!

    30. 30 charlie

      HOORAAAAY!!! My hero!!

    31. 31 coryn

      sorry sorry sorry…. stupid me… had to restart processing before it recognized the new library… oops!

    32. 32 charlie mezak

      Not to be a bother, but I’m really excitedly awaiting a library that will run on my intel mac. I do experiments with live video and I’d love to capture it.

      I’m planning on working through some of your Nature of Code coursework soon!

      Good luck!

    33. 33 Ram Subramanian

      Daniel, i dont understand exactly how to control the movie frame rate .. i seemed to see a trend and i just wrote in my hack to do the same. however i would like your thoughts on it.

      Case: Camera rate is 12 fps, but the o/p movie post processing should be around 20 fps -> there seems to be a fair amount of numbers you need to twist :-).

      would love to hear your thoughts on this

    34. 34 Daniel

      Hey Ram,

      Does it not work if you pass in the integer 20 to the constructor?

      mm = new MovieMaker(this,width,height,\”test.mov\”, MovieMaker.JPEG, MovieMaker.HIGH,20);

      If you look at the source code you\’ll see this rate value is used when adding frames using the addSample() method.

    35. 35 Ram Subramanian

      -> regd movie write speeds, no that does not work Dan, i think when you write it you need to tell it to write faster so if you are reading frames at 12 fps and you need to write at 20 you need to tell the that you need to write twice as fast as you are reading from the camera. so write speed value will be close to 60 fps. its weird the way it works. If it directly works with slotting in a number that would be great !!

      Thanks
      Ram

    36. 36 Daniel

      Ah, this is because MovieMaker doesn’t care what the camera framerate is. It only cares about what the display framerate is (assuming you are adding the pixel array with every frame.) Two possible fixes — (1) set the framerate of the applet to the same as the camera framerate. (2) Add the pixels of the video source to the movie directly in the captureEvent() function.

    37. 37 Diex

      Hi Shiffman !:

      I was working around with moviemaker. It goes fine but with certain issues:

      1) How could it use it with OPENGL rendering?
      2) the framerate of my recorded movie looks faster than the realtime applet. how could I fix it up? (I\’m trying to record some audio-video live performance)
      3) using mm directly I got some frezzed frames in the applet window so I decided to run it in another thread (my class follow) but I get the framerate trouble and also some black frames in the movie. Any thoughts?

      thnk you very much !!! (sorry.. I\’m on vacation; plenty of time for disturbbing :))

    38. 38 Daniel

      1) OPENGL mode should work just fine. Does it not?
      2) The framerate for the movie is fixed to whatever you specify. This is not recording your screen in real-time, it is adding frames of your applet one at a time to the movie (and playing them back at whatever framerate you set in the constructor.)
      3) Writing a movie file while running an applet is slow, and will cause your applet to run very slow. The library is not recommended for use in real-time recording. If you want that, you may just want to record the video out of your machine to directly. Also, doing a separate thread will not help matters as you want each frame to be added to the movie precisely at the end of each draw() cycle. I suppose you could make a thread for every addFrame() call. . .

    39. 39 Diex

      oh.. I see.. I’ll try adding frames on a diferent thread and see what happens..
      thank you very very much !

    40. 40 eric

      Hi, can I use your library for a web project? I mean will it save the video in a folder on the webserver?

      thanks

    41. 41 Daniel

      Unfortunately, the MovieMaker library will not work in an applet on the web (only running in Processing locally.)

    42. 42 Oswald

      Hello.
      Im working with a project for capturing images, videos and audio from a webcam. Can the library record the sound in the movie as well?

    43. 43 Daniel

      Nope the library doesn’t do sound. You’d have to capture that separately.

    44. 44 movax

      Thank you very much for making this. Because of people like you, the free tools are getting to be even better than the commercial ones!

    45. 45 Wanda

      Thanks for your project. I like this site. KEEP IT UP..G

    46. 46 Claudio Midolo

      Hi Dan!

      working with MovieMaker library on Processing 0124 I get this

      … .java:362:1:362:10: Semantic Error: Type “MovieMaker” is imported on demand from package “processing.video” and package “moviemaker”.

      but on Processing 0121 is working fine, do you know why?

      Thanks!

    47. 47 Fabien

      Hi Dan,

      I got the same error as Claudio. Although when using MovieMaker without invoking the video library it works fine …
      I’m also using 0124.
      Any clue? Thanks.
      Cheers!

    48. 48 Daniel
    49. 49 Ted

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

    50. 50 David

      Dan,

      This is a wonderfully useful tool. I just solved a problem that may be confusing for others should they encounter it. The error message follows:

      /tmp/build38572.tmp/Temporary_4127_7447.java:21:1:21:10: Semantic Error: Type “MovieMaker” is imported on demand from package “moviemaker” and package “processing.video”.

      When using the video library for live video input, you import something else which is also called MovieMaker. To distinguish between the two, you need to write moviemaker.MovieMaker or video.MovieMaker whenever you are instantiating a MovieMaker or accessing class attributes. Hopefully this will save someone a few minutes of headscratching.

      Thanks again for the great library.

    51. 51 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

    52. 52 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

    53. 53 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

    54. 54 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

    55. 55 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.

    1. 1 Random Etc. : Blog Archive : Processing 0121 is ready
    2. 2 dasAutomat.com » Blog Archive » Surface library
    3. 3 christianmeinke.com » Blog Archive » Processing Extended


    Leave a Reply