summaryrefslogtreecommitdiff
path: root/localvideowebencode
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2011-02-10 00:04:56 +0100
committerJonas Smedegaard <dr@jones.dk>2011-02-10 00:04:56 +0100
commit975e337ea9cd9a6663988e26400f9c38e44c6827 (patch)
treede01b5d729eb68aa373cbcc020f55670b58f4ae2 /localvideowebencode
parentb694d6c7ce904ee566cdae47402e1a0e853d7738 (diff)
Add --profile option for higher bitrade and widescreen mode.
Diffstat (limited to 'localvideowebencode')
-rwxr-xr-xlocalvideowebencode40
1 files changed, 34 insertions, 6 deletions
diff --git a/localvideowebencode b/localvideowebencode
index 0f4f3dc..d020a46 100755
--- a/localvideowebencode
+++ b/localvideowebencode
@@ -13,12 +13,14 @@ PRG=$(basename "$0")
showhelp() {
cat <<EOF
-Usage: $PRG --size SIZE [--title TITLE] INPUTFILE
+Usage: $PRG --size SIZE [--profile PROFILE] [--title TITLE] INPUTFILE
Encode video file in multiple web-optimized formats, and provide sample
html favoring open formats with optional non-JavaScript Flash fallback.
-s, --size Output size in WIDTHxHEIGHT
(mandatory)
+ -p, --profile Quality profile (lo, hi, lowide, hiwide)
+ (default: lo)
-t, --title Title used in html fallback graphics
(default: basename of input file)
-h, --help This help text
@@ -37,12 +39,13 @@ exit1() {
}
# parse cmdline options
-TEMP="`getopt -s sh -o hs:t: -l help,size:,title: -n "$PRG" -- "$@"`" || exit1 "Internal getopt error."
+TEMP="`getopt -s sh -o hs:p:t: -l help,size:,profile:,title: -n "$PRG" -- "$@"`" || exit1 "Internal getopt error."
eval set -- "$TEMP"
while true ; do
case "$1" in
-h|--help) showhelp; exit;;
-s|--size) size="$2"; shift 2;;
+ -p|--profile) profile="$2"; shift 2;;
-t|--title) title="$2"; shift 2;;
--) shift; break;;
*) exit1 "Internal error resolving options.";;
@@ -73,22 +76,47 @@ width=$(echo "$size" | perl -pe 's/x[^x]*//')
height=$(echo "$size" | perl -pe 's/[^x]*x//')
heightplus=${height:+$(($height+4))}
+# fallback profile
+profile=${profile:-lo}
+case "$profile" in
+ lo)
+ bitrateKB=200
+ bitrateB=204800
+ aspect=4:3
+ ;;
+ lowide)
+ bitrateKB=200
+ bitrateB=204800
+ aspect=16:9
+ ;;
+ hi)
+ bitrateKB=400
+ bitrateB=409600
+ aspect=4:3
+ ;;
+ hiwide)
+ bitrateKB=400
+ bitrateB=409600
+ aspect=16:9
+ ;;
+esac
+
# fallback graphics title
title=${title:-$filebase}
# TODO: Check and fail if all needed tools are not available
## Theora/Vorbis/Ogg
-ffmpeg2theora --videobitrate 200 --max_size "$size" --output "$filebase.ogv" "$infile"
+ffmpeg2theora --videobitrate "$bitrateKB" --max_size "$size" --aspect "$aspect" --output "$filebase.ogv" "$infile"
## H.264/AAC/MP4
-HandBrakeCLI --preset "iPhone & iPod Touch" --vb 200 ${width:+--maxWidth "$width"} ${height:+--maxHeight "$height"} --two-pass --turbo --optimize --input "$infile" --output "$filebase.mp4"
+HandBrakeCLI --preset "iPhone & iPod Touch" --vb "$bitrateKB" ${width:+--maxWidth "$width"} ${height:+--maxHeight "$height"} --two-pass --turbo --optimize --input "$infile" --output "$filebase.mp4"
## VP8/Vorbis/WebM
! ffmpeg -codecs | grep -iw vp8 || webm=yes
# FIXME: check and fail if logfiles exist already
-[ -z "$webm" ] || ffmpeg -pass 1 -passlogfile "$infile" -threads 16 -keyint_min 0 -g 250 -skip_threshold 0 -qmin 1 -qmax 51 -i "$infile" -vcodec libvpx -b 204800 -s "$size" -aspect 4:3 -an -f webm -y NUL
-[ -z "$webm" ] || ffmpeg -pass 2 -passlogfile "$infile" -threads 16 -keyint_min 0 -g 250 -skip_threshold 0 -qmin 1 -qmax 51 -i "$infile" -vcodec libvpx -b 204800 -s "$size" -aspect 4:3 -acodec libvorbis -ac 2 -y "$filebase.webm"
+[ -z "$webm" ] || ffmpeg -pass 1 -passlogfile "$infile" -threads 16 -keyint_min 0 -g 250 -skip_threshold 0 -qmin 1 -qmax 51 -i "$infile" -vcodec libvpx -b "$bitrateB" -s "$size" -aspect "$aspect" -an -f webm -y NUL
+[ -z "$webm" ] || ffmpeg -pass 2 -passlogfile "$infile" -threads 16 -keyint_min 0 -g 250 -skip_threshold 0 -qmin 1 -qmax 51 -i "$infile" -vcodec libvpx -b "$bitrateB" -s "$size" -aspect "$aspect" -acodec libvorbis -ac 2 -y "$filebase.webm"
rm "$infile"-*.log
## JPEG preview