Movies: Difference between revisions
(+Publish your cool videos in this Wiki) |
|||
Line 104: | Line 104: | ||
Linux: | Linux: | ||
* Easist way: [http://recordmydesktop.sourceforge.net/ recordmydesktop] (on Mandriva, install with 'urpmi gtk-recordmydesktop') | * Easist way: [http://recordmydesktop.sourceforge.net/ recordmydesktop] (on Mandriva, install with 'urpmi gtk-recordmydesktop') | ||
:* when uploading videos created by <tt>recordmydesktop</tt> you need to encode the file eg. using <tt>mencoder</tt> | |||
:<pre>mencoder out.ogv -o out.avi -nosound -ovc lavc</pre> | |||
* [https://wiki.ubuntu.com/MeetingLogs/openweekfeisty/screencast Ubuntu discussion over screencast] | * [https://wiki.ubuntu.com/MeetingLogs/openweekfeisty/screencast Ubuntu discussion over screencast] | ||
* [https://wiki.ubuntu.com/ScreencastTeam/RecordingScreencasts Ubuntu screencast how to] | * [https://wiki.ubuntu.com/ScreencastTeam/RecordingScreencasts Ubuntu screencast how to] |
Revision as of 18:57, 21 July 2011
Q: How to construct high-quality MPEG-4 movies (animations) from a series of still frames?
Maris wrote:
Encode all .png files in directory to out.avi with 15 frames per second:
mencoder "mf:///path/to/files/*.png" -mf fps=15 -o out.avi # put -ovc here, see next lines
## for DivX - libavcodec MPEG 4 (DivX5), use: -ovc lavc -lavcopts vcodec=mpeg4:vhq:vbitrate=1800 -ffourcc MP4S ## for XviD, use: -ovc xvid -xvidencopts bitrate=1024 -xvidencopts pass=2 -xvidencopts cartoon ## for DivX4, use: -ovc divx4 -divx4opts q=5 ## for x264 use: -ovc x264 -x264encopts pass=3 -x264encopts preset=veryslow -x264encopts tune=animation
Uses mplayer's encoder. Choose one of encoding formats and append to end of "mencoder" line. Unfortunately only way to know quality settings is by encoding, watching result and re-encoding with different params.
Notice - by default encoding with lavc will set video fourcc to FMP4, that can be decoded with ffdshow. Option -ffourcc MP4S will change it to MPS4 ("official" MS fourcc for mpeg4) and video will be playable on Windows by standard MS mpeg4 decoder. It may lead to side effects, if MS mpeg4 decoder is buggy. More info: http://www.itdp.de/mplayer-users/2005-03/msg00069.html
Other guides:
- http://www.mplayerhq.hu/DOCS/HTML/en/menc-feat-enc-images.html
- http://electron.mit.edu/~gsteele/ffmpeg/
- http://www.stillhq.com/extracted/howto-jpeg2mpeg/output.html
Q: How to generate an animated GIF, FLI, or MNG?
A: for animations of 300 frames or less, animated GIF, FLI, or MNG formats are smaller files and better quality (i.e., frames stored as PNG not JPEG). Create with gifsicle, ppm2fli, or for MNG use ImageMagick's 'convert'. With more than 300 frames the players usually have memory issues. Animated GIFs are playable in any web browser of course and also in OpenOffice.
# with convert, many GIFs into one animated GIF: convert -verbose -delay 20 -loop 0 snapshot*.png animation.gif
Notes: '-delay 20' means 20 hundreds of a second delay between each frame. The '-loop 0' flag lets it loop indefinitely. To loop only 3 times use '-loop 3' etc.
Sample script to export PNGs in GRASS (generates tmean_001.png .. tmean_708.png):
export i=0 for year in `seq 1950 2008` ; do for m in `seq 1 12` ; do i=`expr $i + 1` # awk trick to generate wildcard-correct file names: i=`echo $i | awk '{printf "%03d\n", $1}'` r.out.png tmean_europe.$year.$m.avg out=tmean_$i.png done done convert -verbose -delay 20 -loop 0 tmean_*.png tmean_animation.gif
For presentations using a web browser, you can center the image on a blank white page, turn off any toolbars and go into full screen mode (F11 for Firefox). Then Alt-Tab your way to the animation at the appropriate time and nobody knows you are using a web browser.
Example HTML for centering image:
<HTML> <HEAD></HEAD> <BODY> <BR><BR><BR><BR><BR><BR><BR> <CENTER> <IMG SRC="animation.gif"> </CENTER> </BODY> </HTML>
Q: How to create dynamic surface movies in NVIZ?
A: See slides from the FOSS4G 2006 workshop: http://skagit.meas.ncsu.edu/~helena/grasswork/foss4g/FOSS4G06WKSVisual4anim.odp
See also the example at the bottom of the NVIZ keyframe animator panel help page.
Q: How to animate a time series of raster maps?
A: Use
- d.slide.show to view in a GRASS xmon (see d.mon)
- xganim to view on screen in X-windows (with live start/stop/speed controls)
- r.out.mpeg to save to a MPEG-1 movie.
Q: How to animate a series of maps, including decorations?
A: Use the xmon drivers (d.mon) to render the displays to a window via a shell script loop, then switch from the x0 to PNG driver to save as a series of PNG or PPM images. Use a method answered in a FAQ above to combine those into a single animation.
Q: How to create a screencast (for video tutorials etc)?
Linux:
- Easist way: recordmydesktop (on Mandriva, install with 'urpmi gtk-recordmydesktop')
- when uploading videos created by recordmydesktop you need to encode the file eg. using mencoder
mencoder out.ogv -o out.avi -nosound -ovc lavc
- Ubuntu discussion over screencast
- Ubuntu screencast how to
- vnc2swf to record a flash movie (short vnc2swf usage tutorial)
MacOSX:
Windows:
- ...
Examples
Using the Spearfish sample dataset
Animate on screen
Using a shell script
GRASS_WIDTH=640 GRASS_HEIGHT=500 \ d.mon start=x0 g.region rast=elevation.dem n=4927830 s=4912980 for NUM in `seq 1 0.5 10` ; do d.rast elevation.dem --quiet d.vect roads d.vect bugsites icon=basic/circle col=black fcol=green \ size=`echo "21-($NUM * 2)" | bc` echo "symbol basic/arrow2 25 80 `echo "10*$NUM" | bc` 80:80:80 125:125:255" | d.graph echo "Spearfish, South Dakota" | d.text size=4.5 at=1,2.25 d.barscale at=59.8,93.6 tcol=grey done
Animate to files
Using GRASS's PNG driver
# set up base map g.region rast=elevation.dem n=4927830 s=4912980 export GRASS_WIDTH=640 export GRASS_HEIGHT=500 export GRASS_PNGFILE=base.ppm export GRASS_PNG_READ=FALSE d.mon start=PNG d.rast elevation.dem d.vect roads echo "Spearfish, South Dakota" | d.text size=4.5 at=1,2.25 d.barscale at=59.8,93.6 tcol=grey d.mon stop=PNG # loop to draw variable parts as new frames i=0 export GRASS_PNG_READ=TRUE for NUM in `seq 1 0.5 10` ; do i=`expr $i + 1` FRAMENUM=`echo $i | awk '{printf("%03d", $1)}'` echo "Processing frame $FRAMENUM ..." export GRASS_PNGFILE="ganim_${FRAMENUM}.ppm" cp base.ppm "$GRASS_PNGFILE" d.mon start=PNG --quiet d.vect bugsites icon=basic/circle col=black fcol=green \ size=`echo "21-($NUM * 2)" | bc` echo "symbol basic/arrow2 25 80 `echo "10*$NUM" | bc` 80:80:80 125:125:255" | d.graph d.mon stop=PNG --quiet done # repeat the last frame a few times for EXTRA in 1 2 3 ; do i=`expr $i + 1` FRAMENUM=`echo $i | awk '{printf("%03d", $1)}'` cp base.ppm "ganim_${FRAMENUM}.ppm" done \rm base.ppm
Encode as animated GIF
- Using the gifsicle encoder
- View in a web browser
for IMG in ganim*.ppm ; do # convert each frame from PPM to GIF ppmquant 256 $IMG | ppmtogif > "`basename $IMG .ppm`.gif" done gifsicle -O2 --delay 20 --no-loopcount --colors 256 ganim_*.gif > ganim.gif \rm ganim_0*.gif
Encode as animated PNG (MNG)
- Using the ImageMagick "convert" encoder
- View with ImageMagick's "display"
convert -delay 20 ganim_*.ppm ganim.mng
Encode as FLI
ls ganim_*.ppm > frames.txt ppm2fli -g"${GRASS_WIDTH}x${GRASS_HEIGHT}" -O -s 15 frames.txt ganim.fli \rm frames.txt
Encode as Flash
png2swf -o outfile.swf *.png -r 1
Encode as MPEG-4 Xvid
# doesn't like GRASS's PPMs, convert to PNG for IMG in ganim*.ppm ; do pnmtopng $IMG > "`basename $IMG .ppm`.png" done mencoder "mf://ganim_*.png" -mf "type=png:fps=5" -o ganim.avi \ -ovc "xvid" -xvidencopts "bitrate=1024" \rm ganim_0*.png
Publish your cool videos in this Wiki
We have installed a Mediawiki widget extension and created a special template for including Youtube videos (Template:YouTube). See also wxGUI Modeler page for the usage.