#!/usr/bin/perl
#
# Turn a bunch of JPG images into a movie
#
# MWR 8/14/2022

$debug = 1;

# this yields a good-looking MOV file, size about 288 MBytes
if (1 == 1) {
  $cmd = "ffmpeg -y -framerate 10 -pattern_type glob -i '*.jpg' ";
  $cmd .= "  -c:v prores -profile:v 3   " ;
  $cmd .= "  -vf 'scale=iw*0.5:ih*0.5' ";
  #$cmd .= "  -vf 'eq=gamma=1.5' ";
  $cmd .= "   out_small_a.mov ";
  $ret = exec_cmd($cmd);
}


# this yields a decent GIF, which is smaller than the MOV, about 80 MBytes
if (1 == 1) {
  $cmd = "ffmpeg -y -framerate 10 -pattern_type glob -i '*.jpg' ";
  $cmd .= "  -vf 'scale=iw*0.5:ih*0.5' ";
  #$cmd .= "  -vf 'eq=gamma=1.5' ";
  $cmd .= "   out_small_a.gif ";
  $ret = exec_cmd($cmd);
}


exit 0;




##############################################################################
# PROCEDURE: exec_cmd
#
# DESCRIPTION: Execute the given shell command line.  If the $debug flag
#              is set, we print to stdout the command line, and
#              also print out the result string.
#
# RETURNS:
#              the result of the command
#
#
sub exec_cmd {

  my($cmd, $ret);

  $cmd = $_[0];

  if ($debug > 0) {
    printf "cmd is ..$cmd.. \n";
  }
  $ret = `$cmd`;
  if ($debug > 0) {
    printf "ret is ..$ret.. \n";
  }

  return($ret);
}


