#!/usr/bin/perl # # Usage: perl makempeg.pl mpegfile imageseq # # Dinoj Surendran 12 Feb 03 dinoj@cs.uchicago.edu # See http://astro.uchicago.edu/cosmus/tech/doc ($mpegfile,@imagefiles) = @ARGV; $images = ""; $VERBOSE = 1; # set to 0 if you dont want it on my $n = 4; # assuming that files are between snap.000.sgi and # snap.9999.sgi .... if you get snap.10000.sgi, change # this to 5. for ($i = 0; $i < $#ARGV; $i++) { if ($VERBOSE == 1) { print "Dealing with $imagefile \n"; } $noext = $imagefiles[$i]; $noext =~ s/\.[a-zA-Z0-9]+$//; ($sn, $num) = split /\.+/ , $imagefiles[$i]; $num = sprintf( "%s", $num); $pad = ""; for (my $i=0; $i<$n-length($num); $i++) {$pad = $pad."0";} if (length($pad) > 0) { $noext = $sn.".$pad".$num ; $nufile = $noext.".".$ext; $cmd = "mv ". $imagefiles[$i]." $nufile"; print ("$cmd\n") if (1 == $VERBOSE); system($cmd); $imagefiles[$i] = $nufile; } $yuvfiles[$i] = $noext.".yuv"; $cmd = "convert ".$imagefiles[$i]." ".$yuvfiles[$i]; print "$cmd\n" if (1 == $VERBOSE); system ($cmd); $images = $images." ".$imagefiles[$i]; } $cmd = sprintf("make_mpeg2encode_parfile %s",$images); print "$cmd\n" if (1 == $VERBOSE); system ("$cmd"); $cmd = sprintf("mpeg2encode mpeg2encode.par %s",$mpegfile); print "$cmd\n" if (1 == $VERBOSE); system ("$cmd");