#/bin/bash

function install_ffmpeg(){
 sudo -n apt install ffmpeg;
};

function perform_avi_to_png(){
 local avi="$1";
 local cmd="ffmpeg -i $avi -r 1 -f image2 $(basename $avi .avi)-%3d.png";
 cmd="ffmpeg -i $avi -vframes 10 -f image2 $(basename $avi .avi)-%3d.png";
 cmd="ffmpeg -i $avi -f image2 $(basename $avi .avi)-%3d.png";
 case $avi in
  *.avi) echo "$cmd"; $cmd; ;;
  *) echo "$1 is not avi file."; ;;
 esac;
};

function perform_avi_to_pngs(){
 while [ -n "$1" ]; do
  perform_avi_to_png "$1";
  shift;
 done;
};


perform_avi_to_pngs *.avi;
