User Tools

Site Tools


gtspring2009:howto:format

How to format movies

matlab

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.

conversion and compression

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   

obsolete conversion scripts

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 
}

Preferences

Please make all videos and images in standard sizes and colors. This makes it much easier to display them in web tutorials etc. –Predrag

Videos

  • Create a flash video file NameFile.flv and a NameFile.png image of the same size
    • for 3D video of a plane Couette solution use 400 x 300 pixels
    • for a dual view state space/3D fluid use 720 x 300 pixels
    • NameFile:
      • for periodic orbits NameFile.flv = P35p77.flv if the period is T=35.77
      • for equilibria follow Halcrow et al papers, as in channelflow.org database
      • if you are replotting the same solution, DO NOT give it a new name (dokuwiki has old versions saved)
    • color: use white background
    • framing: please crop movies so they have as little dead area along the edges as possible

Images

  • pre-publication quality images
    • for pdflaTeX: NameFile.png (not NameFile.jpg, etc.) 800 x ??? pixels (fixed width, not sure 800 is optimal…)
    • for laTeX (inclusion in ChaosBook.org, etc): NameFile.eps not larger thank 60KB, preferably 5-10KB

How to resize PNGs

To convert a PNG figure to the pixel size you prefer, use the ImageMagick convert command. For example,

convert -resize 400x300 bigfig.png justright.png

converts the 560×420 pixel figure bigfig.png to a 400×300 pixel figure justright.png.

bigfig.png justright.png

gtspring2009/howto/format.txt · Last modified: 2010/02/02 07:55 (external edit)