#!/bin/sh

#
# (c) 2006 Holger Levsen
# This is script is free software licenced under the GPLv2
#
#
#
#
#
# This script is also a hack. Have fun, take care.
#
#
#
#
#

# todo: proper params
# todo: dont use mencoder

AUTHOR="Debian-Edu Video Team"
COPYRIGHT="MIT-style"


SOURCE=dv
#SOURCE=sample
TARGET=debian-edu-erkelenz
export TARGET

mkdir -p ${TARGET}/xvid ${TARGET}/mpeg/720x576 ${TARGET}/ogg_theora/720x576 ${TARGET}/ogg_theora/384x288
#mkdir -p ${TARGET}/mpeg/384x288

#nice mencoder hdv/00_Opening_Schoolband.m2t -ovc xvid -xvidencopts bitrate=2500 -vf  scale=1280:720 -oac mp3lame -srate 48000 -o $TARGET/xvid/00_Opening_Schoolband.avi 
#nice mencoder hdv/00_Opening_Schoolband.m2t -ovc xvid -xvidencopts bitrate=1500 -vf  scale=1024:576 -oac mp3lame -srate 48000 -o $TARGET/xvid/00_Opening_Schoolband_1024x576.avi 
#####nice ffmpeg -author "$AUTHOR" -copyright "$COPYRIGHT" -i hdv/00_Opening_Schoolband.m2t -vcodec mpeg1video -b 150  -g 96 -bt 100 -ac 2 -ab 64 -ar 32000 -s 512x288 $TARGET/mpeg/384x288/00_Opening_Schoolband_384x288.mpeg 
#nice ffmpeg -author "$AUTHOR" -copyright "$COPYRIGHT" -i hdv/00_Opening_Schoolband.m2t -target pal-dvd -aspect 16:9 -b 2000 $TARGET/mpeg/720x576/00_Opening_Schoolband.mpeg
#nice ffmpeg2theora --artist "$AUTHOR" --copyright "$COPYRIGHT" -x 1024 -y 576  -V 2000 -H 48000 --aspect 4:3 -a 3 -c 2 --aspect 16:9 hdv/00_Opening_Schoolband.m2t -o $TARGET/ogg_theora/720x576/00_Opening_Schoolband_1024x576.ogg
#nice ffmpeg2theora --artist "$AUTHOR" --copyright "$COPYRIGHT" -x 512 -y 288   -V  150 -H 32000 --aspect 4:3 -a 3 -c 1 --aspect 16:9 hdv/00_Opening_Schoolband.m2t -o $TARGET/ogg_theora/384x288/00_Opening_Schoolband_512x288.ogg

#cd ${SOURCE} && time for i in *.mov ; do time nice -n 19 mencoder $i -of avi -ovc xvid -xvidencopts bitrate=900 -oac mp3lame -srate 48000 -o ../$TARGET/xvid/${i%.mov}.avi ; done && cd ../$TARGET/xvid && rm MD5SUMS.txt ; md5sum * > MD5SUMS.txt ; cd ../..
#date | mail -s "xvids done" holger

cd ${SOURCE} && time for i in *.mov ; do time nice -n 19 ffmpeg -author "$AUTHOR" -copyright "$COPYRIGHT" -i $i -target pal-dvd -aspect 4:3 -b 1000 ../$TARGET/mpeg/720x576/${i%.mov}.mpeg ; done && cd ../$TARGET/mpeg/720x576 && rm MD5SUMS.txt ; md5sum * > MD5SUMS.txt ; cd ../../..
date | mail -s "mpeg2s done" holger

# this take 25h for 12 dv files with 80gb
#cd ${SOURCE} && time for i in *.mov ; do time nice -n 19 ffmpeg2theora --artist "$AUTHOR" --copyright "$COPYRIGHT" --aspect 4:3 -x 720 -y 576 --inputfps 25 -V 1200 -H 48000 -a 3 -c 2 $i -o  ../$TARGET/ogg_theora/720x576/${i%.mov}.ogg ; done && cd ../$TARGET/ogg_theora/720x576 && rm MD5SUMS.txt ; md5sum * > MD5SUMS.txt ; cd ../../..
#date | mail -s "good oggs done" holger

#cd ${SOURCE} && time for i in *.mov ; do time nice -n 19 ffmpeg2theora --artist "$AUTHOR" --copyright "$COPYRIGHT" --aspect 4:3 -x 384 -y 288 --inputfps 25 -V 200 -H 32000 -a 3 -c 1 $i -o  ../$TARGET/ogg_theora/384x288/${i%.mov}.ogg ; done && cd ../$TARGET/ogg_theora/384x288 && rm MD5SUMS.txt ; md5sum * > MD5SUMS.txt ; cd ../../..
#date | mail -s "bad oggs done" holgi


# DISABLED: use low quality oggs instead
#####cd ${SOURCE} && time for i in *.mov ; do time nice -n 19 ffmpeg -author "$AUTHOR" -copyright "$COPYRIGHT" -i $i -vcodec mpeg1video -b 150 -bt 100 -g 96 -ac 1 -ab 64 -ar 32000 -s 384x288  ../$TARGET/mpeg/384x288/${i%.mov}.mpeg ; done && cd ../$TARGET/mpeg/384x288 && rm MD5SUMS.txt && md5sum * > MD5SUMS.txt && cd ../../..
#####date | mail -s "mpeg1s done" holger





