Simple creation of movies
Post date: May 04, 2009 2:14:51 PM
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:
create a subfolder where you gonna put everything for your video
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));
go into the subfolder
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:
rotate the output: convert -rotate 90 *.png movie.gif
insert delay in the video between keyframes: convert -delay 1/2 *.png movie.gif
see more examples at: http://amath.colorado.edu/computing/software/man/convert.html#ex
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