diff options
Diffstat (limited to 'localvideowebencode')
-rwxr-xr-x | localvideowebencode | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/localvideowebencode b/localvideowebencode index d4670da..b225aac 100755 --- a/localvideowebencode +++ b/localvideowebencode @@ -31,6 +31,11 @@ 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. + --video Video style: + ref-bpp + talkinghead 0.1 + action 0.15 + (default: none) -p, --profile Video format - size with optional rate suffix, delimited by @ (except for widescreen labels): e.g. 848x480@25 480p25 wvga@25 @@ -51,8 +56,11 @@ html favoring open formats with optional non-JavaScript Flash fallback. -r, --rate Video framerate - integer or fraction: e.g. 15 1001/24000 25 1001/30000 (default: use input framerate) - -b, --bitrate Video bitrate in bytes, with optional ISO suffix - (default: none) + --refbpp Reference bits-per-pixel (relative to 360p30), + for computing average bitrate when not fixed. + (default: 0.12) + -b, --bitrate Fixed video bitrate in bytes: e.g. 768k 1M + (default: none - use variable bitrate) --h264profile MPEG-4 AVC target profile: baseline main high (default: baseline) --h264preset MPEG-4 AVC target preset: slow ultrafast etc. @@ -81,15 +89,12 @@ Examples: Options before input files are passed to melt producer, and after to melt avformat consumer. -When video bitrate is set, 2-pass encoding is used for MPEG-4 output. - Hints: * Use square-pixel max. 480 width (vga 480p) for widest compatibility. * Use a modulus 16 profile (qvga vga 480p 720p) for best compression. - * Set bitrate for optimal MPEG-4/WebM bits-per-pixel ratio: - + talking head: 0.1 - + high-motion or detailed content: 0.15 - (inspect bits-per-pixel ratio with mediainfo) + * Try lower reference bits-per-pixel until visual quality is affected. + * Raise reference bits-per-pixel if needed, but no higher than 0.2. + (you can inspect actual bits-per-pixel and bitrate with mediainfo) More info: <http://camendesign.com/code/video_for_everybody> @@ -110,7 +115,7 @@ exit1() { h264profile=baseline # parse cmdline options -TEMP="`getopt -s sh -o hp:s:a:r:b:t: -l help,profile:,size:,aspect:,rate:,bitrate:,h264profile:,h264preset:,webmpreset:,audio:,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:,video:,refbpp:,bitrate:,h264profile:,h264preset:,webmpreset:,audio:,stem:,title:,filter:,sample:: -n "$PRG" -- "$@"`" || exit1 "Internal getopt error." eval set -- "$TEMP" while true ; do case "$1" in @@ -119,6 +124,8 @@ while true ; do -s|--size) size="$2"; shift 2;; -a|--aspect) aspect="$2"; shift 2;; -r|--rate) framerate="$2"; shift 2;; + --video) video="$2"; shift 2;; + --refbpp) refbpp="$2"; shift 2;; -b|--bitrate) bitrate_fixed="$2"; shift 2;; --h264profile) h264profile="$2"; shift 2;; --h264preset) h264preset="$2"; shift 2;; @@ -241,6 +248,19 @@ done << EOF $(mediainfo --Inform="Video;%Width% %Height% %FrameRate%" "$infile_first") EOF +case "$video" in + talkinghead) + refbpp="${refbpp:-0.1}" + ;; + action) + refbpp="${refbpp:-0.15}" + ;; + '') + refbpp="${refbpp:-0.12}" + ;; + *) exit1 "Unknown video style \"$video\".";; +esac + case "$h264profile" in baseline|main) _melt_h264="properties=x264-medium-$h264profile ${h264preset:+-vpre=libx264-$h264preset}" @@ -264,6 +284,12 @@ if [ -n "$_pixels" ] && [ $_pixels -ge $((1024*768)) ]; then fi bitrate="$bitrate_fixed" +# compute average bitrate from reference bits-per-pixel and "power of .75" +if [ -n "$_pixels" ] && [ -n "$_frames" ]; then + bitrate="${bitrate_fixed:-$(perl \ + -E "say int( +(($_pixels/(640*360))**0.75" \ + -E "*640*360*$_frames*${refbpp:-$refbpp_default}) )")}" +fi # default per-codec-channel bitrates bitrate_vorbis=64 |