From 56b7655e67528880778696d32f2d3a3e3ff30782 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Thu, 18 May 2017 11:06:33 +0200 Subject: Generalize function videosize. --- bin/stream | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'bin/stream') diff --git a/bin/stream b/bin/stream index db1c100..24213d3 100755 --- a/bin/stream +++ b/bin/stream @@ -7,6 +7,11 @@ set -eu # TODO: Externalize to site-specific configfile [ $# -gt 0 ] || set -- morla 5002 -- dvcam ../../content/icon_small.png +## +## defaults +## +RATIO=4:3 + ## ## generic functions ## @@ -113,8 +118,15 @@ HEIGHT=288 HEIGHTS_WEBM="$HEIGHT" HEIGHTS_MPEG="$HEIGHT" -RATIO_NUM=4 -RATIO_DEN=3 +videosize() { height=$1; width_or_ratio=$2; + case $width_or_ratio in + *:*) num=${width_or_ratio%:*}; den=${width_or_ratio#*:}; width=$((height*num/den));; + *) width=$width_or_ratio;; + esac + echo_n $((height*width)) +} + +BITS=$(videosize "$HEIGHT" "$RATIO") # * bitrates and bits in parens based on https://developer.apple.com/library/content/documentation/General/Reference/HLSAuthoringSpec/Requirements.html # + bits rounded up to include nearby modulo 16 formats @@ -122,10 +134,6 @@ RATIO_DEN=3 # + best (i.e. high-modulo) 4:3 heights: 288 312 384 480 624 816 # * speeds tuned to just below 100% cpu usage for each combination on a multi-core computer # TODO: Externalize speeds to site-specific configfile -RATIO_NUM=${RATION_NUM:-16} -RATIO_DEN=${RATION_DEN:-9} -WIDTH=${WIDTH:-$((HEIGHT*RATIO_NUM/RATIO_DEN))} -BITS=$((WIDTH*HEIGHT)) if [ $BITS -le 110592 ]; then # 234p → 97344 VBITRATE=145000 SPEED_X264=fast; SPEED_X264_ALONE=fast -- cgit v1.2.3