Creating Video With Processing and FFMPEG

Max/MSP users: look familiar?

For the past week I have been wrangling with getting ffmpeg (the open-source, command line video utility) to run in a Processing sketch and preserve the hard edges of graphical and/or intentionally pixelly video. It now works!

Details are listed in the code itself, but it is most important to note that the codec is likely the most important factor in getting good quality.   The “png” codec is great, but will create rather large files; mjpeg (MotionJPEG) also works well for graphics and hard edges (pixellated images, etc); H.264 is all-around good for photgraphic images.

The sketch below runs ffmpeg’s commands within Processing (as covered before) and exports a video from a series of still files.  Processing’s built-in video library seems ok, but offers little in the way of control as compared to ffmpeg.  Questions or suggestions are welcomed – feel free to use but please give credit!

UPDATE:
While I really don’t know why, the previous sketch seems to break with a Java IOException error.  It appears that ffmpeg can’t be found, but the solution is simple: specify the path to your ffmpeg install.  For example:

    /usr/local/bin/ffmpeg filename.mov etc...

The “-c:v” option to specify the codec is also updated to “-vcodec” and “-acodec”

[ download the updated sketch here ]

 

 

Collision Detection Functions for Processing Released!

UPDATE: these functions have been updated and moved to GitHub

Released today, version 0.9 of my 2d collision detection functions for Processing!

While some tools already exist, like the excellent Box2D, the source code is not easy to understand and the implementation is a bit complex. Other examples (equally great), like the line-line collision in the toxiclibs collection, use vector math which isn’t great for us “creative programmers” (ie: those like me who got bad grades in high school math).

Instead, these tools can be used as simple, one-line commands to determine whether two objects have collided. Designed for simple games and interactive systems, they are intended to be building blocks for larger projects.

Functions include:

  • Point/Point
  • Point/Rect
  • Point/Ball
  • Rect/Rect
  • Ball/Ball
  • Ball/Rect
  • Point/Line
  • Line/Line
  • Ball/Line

Download here via Google Project Hosting