Sunday, June 7, 2009

Create a movie using Fortran

Recently, I posted a method for making images in Fortran. With a couple of commands, its easy to turn those images into a movie.

I'm assuming that you're following my previous hack and you've got a directory of ppm image files, each one containing a single image of the movie you want to create. First, you'll need to convert each one to jpg:

convert IMAGE.ppm IMAGE.jpg


Then convert the jpg's to an avi file. This requires mencoder, which is included with the MPlayer package, which is part of the Packman repositories.

mencoder "mf://*.jpg" -mf fps=1 -o VIDEO.avi -ovc lavc -lavcopts vcodec=wmv2


The video is encoded using wmv2 which is playable on every Windows and Linux machine I've come across. This plays the video at 1 frame per second. You can increase or decrease the fps switch to set the speed at whatever you like (such as "fps=3.5"). The images are read in alphabetical order, so numbering your images 0001.jpg, 0002.jpg, and so on is not a bad idea.

Here's movie that I recently created as part of my thesis research:



It probably doesn't make a lot of sense what's going, but the important thing is that this entire video was created using a couple hundred lines of Fortran, my data files, and a couple of scripts.

No comments:

Post a Comment