User Tools

Site Tools


gtspring2009:howto:format

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
gtspring2009:howto:format [2009/03/21 10:40]
gibson
gtspring2009:howto:format [2010/02/02 07:55] (current)
Line 1: Line 1:
 +====== 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 ​ ====== ====== Preferences ​ ======
  
-Please make all videos and images in standard sizes and colors. This makes it much easier to display them in [[http://​chaosbook.org/​tutorials/​index.html|web tutorials]] etc.+Please make all videos and images in standard sizes and colors. This makes it much easier to display them in [[http://​chaosbook.org/​tutorials/​index.html|web tutorials]] etc. --Predrag 
  
 ===== Videos ===== ===== Videos =====
Line 15: Line 93:
     * framing: please **crop movies** so they have as little dead area along the edges as possible     * framing: please **crop movies** so they have as little dead area along the edges as possible
  
-===== Figures ​=====+====== Images ======
  
   * pre-publication quality ​ images   * pre-publication quality ​ images
Line 22: Line 100:
  
  
 +===== How to resize PNGs =====
 +
 +To convert a PNG figure to the pixel size you prefer, use the ImageMagick %%convert%% command. For example,
 +
 +<​code>​
 +convert -resize 400x300 bigfig.png justright.png
 +</​code>​
 +
 +converts the 560x420 pixel figure %%bigfig.png%% to a 400x300 pixel figure %%justright.png%%.
 +
 +{{:​gtspring2009:​howto:​bigfig.png|bigfig.png}} {{:​gtspring2009:​howto:​justright.png|justright.png}}
gtspring2009/howto/format.1237657258.txt.gz · Last modified: 2009/03/21 10:40 by gibson