[GRASSLIST:360] Re: NVIZ : getting a script to run

H Bowman hamish_nospam at yahoo.com
Thu Jun 12 02:15:05 EDT 2003


> > Use the ImageMagick tools:
> > pnmtopng < dump.ppm > dump.png
> > sgitopnm < dump.rgb | pnmtopng > dump.png
> 
> The question is : does it work *inside* the nviz script ? Does "dump" 
> correspond to a temp file created during the script, before the
> picture gets its proper name ? If not, well, back to the beginning.

Those commands are just for the Bash prompt.
By with the NVIZ script do you mean in:
/usr/local/grass5/etc/nviz2.2/scripts/nviz2.2_script
?
That's a Tcl/Tk script, I'd guess there would be a "system()" command in
tcl, but I wouldn't know what it was.


Yet Bash another option would be to use X window dump (xwd):
 (this is for dumping a GRASS monitor, but you get the idea..)
 It suffers the same non-double buffered graphics as NVIZ image dump.

OLD_MON=`d.mon -p | awk '{printf "%s", $4}'`
GRASS_VER=`g.version | awk '{printf "%s", $1 " " $2}'`
export GRASS_PNGFILE="$1".png
echo "Exporting to $GRASS_PNGFILE from [$GRASS_VER- Monitor: $OLD_MON]"
xwd -name "$GRASS_VER- Monitor: $OLD_MON" | xwdtopnm | pnmtopng \
   > $GRASS_PNGFILE


> Actually, I thought about a workaround: instead of relying on nviz to
> loop on the maps, I rely on my bash parent. That way, I write only one
> PPM that I can convert on the fly.

Another ugly hack might be to have a cron job which runs every 20
minutes: copy *.ppm to a temporary directory, convert everything in that
directory to PNG, delete *.ppm in that dir, and move the PNG files back.


> I've never been able to understand the parameters of the MPEG2
> algorithm, there are far toomany parameters for me.

mpeg2enc stream.yuv -f 3 -b 1500 -q 7 -4 2 -2 2 -a 1 -o stream.mpg

might get you started. Try the MJPEG web page (sf.net I think) and
mpeg2enc man page or the mencoder web page.. you might be able to encode
with the MPEG4 Xvid codec with mpeg2enc as well with better (but less
portable) results, although I couldn't give you specific instructions
how. Note MPEG2/4 share the same potential patent woes as GIF. Various
versions of PowerPoint tend to choke on large animated GIFs (eg 4mb 300
frames). Best way of presenting them I've found is to make a blank web
page with the embedded animation centered on the page, and show it in
full screen mode in Mozilla/Galeon with all the toolbars turned off.
There was a Knoppix variant for auto-booting into your scripted
presentation, but I haven't investigated that either.. but I'm
digressing here.


You'll want to either have a script sylinking dump0001.yuv to
frame0001.yuv->frame0025.yuv so your movie isn't over in 2 seconds, or
use frame rate control (mencoder?) to slow it down to 1 fps or so. I
haven't found a great solution for this yet.


> Great ! Can I compile the latest version of NVIZ on a old version of
> GRASS ? IS there a pb of backward compatibility ?

For the fewest headaches, I'd grab the 5.0 CVS snapshot and try from there.


good luck,
Hamish




More information about the grass-user mailing list