CUTOPT="-vcodec libx264 -vpre lossless_ultrafast -acodec libfaac -ab 192k"
OPTS1="-pass 1 -vcodec libx264 -vpre slow_firstpass -s hd480 -b 1200k -bt 1200k -threads 0 -f rawvideo -y /dev/null"
OPTS2="-pass 2 -vcodec libx264 -vpre slow -s hd480 -b 1200k -bt 1200k -acodec libfaac -ab 192k -threads 0"

ORIGINALUID=2438
CUID=$ORIGINALUID
FINALUID=FILL_FINAL_UID

create ()
{
   echo $PERSON - Making Cut
   ffmpeg -i raw/$FILENAME -ss $START -t $DURATION $CUTOPT cut.mp4
   echo $PERSON - Pass 1
   ffmpeg -i cut.mp4 $OPTS1
   echo $PERSON - Pass 2
   ffmpeg -i cut.mp4 $OPTS2 output.mp4
   qt-faststart output.mp4 $OUTNAME.mp4
   echo $PERSON - Screenshot
   ffmpeg -i output.mp4 -an -ss 10 -an -r 1 -vframes 1 -y %d.jpg 
   rm output.mp4 cut.mp4 *log*
   mv 1.jpg web/$OUTNAME.jpg
   cp web/template.html web/$OUTNAME.html
   sed -i "s/FILL_FILENAME/$FILENAME/" web/$OUTNAME.html
   sed -i "s/FILL_OUTNAME/$OUTNAME/" web/$OUTNAME.html
   sed -i "s/FILL_PERSON/$PERSON/" web/$OUTNAME.html
   sed -i "s/FILL_UID/$CUID/" web/$OUTNAME.html

   CUID=$(($CUID+1))
   #Need this?  export CUID
}


# Don't do this stuff for now
if [ "A" = "B" ] ; then
	echo none
FILENAME=MVI_.MOV
START=00:
DURATION=
OUTNAME=
PERSON=$OUTNAME
create

FILENAME=MVI_3120.MOV
START=00:00:24
DURATION=31.5
OUTNAME=Cara
PERSON="Cara"
create

FILENAME=MVI_3120.MOV
START=00:01:54
DURATION=39.5
OUTNAME=Hanna
PERSON=$OUTNAME
create

FILENAME=MVI_3121.MOV
START=00:00:08
DURATION=33.5
OUTNAME=MarkAndBecca
PERSON="Mark and Becca"
create

FILENAME=MVI_3121.MOV
START=00:00:58
DURATION=36.5
OUTNAME=Gram
PERSON=$OUTNAME
create

FILENAME=MVI_3121.MOV
START=00:01:46
DURATION=31.5
OUTNAME=KevinK
PERSON=Kevin
create

FILENAME=MVI_3122.MOV
START=00:00:27
DURATION=53.5
OUTNAME=Nolan
PERSON="Mr. Nolan"
create

FILENAME=MVI_3122.MOV
START=00:02:27
DURATION=49.5
OUTNAME=KevinG
PERSON=Kevin
create

FILENAME=MVI_3123.MOV
START=00:00:05
DURATION=38.5
OUTNAME=Patrick
PERSON=$OUTNAME
create

FILENAME=MVI_3123.MOV
START=00:01:08
DURATION=56.5
OUTNAME=MoK
PERSON="Aunt Mo"
create

FILENAME=MVI_3124.mkv
START=00:00:06
DURATION=37.5
OUTNAME=KathleenK
PERSON=Kathleen
create

FILENAME=MVI_3126.mkv
START=00:00:08
DURATION=32
OUTNAME=EmilyB
PERSON=Emily
create

FILENAME=MVI_3126.mkv
START=00:03:28
DURATION=33
OUTNAME=Parents
PERSON="Mom and Dad"
create

FILENAME=MVI_3120.MOV
START=00:01:03
DURATION=43.5
OUTNAME=EmilyR
PERSON=Emily
create

FILENAME=MVI_3123.MOV
START=00:03:39
DURATION=53.5
OUTNAME=PK
PERSON="Aunt P"
create

FILENAME=MVI_3124.mkv #MVI_3124_un.mkv
START=00:01:04
DURATION=53.5
OUTNAME=SheahanTry1
PERSON="Mr. and  Mrs. Sheahan"
create

FILENAME=MVI_3124.mkv #MVI_3124_un.mkv
START=00:02:18
DURATION=50
OUTNAME=Johnson
PERSON="Johnson Family"
create

FILENAME=MVI_3126.mkv #MVI_3126_un.mkv
START=00:04:09
DURATION=49
OUTNAME=Lisa
PERSON=$OUTNAME
create

FILENAME=MVI_3126.mkv #MVI_3126_un.mkv
START=00:05:14
DURATION=50
OUTNAME=SrCarolTry1
PERSON="Sr. Carol"
create

FILENAME=MVI_3126.mkv #MVI_3126_un.mkv
START=00:06:26
DURATION=56
OUTNAME=GGRiley
PERSON="Grandma and Grandpa"
create

FILENAME=MVI_3126.mkv #MVI_3126_un.mkv
START=00:01:10
DURATION=43
OUTNAME=MikeF
PERSON=Mike
create

FILENAME=MVI_3126.mkv #MVI_3126_un.mkv
START=00:02:08
DURATION=46
OUTNAME=BillAndTerriTry1
PERSON="Bill and Terri"
create

FILENAME=MVI_3123.MOV
START=00:06:50
DURATION=57.5
OUTNAME=ZechTry1
PERSON="Zech Family"
create

FILENAME=MVI_3123.MOV
START=00:02:16
DURATION=69.0
OUTNAME=Armgardts
PERSON="Armgardt Family"
create

FILENAME=MVI_3120.MOV
START=00:02:44
DURATION=43.5
OUTNAME=Jamey
PERSON=$OUTNAME
create

FILENAME=MVI_4430.mkv
START=00:03:19
DURATION=52
OUTNAME=StEds
PERSON="St. Edwards Community"
create

FILENAME=MVI_4430.mkv
START=00:06:58
DURATION=66
OUTNAME=Hattie
PERSON="Aunt Hattie"
create

FILENAME=MVI_4430.mkv
START=00:10:24
DURATION=53
OUTNAME=BillAndTerri
PERSON="Bill and Terri"
create

FILENAME=MVI_4430.mkv
START=00:11:53
DURATION=54
OUTNAME=Chrissie
PERSON=$OUTNAME
create

FILENAME=MVI_4430.mkv
START=00:13:22
DURATION=70
OUTNAME=SrCarol
PERSON="Sr. Carol"
create

FILENAME=MVI_4430.mkv
START=00:14:56
DURATION=57
OUTNAME=Zech
PERSON="Mr. & Mrs. Zech"
create

FILENAME=MVI_4430.mkv
START=00:17:57
DURATION=65
OUTNAME=Carl
PERSON=$OUTNAME
create

fi

FILENAME=MVI_4430.mkv
START=00:16:48
DURATION=62
OUTNAME=Sheahen
PERSON="Mr. & Mrs. Sheahen"
create

rm *log*
echo v$(($CUID-1)) > ClipFinalUID.txt

