show_usage() {
printf "Usage: %s <start hh:mm:ss> <end hh:mm:ss> <inputfile>\n" "$0"
}
if [ $# -lt 2 ]; then
show_usage
exit 1
fi
if [[ $1 == "-h" || $1 == "--help" ]]
then
show_usage
exit 0
fi
start=$1
end=$2
length=$(timediff $start $end)
shift 2
name=$@
echo "Start enconding now"
ffmpeg -vcodec copy -map 0.0 -acodec copy -map 0.1 -ss $start -t $length -i "$name" "tmp-$name"
mencoder "tmp-$name" -o "${name%.*}.mkv" -oac mp3lame -ovc x264
rm "tmp-$name"
printf "Finished - Output: %s" "${name%.*}.mkv\n"