Java: How do I create a movie from an array of images?

The solution seems to be to use Mencoder (or at least, that seems to be a semi-popular choice).

Here’s a link that specifically addresses images-to-movies capabilities in Mencoder.

As for rendering text onto the frames before encoding them as part of the video, you can use Java2D’s image manipulation libraries to simply draw text on top of the images beforehand For example:

That’s one way to do it, and this FAQ should get you started in that direction with Java2D, font rendering, etc., and offer pointers to further resources.

The ImageIO library also allows you to read/write a number of image formats, effectively allowing you to transcode images from, say, .jpg -> BufferedImage -> .png, or any which way you need to do it, if you want to store the image files temporarily during the conversion process, and/or convert all the images to a single format when importing them for the conversion project, etc.

Depending on how many output formats you want to support, you’ll probably do something like

public void createMovie(BufferedImage[] frames, String destinationFormat)

…where “destinationFormat” is something like “m4v”, “mpeg2”, “h.264”, “gif”, etc.

Leave a Comment