#!/bin/sh

SRC="$1"
DST="$2"
SIZE="320x240"

if [ "$1" = "-w" ]
then
	echo "widescreen!"
	SIZE="320x180"
	SRC="$2"
	DST="$3"
fi

# convert video
ffmpeg -y -i "$SRC" -threads auto -vcodec libx264 -b 250k -maxrate 768k \
 -flags +loop  -cmp +chroma -partitions +parti4x4+partp4x4+parti8x8+partp8x8 -flags2 \
 +mixed_refs -level 13 -refs 3 -subq 7 -trellis 2 -me 6 -g 300 -s $SIZE -ab 128k -ar\
 44100 -ac 2 -acodec libfaac "$DST.mp4"

# make thumbnail
ffmpeg -y -i "$DST.mp4" -f mjpeg -ss 30 -vframes 1 -an "$DST.jpg"
