#!/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 # # Corrected by Ashlesh Sharma, shortly before Oct 2 2005 # # Details on the correction from his email : # # In the [old] perl file makempeg.pl there was a bug. It did not convert # snap.*. back to snap.*.sgi, which is required for # make_mpeg2encode_parfile to work. The make_mpeg2encode_parfile takes # the parameter "images". But since snap.*. is not converted back to # snap.*.sgi, the make_mpeg2encode_parfile parameter is missing. ($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]; print "noext = $noext\n"; $noext =~ s/\.[a-zA-Z0-9]+$//; ($sn, $num) = split /\.+/ , $imagefiles[$i]; $num = sprintf( "%s", $num); print "num = $num"; $pad = ""; for (my $i=0; $i<$n-length($num); $i++) {$pad = $pad."0";} if (length($pad) > 0) { $noext = $sn.".$pad".$num ; print "$noext\n"; $nufile = $noext.".".$ext; print "$nufile\n"; $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); print "modified_start\n"; $sgi_ext[$i] = $noext.".sgi"; $cmd = "mv ".$imagefiles[$i]." ".$sgi_ext[$i]; print "$cmd\n"; system ($cmd); $images = $images." ".$sgi_ext[$i]; print "modified_end\n"; } print "$images\n"; $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");