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 filename.mov etc...
The “-c:v” option to specify the codec is also updated to “-vcodec” and “-acodec”
[ download the updated sketch here ]
2 Replies to “Creating Video With Processing and FFMPEG”
Hi there, fantastic post!
One question, I have been working with some of your code but I keep coming up against the JavaIO exception error you mention, except I am not sure how to get past it – I am working on Windows 7 and have saved my ffmpeg download in C:\ffmpeg, but whenever I try to update your String ffmpegInstall = “/usr/local/bin/”; command with “C:\ffmpeg” or something like it, I keep getting this error:
Creating temporary directory for still images…
java.io.IOException: Cannot run program “mkdir” (in directory “C:\Users\Alison\AppData\Local\Temp\untitled5492383391214224779sketches\sketch_141024e”): CreateProcess error=2, The system cannot find the file specified
Also one other thing, I was also initially getting an error about a class/type called InputStreamReader not being found, but I was able to add in an import java.io.*; line in which fixed this.
Hmm, seems to be a few different problems:
which ffmpegto see where it’s installed.