go to www.geomview.org home page
 
Home

Overview
FAQ
Documentation

Download

Mailing List

Geomview For Windows?

Support
Users
Development

Bug Reporting
Contributing
Contact Us

Sponsors

 

Site Search

 

Advanced
Search

 
About the software@geom archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Closed REQ 5960]: creating MPEGs with geomview?


  • To: software@geom.umn.edu
  • Subject: Re: [Closed REQ 5960]: creating MPEGs with geomview?
  • From: daemon
  • Date: Thu, 8 Aug 1996 00:17:09 -0500 (CDT)

The SGI version of geomview, at least, saves SGI-format images rather than TIFF.
I'm not sure what you may have to produce MPEG movies; we've been using a
freeware UNIX program "mpeg_encode", which wants PPM files as input, though it's
willing to invoke a user-specified conversion program to convert them on the fly
from some less bulky format.

Enclosed below is a script you can use to make an MPEG movie from a collection
of images.  See the "Usage" message it emits when run with no arguments.
It just accepts a list of files on the command line, and produces an mpeg movie;
the only important option might be "-w", to shrink the images before mpeg-ing.
To run it, you'll need:

   - perl
   - The public-domain program "mpeg_encode"; we got our copy a year ago from
	ftp.cc.utexas.edu under source/graphics/mpeg_encode-1.2/...
	but you can probably find a closer source.
   - the "pbmplus" a.k.a. "netpbm" toolkit, widely available
   - and, you'll need to create a script "img2pnm" which converts whatever
	kind of image you can have into "PPM" format images,
	and writes the resulting PPM file to standard output.
	This might be as simple as

	#! /bin/sh
	/usr/sbin/toppm $1 /usr/tmp/file.ppm
	cat /usr/tmp/file.ppm
	rm /usr/tmp/file.ppm

A possible alternative, which I haven't tried, would be to acquire the free
"ImageMagick" package, whose "convert" program can do lots of image conversions,
including reading SGI format and writing PPM.  ImageMagick is quite a nice
package.  If you go that route, you don't need the pbmplus toolkit.
In the script below, I think you'd change

	   $scale = "|pbmplus -xsize $1";
	to
	   $scale = "-geometry $1";

	and also change
	    INPUT_CONVERT	  img2pnm *  $scale
	to
	    INPUT_CONVERT	  convert $scale avs:* ppm:-

Good luck.

   - Stuart Levy, Geometry Center, University of Minnesota

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  /u/share/bin/img2mpeg
# Wrapped by slevy at morse on Fri May 17 10:28:42 1996
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f '/u/share/bin/img2mpeg' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'/u/share/bin/img2mpeg'\"
else
echo shar: Extracting \"'/u/share/bin/img2mpeg'\" \(2469 characters\)
sed "s/^X//" >'/u/share/bin/img2mpeg' <<'END_OF_FILE'
X#! /usr/local/bin/perl
X
X# Wrapper around mpeg_encode.
X
X$usage = "Usage: img2mpeg [-o output.mpeg] [-w xsize] [-q qI,qP,qB] [-p pattern]
X		[- (or) file ...]
Xcalls mpeg_encode to convert a collection of image files
Xto an MPEG movie.  Options:
X    -o  name of output file, default -o output.mpeg
X    -w  resize images to 'xsize' pixels wide; default orig. size
X    -q  qI,qP,qB   Quality factors, 3..31, 3 being best, default -q 3,5,4
X    -p  framepattern Pattern of I-, P- and B-frames, default -p IPIPI
X    file ...  list of image files
X    -  Read a list of file names from standard input, one per line\n";
X
X$out = "output.mpeg";
X$pattern = "IPIPI";
X
Xwhile($ARGV[0] =~ /^-./) {
X    if($ARGV[0] eq "-o") { shift, $out = shift, next; }
X    elsif($ARGV[0] eq "-w") {
X	shift, $_ = shift;
X	unless(/(\d+)/ || $1 < 1 || $1 != int($1)) {
X	    print STDERR "-s imagesize: expected desired image width in pixels\n";
X	    exit(1);
X	}
X	$scale = "| pnmscale -xsize $1";
X    } elsif($ARGV[0] eq "-q") {
X	shift, $_ = shift;
X	tr/,/ /;
X	@quality = split(' ', $_);
X	if(grep($_ < 1 || $_ > 31, @quality)) {
X	    print STDERR "-q qI,qP,qB: expected quality factors, each in range 1..31\n";
X	    exit(1);
X	}
X	grep($_ < 3 && ($_ = 3), @quality);
X    } elsif($ARGV[0] eq "-p") {
X	shift, $pattern = shift;
X	if($pattern =~ /[^IBP]/i || $pattern !~ /I/i) {
X	    print STDERR "-p pattern: must contain a sequence of letters from I, B, or P (default IBPBI)
Xand must include at least one I.\n";
X	    exit(1);
X	}
X    } else {
X	print STDERR "Unknown option: $ARGV[0]\n$usage";
X	exit(1);
X    }
X}
X
X
Xif ($#ARGV < 0) {
X    print STDERR $usage;
X    exit(1);
X}
X
X
X$PF = "/usr/tmp/$$.encode";
X
X$SIG{'INT'} = 'quit';
X$SIG{'HUP'} = 'quit';
X$SIG{'TERM'} = 'quit';
X
Xsub quit {
X    unlink($PF);
X    exit(1);
X}
X
X$gop = length($pattern);
X
Xopen(PF, ">$PF");
Xselect(PF);
Xprint "
XPATTERN			$pattern
XOUTPUT			$out
XBASE_FILE_FORMAT	PNM
XINPUT_CONVERT		img2pnm *  $scale
XSLICES_PER_FRAME	1
XGOP_SIZE		$gop
XPIXEL			FULL
XRANGE			10
XPSEARCH_ALG		LOGARITHMIC
XBSEARCH_ALG		CROSS2
XREFERENCE_FRAME		ORIGINAL
XINPUT_DIR		.
X";
X
Xprint "IQSCALE\t", $quality[0] || 3, "\n";
Xprint "PQSCALE\t", $quality[1] || 5, "\n";
Xprint "BQSCALE\t", $quality[2] || 4, "\n";
X
Xprint "INPUT\n";
X
Xwhile($_ = shift) {
X    if($_ eq "-") {
X	while(<STDIN>) {
X	    print;
X	    print "\n" unless $_ =~ /\n$/;
X	}
X    } else {
X	print $_, "\n";
X    }
X}
X
Xprint "END_INPUT\n";
X
Xclose(PF);
X
Xsystem("mpeg_encode -stat /dev/null -no_frame_summary $PF");
X
Xunlink($PF);
END_OF_FILE
if test 2469 -ne `wc -c <'/u/share/bin/img2mpeg'`; then
    echo shar: \"'/u/share/bin/img2mpeg'\" unpacked with wrong size!
fi
chmod +x '/u/share/bin/img2mpeg'
# end of '/u/share/bin/img2mpeg'
fi
echo shar: End of shell archive.
exit 0


 
Home | Overview | FAQ | Documentation | Support | Download | Mailing List
Windows? | Development | Bug Reporting | Contributing | Contact Us | Sponsors
 
site hosted by
SourceForge Logo