diff options
Diffstat (limited to 'localvideowebencode')
-rwxr-xr-x | localvideowebencode | 55 |
1 files changed, 28 insertions, 27 deletions
diff --git a/localvideowebencode b/localvideowebencode index d8adb16..bd4b198 100755 --- a/localvideowebencode +++ b/localvideowebencode @@ -35,18 +35,19 @@ html favoring open formats with optional non-JavaScript Flash fallback. (default: none - reuse input profile) --h264profile MPEG-4 AVC target profile (baseline medium) (default: baseline) + --stem Stem of output filenames, optionally with path + (default: basename of last input file) -t, --title Title used in html fallback graphics - (default: basename of first input file) + (default: stem) -h, --help This help text Examples: - $PRG -s qvga -t "Funny guy" myvideo.dv outro.dv - $PRG -p sdi_486i_5994 -s hd480 -t "Funny guy" myvideo.dv + $PRG -s qvga -t "Funny guy" intro.dv myvideo.dv + $PRG -p sdi_486i_5994 --stem funny -t "Funny guy" myvideo.dv Arguments can be passed directly to the melt avformat consumer. -If multiple input files are provided, they are merged together and -output files are named based on last input file. +Multiple input files merged together. Default options are optimal for 320x240 (qvga) and similar. Suggested bitrates: @@ -75,7 +76,7 @@ bitrate=768k h264profile=baseline # parse cmdline options -TEMP="`getopt -s sh -o hs:a:b:p:t: -l help,size:,aspect:,bitrate:,profile:,h264profile,title: -n "$PRG" -- "$@"`" || exit1 "Internal getopt error." +TEMP="`getopt -s sh -o hs:a:b:p:t: -l help,size:,aspect:,bitrate:,profile:,h264profile:,stem:,title: -n "$PRG" -- "$@"`" || exit1 "Internal getopt error." eval set -- "$TEMP" while true ; do case "$1" in @@ -85,6 +86,7 @@ while true ; do -b|--bitrate) bitrate="$2"; shift 2;; -p|--profile) profile="$2"; shift 2;; --h264profile) h264profile="$2"; shift 2;; + --stem) stem="$2"; shift 2;; -t|--title) title="$2"; shift 2;; --) shift; break;; *) exit1 "Internal error resolving options.";; @@ -100,10 +102,9 @@ fi infile=$(perl -e 'print pop @ARGV' "$@") [ -e "$infile" ] || exit1 "Input file missing!" -filebase=$(basename "$infile" | perl -pe 's/\.[^.]*//') - -# fallback graphics title -title=${title:-$filebase} +# resolve stem and title (if not explicitly set) +stem=${stem:-$(basename "$infile" | perl -pe 's/\.[^.]*//')} +title=${title:-$stem} # TODO: Check and fail if all needed tools are not available @@ -113,24 +114,24 @@ 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:"$filebase.ogg" f=ogg vcodec=libtheora $args acodec=libvorbis aq=25 $args_audio "$@" +melt $opts -consumer avformat:"$stem.ogg" f=ogg vcodec=libtheora $args acodec=libvorbis aq=25 $args_audio "$@" ## 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:"$filebase.mp4" properties=x264-medium-$h264profile $args pass=2 acodec=libvo_aacenc $args_audio "$@" -mv "$filebase.mp4" "$filebase.mp4"~ -qt-faststart "$filebase.mp4"~ "$filebase.mp4" -[ -f "$filebase.mp4" ] && rm "$filebase.mp4"~ || exit1 "failed to optimize with qt-faststart." +melt $opts -consumer avformat:"$stem.mp4" properties=x264-medium-$h264profile $args pass=2 acodec=libvo_aacenc $args_audio "$@" +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:"$filebase.webm" properties=webm $args $args_audio "$@" +melt $opts -consumer avformat:"$stem.webm" properties=webm $args $args_audio "$@" ## JPEG preview -ffmpegthumbnailer -s0 -i "$filebase.mp4" -o "$filebase.jpg" +ffmpegthumbnailer -s0 -i "$stem.mp4" -o "$stem.jpg" # resolve width and height from preview image -size=$(jpeginfo "$filebase.jpg" | perl -ane 'print "$F[1]x$F[3]"') +size=$(jpeginfo "$stem.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))} @@ -138,22 +139,22 @@ heightplus=${height:+$(($height+4))} # TODO: resolve flash player to use [ -z "$flashplayer" ] || flash=yes -cat >"$filebase.html" <<EOF +cat >"$stem.html" <<EOF <!-- Video for Everybody, Kroc Camen of Camen Design --> <video width="$width" height="$height" preload controls> -<source src="$filebase.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"' /> -<source src="$filebase.ogg" type='video/ogg; codecs="theora, vorbis"' /> -<source src="$filebase.webm" type='video/webm; codecs="vp8, vorbis"' /> +<source src="$stem.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"' /> +<source src="$stem.ogg" type='video/ogg; codecs="theora, vorbis"' /> +<source src="$stem.webm" type='video/webm; codecs="vp8, vorbis"' /> ${flash:+<object width="$width" height="$heightplus" type="application/x-shockwave-flash" data="$flashplayer.swf"> <param name="movie" value="$flashplayer.swf" /> -<param name="flashvars" value="image=$filebase.jpg&file=$filebase.mp4" /> -}<img src="$filebase.jpg" width="$width" height="$height" alt="$title" +<param name="flashvars" value="image=$stem.jpg&file=$stem.mp4" /> +}<img src="$stem.jpg" width="$width" height="$height" alt="$title" title="No video playback capabilities, please download the video below" /> ${flash:+</object> }</video> <p><strong>Download Video:</strong> -open format <a href="$filebase.ogg">Ogg</a>, -open format <a href="$filebase.webm">WebM</a>, -closed Format <a href="$filebase.mp4">MP4</a>. +open format <a href="$stem.ogg">Ogg</a>, +open format <a href="$stem.webm">WebM</a>, +closed Format <a href="$stem.mp4">MP4</a>. </p> EOF |