summaryrefslogtreecommitdiff
path: root/localvideowebencode
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2010-09-07 16:26:57 +0200
committerJonas Smedegaard <dr@jones.dk>2010-09-07 16:34:24 +0200
commit08932f084ab06e8dfa4e8631c27d392c3eb62bd9 (patch)
treecae7177f2a3ea890e1a676a418057463b978a27e /localvideowebencode
parent5562aba17255c674b08d64f7e55dc85a9add099d (diff)
Add getopt option parsing, and set size and title as options.
Diffstat (limited to 'localvideowebencode')
-rwxr-xr-xlocalvideowebencode17
1 files changed, 15 insertions, 2 deletions
diff --git a/localvideowebencode b/localvideowebencode
index e49999e..cb4b2e1 100755
--- a/localvideowebencode
+++ b/localvideowebencode
@@ -15,6 +15,20 @@ exit1() {
exit 1
}
+PRG=$(basename "$0")
+
+# parse cmdline options
+TEMP="`getopt -s sh -o s:t: -l size:,title: -n "$PRG" -- "$@"`" || exit1 "Internal getopt error."
+eval set -- "$TEMP"
+while true ; do
+ case "$1" in
+ -s|--size) size="$2"; shift 2;;
+ -t|--title) title="$2"; shift 2;;
+ --) shift; break;;
+ *) exit1 "Internal error resolving options.";;
+ esac
+done
+
# input filename (mandatory)
infile="$1"; shift || exit1 "Input file missing!"
filebase=$(echo "$infile" | perl -pe 's/\.[^.]*//')
@@ -22,13 +36,12 @@ filebase=$(echo "$infile" | perl -pe 's/\.[^.]*//')
# output size in WIDTHxHEIGHT (mandatory)
# TODO: Make optional with input size as default
# TODO: Make each half of size optional with default resolved from input aspect ratio
-size="$1"; shift || exit1 "Unknown output size!"
+[ -n "$size" ] || exit1 "Unknown output size!"
width=$(echo "$size" | perl -pe 's/[^x]*x//')
height=$(echo "$size" | perl -pe 's/x[^x]*//')
heightplus=${height:+$(($height+4))}
# fallback graphics title
-# TODO: implement --title option (set it in environment for now)
title=${title:-$filebase}
# TODO: Check and fail if all needed tools are not available