#!/bin/sh

echo "Paul T.Threshold 2003"
echo -n "Extracting jpegs..."
mplayer -nosound -vo jpeg $@ 
echo "Extracted."
export PPPT_BACKRIP=9000000000000000000
echo -n "Reordering them..."
for i in `ls -r *.jpg` ; do PPPT_BACKRIP=$(($PPPT_BACKRIP+1)); mv $i $PPPT_BACKRIP$i ; done;
echo ": done."
echo "...and finally encoding the result to \'reverse_pttoutput.avi\'..."
mencoder -mf type=jpeg:fps=25 -o reverse_pttoutput.avi -info comment="Paul T.Threshold 2003" -ovc lavc -lavcopts vcodec=mpeg4 mf://*
unset PPPT_BACKRIP
rm -f 9000000*.jpg
echo "Finished. Enjoy! ;-)"

