diff options
Diffstat (limited to 'localvideowebencode')
-rwxr-xr-x | localvideowebencode | 78 |
1 files changed, 68 insertions, 10 deletions
diff --git a/localvideowebencode b/localvideowebencode index 8910e73..c0c0e3a 100755 --- a/localvideowebencode +++ b/localvideowebencode @@ -23,14 +23,23 @@ 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. + -p, --profile Video format: + [modulus 16] + 320x240 qvga 240p 432x240 wqvga + 640x480 vga 480p 848x480 wvga + 576p 1024x576 wsvga + 1024x768 xga hd 720p 1280x720 wxga + [modulus 8] + 480x360 hvga nhd 360p 640x360 + 800x600 svga -s, --size Output size (ffmpeg): WIDTHxHEIGHT vga qcif etc. (default: use input size) -a, --aspect Display Aspect Ratio in melt format e.g. @16/9 (default: no aspect hinting) + -r, --rate Video framerate + (default: 25) -b, --bitrate Video bitrate in bytes, with optional ISO suffix (default: none) - -p, --profile Video format (melt): square_ntsc qcif_15 etc. - (default: none - reuse input format) --h264profile MPEG-4 AVC target profile (baseline medium) (default: baseline) --stem Stem of output filenames, optionally with path @@ -44,7 +53,7 @@ html favoring open formats with optional non-JavaScript Flash fallback. Examples: $PRG -s qvga -t "Funny guy" intro.dv myvideo.dv - $PRG -p sdi_486i_5994 --stem funny -t "Funny guy" myvideo.dv + $PRG -p 480p --stem funny -t "Funny guy" myvideo.dv Options before input files are passed to melt producer, and after to melt avformat consumer. @@ -54,6 +63,7 @@ When video bitrate is set, 2-pass encoding is used for MPEG-4 output. Hints: * Use max. 640x480 pixel size for widest compatibility (ie. square-pixel 640x360 or anamorphic svcd_ntsc_wide for 16:9) + * Use a modulus 16 profile (qvga vga 480p 720p) for best compression. * Append these for single-mic speech: ac=1 ar=32000 ab=64k * Set bitrate for optimal MPEG-4/WebM bits-per-pixel ratio: + talking head: 0.1 @@ -73,18 +83,20 @@ exit1() { } # defaults +rate=25 h264profile=baseline # parse cmdline options -TEMP="`getopt -s sh -o hs:a:b:p:t: -l help,size:,aspect:,bitrate:,profile:,h264profile:,stem:,title:,filter:,sample:: -n "$PRG" -- "$@"`" || exit1 "Internal getopt error." +TEMP="`getopt -s sh -o hp:s:a:r:b:t: -l help,profile:,size:,aspect:,rate:,bitrate:,h264profile:,stem:,title:,filter:,sample:: -n "$PRG" -- "$@"`" || exit1 "Internal getopt error." eval set -- "$TEMP" while true ; do case "$1" in -h|--help) showhelp; exit;; + -p|--profile) profile="$2"; shift 2;; -s|--size) size="$2"; shift 2;; -a|--aspect) aspect="$2"; shift 2;; + -r|--rate) rate="$2"; shift 2;; -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;; @@ -129,16 +141,62 @@ infile=$(perl -e 'print pop @ARGV' $infiles) stem=${stem:-$(basename "$infile" | perl -pe 's/\.[^.]*//')} title=${title:-$stem} +case "$profile" in + 320x240|qvga) + _melt_in="-profile=quarter_pal${_melt_in:+ $_melt_in}" + _melt="${size:-width=320 height=240}${_melt:+ $_melt}" + ;; + 480x360|hvga) + _melt_in="-profile=quarter_pal${_melt_in:+ $_melt_in}" + _melt="${size:-width=480 height=360}${_melt:+ $_melt}" + ;; + 640x480|vga) + _melt_in="-profile=quarter_pal${_melt_in:+ $_melt_in}" + _melt="${size:-width=640 height=480}${_melt:+ $_melt}" + ;; + 800x600|svga) + _melt_in="-profile=quarter_pal${_melt_in:+ $_melt_in}" + _melt="${size:-width=800 height=600}${_melt:+ $_melt}" + ;; + 1024x768|xga) + _melt_in="-profile=quarter_pal${_melt_in:+ $_melt_in}" + _melt="${size:-width=1024 height=768}${_melt:+ $_melt}" + ;; + 240p|432x240|wqvga) + _melt_in="-profile=atsc_720p_25${_melt_in:+ $_melt_in}" + _melt="${size:-width=432 height=240}${_melt:+ $_melt}" + ;; + 360p|640x360|nhd) + _melt_in="-profile=atsc_720p_25${_melt_in:+ $_melt_in}" + _melt="${size:-width=640 height=360}${_melt:+ $_melt}" + ;; + 480p|848x480|wvga) + _melt_in="-profile=atsc_720p_25${_melt_in:+ $_melt_in}" + _melt="${size:-width=848 height=480}${_melt:+ $_melt}" + ;; + 576p|1024x576|wsvga) + _melt_in="-profile=atsc_720p_25${_melt_in:+ $_melt_in}" + _melt="${size:-width=1024 height=576}${_melt:+ $_melt}" + ;; + 720p|1280x720|wxga|hd) + _melt_in="-profile=atsc_720p_25${_melt_in:+ $_melt_in}" + ;; + '') + _melt="progressive=1 frame_rate_den=1${_melt:+ $_melt}" + [ "25" != "$rate" ] || _melt="{_melt:+$_melt }frame_rate_num=$rate" + ;; + *) exit1 "Unknown profile \"$profile\" - please specify size and aspect directly.";; +esac + +[ "25" = "$rate" ] || _melt="{_melt:+$_melt }frame_rate_num=$rate" + # TODO: Check and fail if all needed tools are not available # TODO: When verified beneficial, add option real_time=-2 -_melt_in="-progress $sample ${profile:+-profile $profile}${_melt_in:+ $_melt_in}" -_melt=" ${bitrate:+vb=${bitrate}} ${size:+s=$size} ${aspect:+aspect=$aspect}" +_melt_in="${_melt_in:+$_melt_in }-progress $sample" +_melt="$_melt ${bitrate:+vb=${bitrate}} ${size:+s=$size} ${aspect:+aspect=$aspect}" _melt_audio="ab=96k" -# x264 Baseline requies progressive output (and probably nice generally) -_melt="${_melt+$_melt }progressive=1" - ## Theora/Vorbis/Ogg melt -group $_melt_in $infiles -group $filters -consumer avformat:"$stem.ogg" f=ogg vcodec=libtheora $_melt acodec=libvorbis $_melt_audio $_melt_out |