summaryrefslogtreecommitdiff
path: root/bin/loop+encode+stream
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2017-05-18 11:06:33 +0200
committerJonas Smedegaard <dr@jones.dk>2017-05-18 11:06:33 +0200
commit56b7655e67528880778696d32f2d3a3e3ff30782 (patch)
tree97dcafe8019733a36e89a3015bb0b09c98d1da10 /bin/loop+encode+stream
parentbff6b3ca2fc4f13592a52e3979161c8faa5b7bc0 (diff)
Generalize function videosize.
Diffstat (limited to 'bin/loop+encode+stream')
-rwxr-xr-xbin/loop+encode+stream20
1 files changed, 14 insertions, 6 deletions
diff --git a/bin/loop+encode+stream b/bin/loop+encode+stream
index 6e6abb3..eaf8897 100755
--- a/bin/loop+encode+stream
+++ b/bin/loop+encode+stream
@@ -7,6 +7,11 @@ set -e
INPUT=../tmp/omni/show0/earth.yuv
##
+## defaults
+##
+RATIO=4:3
+
+##
## generic functions
##
# shellcheck disable=SC2048,SC2059
@@ -30,8 +35,15 @@ ABITRATE_OPUS=48000
# TODO
HEIGHT=384
-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
@@ -39,10 +51,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_VP8=2