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!

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

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

[ download the updated sketch here ]