You can make movies in Matlab using avifile and related Matlab commands. The basics of this are
aviobj = avifile(filename, 'fps', fps); for n=1:N; ...make a plot... fr = getframe(gcf); aviobj = addframe(aviobj, fr); end aviobj = aviobj(close)
See makemovie.m in the channelflow distribution for a complete example.
On Linux Matlab produces only uncompressed AVI files. These can be huge (gigabytes). You can compress the AVIs and convert to other formats using mencoder (a command-line utility that usually is installed as part of the Mplayer package.
To compress and save as AVI, run
mencoder -nosound -ovc lavc -of avi -lavcopts vcodec=wmv2:vbitrate=1600 input.avi -o output.avi
To compress and save as FLV (flash video), run
mencoder -nosound -of lavf -lavfopts format=flv -ovc lavc -lavcopts vcodec=flv:vmax_b_frames=0:vbitrate=1600 input.avi -o output.flv
You will probably need to adjust the bitrate (here 1600) to get a good balance of file size and video quality. For convenience you can turn these commands into shell functions by placing the following in a bash start-up file (probably either ~/.bashrc or ~/.bash_aliases).
function avicompress() { mencoder -nosound -ovc lavc -of avi -lavcopts vcodec=wmv2:vbitrate=$1 $2 -o $3 } function flvcompress() { mencoder -nosound -of lavf -lavfopts format=flv -ovc lavc -lavcopts vcodec=flv:vmax_b_frames=0:vbitrate=$1 $2 -o $3 }
which can then be run as follows
avicompress 1600 input.avi output.avi flvcompress 1600 input.avi output.flv
I used to be able to convert to Quicktime and MP4 using these scripts, but mp4creator is now unsupported and it no longer compiles.
function mp4compress() { mencoder $2 -ovc x264 -x264encopts bitrate=$1 -nosound -o tmp.avi mplayer -nolirc -nojoystick tmp.avi -dumpvideo -dumpfile tmp.h264 rm -f $3 mp4creator -create=tmp.h264 -rate=10 $3 rm tmp.h264 tmp.avi mp4creator -hint=1 $3 mp4creator -optimize $3 mp4creator -list $3 } function movcompress() { mencoder -nosound -ovc x264 $1 -o tmp.avi mplayer tmp.avi -dumpvideo -dumpfile tmp.h264 mp4creator -create=tmp.h264 -rate=29.97 tmp.mp4 mp4creator -hint=1 tmp.mp4 mp4creator -optimize tmp.mp4 mencoder -nosound -ovc copy -of lavf -o $2 tmp.mp4 -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames } function mp2compress() { ffmpeg -i $2 -vcodec mpeg2video -b ${1}k $3 } function mp1compress() { ffmpeg -i $2 -vcodec mpeg1video -b ${1}k $3 }
Please make all videos and images in standard sizes and colors. This makes it much easier to display them in web tutorials etc. –Predrag
NameFile.flv
and a NameFile.png
image of the same size NameFile.flv = P35p77.flv
if the period is T=35.77NameFile.png
(not NameFile.jpg
, etc.) 800 x ??? pixels (fixed width, not sure 800 is optimal…)NameFile.eps
not larger thank 60KB, preferably 5-10KB