summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2011-11-16 03:41:43 +0700
committerJonas Smedegaard <dr@jones.dk>2011-11-16 03:41:43 +0700
commit008982ec8e7630e237b34ce5de8ee26893006e06 (patch)
treee6d85b47b193142ebd0272c59605793045a6ff7d
parent14b847e5201363ef82e54df2ceae3c0b7cef1ad6 (diff)
Support passing options to melt producer.
-rwxr-xr-xlocalvideowebencode33
1 files changed, 24 insertions, 9 deletions
diff --git a/localvideowebencode b/localvideowebencode
index 97e23f9..630b58c 100755
--- a/localvideowebencode
+++ b/localvideowebencode
@@ -19,7 +19,7 @@ PRG=$(basename "$0")
showhelp() {
cat <<EOF
-Usage: $PRG [OPTION...] [--] [ARG=VALUE...] INPUTFILE [INPUTFILE...]
+Usage: $PRG [OPTION...] [--] [ARG=VALUE...] INPUTFILE... [ARG=VALUE...]
Encode video file in multiple web-optimized formats, and provide sample
html favoring open formats with optional non-JavaScript Flash fallback.
@@ -43,7 +43,8 @@ Examples:
$PRG -s qvga -t "Funny guy" intro.dv myvideo.dv
$PRG -p sdi_486i_5994 --stem funny -t "Funny guy" myvideo.dv
-Arguments after double-dash are passed to the melt avformat consumer.
+Options before input files are passed to melt producer, and after to
+melt avformat consumer.
Defaults are optimized for 320x240 (qvga). For better quality use this:
@@ -85,13 +86,27 @@ while true ; do
esac
done
-if [ $# -eq 0 ]; then
+while [ $# -gt 0 ] ; do
+ case "$1" in
+ *=*) args_in="${args_in:+$args_in }$1"; shift;;
+ *) break;;
+ esac
+done
+
+while [ $# -gt 0 ] ; do
+ case "$1" in
+ *=*) args_out="${args_out:+$args_out }$1"; shift;;
+ *) infiles="${infiles:+$infiles }$1"; shift;;
+ esac
+done
+
+if [ -z "$infiles" ]; then
showhelp
exit1 "Too few parameters!"
fi
# input filename (mandatory)
-infile=$(perl -e 'print pop @ARGV' "$@")
+infile=$(perl -e 'print pop @ARGV' $infiles)
[ -e "$infile" ] || exit1 "Input file missing!"
# resolve stem and title (if not explicitly set)
@@ -101,23 +116,23 @@ title=${title:-$stem}
# TODO: Check and fail if all needed tools are not available
# TODO: When verified beneficial, add option real_time=-2
-opts="${profile:+-profile $profile}"
+args_in="${profile:+-profile $profile}${args_in:+ $args_in}"
args=" ${bitrate:+b=${bitrate}} ${size:+s=$size} ${aspect:+aspect=$aspect}"
args_audio="ac=2 ar=44100 ab=96k"
## Theora/Vorbis/Ogg
-melt $opts -consumer avformat:"$stem.ogg" f=ogg vcodec=libtheora $args acodec=libvorbis aq=25 $args_audio "$@"
+melt -group $args_in $infiles -group -consumer avformat:"$stem.ogg" f=ogg vcodec=libtheora $args acodec=libvorbis aq=25 $args_audio $args_out
## H.264/AAC/MP4
-melt $opts -consumer avformat:/dev/null f=mp4 properties=x264-medium-$h264profile $args pass=1 an=1 fastfirstpass=1 "$@"
-melt $opts -consumer avformat:"$stem.mp4" properties=x264-medium-$h264profile $args pass=2 acodec=libvo_aacenc $args_audio "$@"
+melt -group $args_in $infiles -group -consumer avformat:/dev/null f=mp4 properties=x264-medium-$h264profile $args pass=1 an=1 fastfirstpass=1 $args_out
+melt -group $args_in $infiles -group -consumer avformat:"$stem.mp4" properties=x264-medium-$h264profile $args pass=2 acodec=libvo_aacenc $args_audio $args_out
mv "$stem.mp4" "$stem.mp4"~
qt-faststart "$stem.mp4"~ "$stem.mp4"
[ -f "$stem.mp4" ] && rm "$stem.mp4"~ || exit1 "failed to optimize with qt-faststart."
## VP8/Vorbis/WebM
# TODO: use two-pass when supported by melt
-melt $opts -consumer avformat:"$stem.webm" properties=webm $args $args_audio "$@"
+melt -group $args_in $infiles -group -consumer avformat:"$stem.webm" properties=webm $args $args_audio $args_out
## JPEG preview
ffmpegthumbnailer -s0 -i "$stem.mp4" -o "$stem.jpg"