PGPLOT and ffmpeg to make animations

I'm making simulations using PDL and PGPLOT, and I want to make a playable movie with them.

PGPLOT

Even though PGPLOT has the option to write out png or gifs, you should write out the images using the imag0001.ps/cps option, instead of \xs. The vector format of this output allows easy rescaling of the data without the need to re-run your simulations.

Use ImageMagick to convert your postscript files into jpeg files with high quality:

 convert -density 200 -rotate 90 im01200.ps -quality 100 t1.png

the -density must be before the ps file for it to work, otherwise the image looks of very low quality.

...or with a command line in bash:

for i in *.ps; do convert -density 200 -rotate 90 -quality 100 $i ${i%.ps}.jpg; done

ALSO add -gamma 1.5 to brigten up a dark image.

The second step with all these images is to use ffmpeg to encode to a video file:

ffmpeg -i file:im%03d00.jpg -b 1024k movie.mp4

Increase the -b bitrate option to get better image quality.

In the MacBook, you have to transfer the movies into yor "Movies" folder before you can pick them up in Keynote! Odd behaviour...

NOTE this command will quietly fail if the numbers of the input files are not in strict increasing numerical sequence.

Last updated: Wednesday January 02, 2008

Valid HTML