Recently I've started making a few movies in Matlab. This is actually quite easy - for an example see
this description from the Matlab documentation. Unfortunately, the movie2avi() function does not apply any compression when writing the movie to file (not in Linux, anyway), and this results in very large movies (on the order of 100 MB for a few seconds).
However, I found a solution. I originally posted it as a reply in the MATLAB Newsreader, but I thought I'd share it here as well:
You can transcode Matlabs AVI movies using FFmpeg (www.ffmpeg.org). If you don't have the package, you can install it using the terminal:
sudo apt-get install ffmpeg
If you have only one file, let's call it inputFile, you can transcode it using something like this:
ffmpeg -i inputFile.avi -sameq outputFile.avi
The "-sameq" option is used to preserve video quality. I tested this on a 80 MB file produced by Matlab, and got a 5 MB file without any visible loss in quality. If you want to do it within your matlab script, use the system() command:
system('ffmpeg -i file1.avi -sameq outputFile.avi')
If you have a problem with the Matlab AVI file growing too big, you can split it into several smaller files and compress them as you go, and finally combine them after your iteration has finished. A way of doing this is described here in the
FFmpeg FAQ. Note that you will have to transcode your intermediate files to MPEG format. .