View this PageEdit this PageUploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

C script created by Rob and Robin


From: brothert@cc.gatech.edu (Jason Alan Brotherton)
Subject: Moviestrip
To: ellen.strain@lcc.gatech.edu
Date: Fri, 16 Jul 1999 15:46:58 -0400 (EDT)
Status:

Here's what she/they wrote. It's a cryptic C-shell program which basically just repeatedly calls a set of pre-defined PBM functions.

Jason




Here's the script we used. It takes any movie file as input and spits
out a "movie strip". The parameters are defined by the command line.
It was run on an sgi using the pbm library. No promises on any other
platform. The pbm library is quite fragil and you may need to
recompile it. I suggest a fast machine, the processing is quite
intense for large files.

Good luck.
-Robin Kravets
(robink@cc.gatech.edu)


  1. !/bin/csh -f
  2. Moviestrip (by Rob Kooper).
  3. based on pnmindex Copyright (C) 1991 by Jef Poskanzer.
  4. Permission to use, copy, modify, and distribute this software and its
  5. documentation for any purpose and without fee is hereby granted, provided
  6. that the above copyright notice appear in all copies and that both that
  7. copyright notice and this permission notice appear in supporting
  8. documentation. This software is provided "as is" without express or
  9. implied warranty.

set xsize=88 # make the images about this big in X
set ysize=88 # same for Y (will keep aspect ratio)
set colors=256 # quantize results to this many colors
set back="-black" # default background color
set step=15 # skip step-1 images
set max=50 # max images concat together
set pix=1 # border
set result=/tmp/mv.$$ # output name

while ( 1 )
switch ( "$1" )

case -xs:
if ( $#argv 2 ) goto usage
set xsize="$2"
shift
shift
breaksw

case -ys:
if ( $#argv 2 ) goto usage
set ysize="$2"
shift
shift
breaksw

case -st:
if ( $#argv 2 ) goto usage
set step="$2"
shift
shift
breaksw

case -a:
if ( $#argv 2 ) goto usage
set across="$2"
shift
shift
breaksw

case -c:
if ( $#argv 2 ) goto usage
set colors="$2"
shift
shift
breaksw

case -m:
if ( $#argv 2 ) goto usage
set max="$2"
shift
shift
breaksw

case -p:
if ( $#argv 2 ) goto usage
set pix="$2"
shift
shift
breaksw

case -r:
if ( $#argv 2 ) goto usage
set result="$2"
shift
shift
breaksw

case -b:
set back="-black"
shift
breaksw

case -w:
set back="-white"
shift
breaksw

case -:
goto usage
breaksw

default:
break
breaksw

endsw
end

if ( $#argv != 1 ) then
goto usage
endif

set dir=/tmp/mv.$$
if ( -d $dir ) then
echo "Directory $dir already exists."
exit 1
endif
mkdir $dir

set imagefiles=()

  1. convert movie to collection of images
echo "Extracting images into $dir, please wait."
set template=`printf "%s/######.rgb" $dir`
dmconvert -f rgb -p video -n $template $argv $template

  1. find first non black
while ( 1 )
set filename=`printf "%s/%06d.rgb" $dir $first`
set toname=`printf "%s/%06d.pnm" $dir $first`
if ( ! -f $filename ) then
echo "No images found."
exit 1
endif

sgitopnm -quiet $filename > $toname
set description=`pnmfile $toname`
rm -f $toname
if ( $description[8] != 0 ) then
echo "Starting at image $first."
break
endif

@ first += 1
end


  1. convert from sgi to pnm (at right size)

while ( 1 )
set filename=`printf "%s/%06d.rgb" $dir $first`
set pnmname=`printf "%s/%06d.pnm" $dir $first`
set toname=`printf "%s/%d.pnm" $dir $conv`
if ( ! -f $filename ) then
break
endif

sgitopnm -quiet $filename > $pnmname
set description=`pnmfile $pnmname`
if ( $description[8] == 0 ) then
rm -f $pnmname
@ first -= $step
echo "Stopping at image $first."
break
endif

pnmscale -quiet -xysize $xsize $ysize $pnmname | pnmmargin $back $pix | ppmquant -quiet $colors > $toname
rm -f $pnmname
set imagefiles=( $imagefiles $toname )

@ first += $step
@ conv += 1
if ( $conv > $max ) then
set duh=`printf "%s.%d.pnm" $result $res`
set jpg=`printf "%s.%d.jpg" $result $res`
pnmcat $back -lr $imagefiles > $duh
cjpeg $duh > $jpg
rm -f $duh
rm -f $imagefiles
@ res += 1
@ conv = 1
set imagefiles=()
endif
end

  1. now concatenate all images together
if ( $#imagefiles > 0 ) then
set duh=`printf "%s.%d.pnm" $result $res`
set jpg=`printf "%s.%d.jpg" $result $res`
pnmcat $back -lr $imagefiles > $duh
cjpeg $duh > $jpg
rm -f $duh
rm -f $imagefiles
endif

  1. remove all the tempimage
echo "Don't forget to remove all the temp files in $dir"
echo "/bin/rm -rf $dir"

  1. Tell where the strip is
echo "Output is in $result.???.jpg, numbered 1...$res"

exit 0

usage:
echo "usage: $0 [-size N] [-across N] [-colors N] [-black] pnmfile ..."
exit 1