#!/bin/bash
#
# Date:    2009-12-10
# Author:  Ole Kristian Lien
# License: GNU General Public License
#
# Generate intro-file with fade in/out from csv-file

EXT=`echo "$1"|awk -F . '{print $NF}'`
BASENAME=`basename $1 .$EXT`
COUNT="1"

LOGO=`./csv $2 $1 logo`
WHAT=`./csv $2 $1 what`
DATE=`./csv $2 $1 date`
LOCATION=`./csv $2 $1 location`
TITLE=`./csv $2 $1 title`
NAME=`./csv $2 $1 name`
LICENSE=`./csv $2 $1 license`

if [ -z "$2" ]; then
	echo "Usage: $0 <video-file> <csv-file>"
	exit 1
fi

echo -n " * Generating intro-video..."

# LOGO
./image_logo $1 intro-$COUNT white $LOGO
./fade $BASENAME-intro-$COUNT.png 3 white
rm $BASENAME-intro-$COUNT.png
COUNT=`expr $COUNT + 1`

# SLIDE 1
./image_text $1 intro-$COUNT white "$WHAT" "$DATE - $LOCATION"
./fade $BASENAME-intro-$COUNT.png 3 white
rm $BASENAME-intro-$COUNT.png
COUNT=`expr $COUNT + 1`

# SLIDE 2
./image_text $1 intro-$COUNT white "$TITLE" "$NAME"
./fade $BASENAME-intro-$COUNT.png 3 white
rm $BASENAME-intro-$COUNT.png
COUNT=`expr $COUNT + 1`

# LICENSE
cp $LICENSE.png $BASENAME-intro-$COUNT.png
./fade $BASENAME-intro-$COUNT.png 3 white
rm $BASENAME-intro-$COUNT.png

./image2video $1 intro
rm $BASENAME-intro-*.png

echo -e "OK!"
