summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2017-05-19 13:00:52 +0200
committerJonas Smedegaard <dr@jones.dk>2017-05-19 13:00:52 +0200
commitb86ac790479ee47813964db53ed71d04f3400b80 (patch)
treeff153af8665e869cd6a82d11e9d19e3b690aeff0
parentc853ebd6d6a4ca5aa3f3d359c55e9582fcc6bf76 (diff)
Fix sync decode+edit+encode: Generalize function videosize.
-rwxr-xr-xbin/decode+edit+encode14
1 files changed, 10 insertions, 4 deletions
diff --git a/bin/decode+edit+encode b/bin/decode+edit+encode
index 5fb0b20..fd8869f 100755
--- a/bin/decode+edit+encode
+++ b/bin/decode+edit+encode
@@ -24,14 +24,20 @@ HEIGHT=360
SPEED_VP8=4
+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
# + best (i.e. high-modulo) 16:9 heights: 216 288 360 432 576 720
# + best (i.e. high-modulo) 4:3 heights: 288 312 384 480 624 816
-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
elif [ $BITS -le 150528 ]; then # 270p → 129600