summaryrefslogtreecommitdiff
path: root/localvideowebencode
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2011-09-19 14:16:18 +0200
committerJonas Smedegaard <dr@jones.dk>2011-09-19 14:16:18 +0200
commit528e6968dc41af053d3ef94ee7536194f9eadcde (patch)
tree0f112ea07f66f433857243b1d2a8e0dfaed23c90 /localvideowebencode
parent4639372d4de5384e0d33963f4e03592a3563aeb9 (diff)
Make --size optional.
Diffstat (limited to 'localvideowebencode')
-rwxr-xr-xlocalvideowebencode19
1 files changed, 9 insertions, 10 deletions
diff --git a/localvideowebencode b/localvideowebencode
index 53d133d..753ea80 100755
--- a/localvideowebencode
+++ b/localvideowebencode
@@ -8,6 +8,8 @@
# Possible flashplayers:
# http://www.internetmarketingnotes.com/2010/07/free-embeddable-flash-video-flv-players-for-commercial-use/
+# TODO: support --width and --height (resolving the other part from input/forced aspect ratio)
+
set -e
PRG=$(basename "$0")
@@ -19,7 +21,6 @@ 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
@@ -71,14 +72,6 @@ infile="$1"; shift
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
-[ -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 profile
profile=${profile:-lo}
case "$profile" in
@@ -132,7 +125,7 @@ _ffmpeg() {
esac
}
-opts_common="-threads 0 -b ${bitrate}k -s $size -aspect $aspect"
+opts_common="-threads 0 -b ${bitrate}k ${size:+-s $size} ${aspect:+-aspect $aspect}"
opts_audio="-ac 2 -ar 44100 -ab 96k"
opts_webm="-vcodec libvpx -keyint_min 0 -g 250 -skip_threshold 0"
@@ -151,6 +144,12 @@ _ffmpeg 2 mp4 $opts_common -vcodec libx264 -vpre medium -vpre baseline -acodec l
## JPEG preview
ffmpegthumbnailer -s0 -i "$filebase.ogg" -o "$filebase.jpg"
+# resolve width and height from preview image
+size=${size:-$(jpeginfo "$filebase.jpg" | perl -ane 'print "$F[1]x$F[3]"')}
+width=$(echo "$size" | perl -Fx -ane 'print $F[0]')
+height=$(echo "$size" | perl -Fx -ane 'print $F[1]')
+heightplus=${height:+$(($height+4))}
+
# TODO: resolve flash player to use
[ -z "$flashplayer" ] || flash=yes