Simple creation of movies

posted May 4, 2009, 7:14 AM by G. Maze ‎(admin)‎   [ updated Sep 22, 2010, 2:09 AM ]
I had some difficulties to create movies from Matlab watchable from every OS platform, even from Mac Leopard to Tiger.
I finally adopted a simple approach, not based on the movie function of Matlab but the command line function "convert".
I know this is not an amazing solution, but at least you can watch the output from everything, incorporate it into keynote talks, webpages and so on ...

> The workflow is as follow:
  1. create a subfolder where you gonna put everything for your video
  2. create an image file in this subfolder for each key frame you want to see in the final video. You need to order files alphabetically. To do so, in your loop, simply add something like: 
print(gcf,'-dpng',sprintf('movie/%s_%0.3d.png',filename,iteration));
  1. go into the subfolder 
  2. hopefully you have the command line function "convert" and then a simple:
convert *.png movie.gif
will create an animated movie into movie.gif


> Convert is highly flexible, note that you can:

see the man page of convert


> You can also produce videos in different format such as .mov .avi and .mpg.
For example:
convert -delay 1/10 -rotate 90 *.png movie.mpg
but for mpeg compression I had to installed the mpeg2vidcodec with MacPort

Comments