summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2017-05-16 13:35:44 +0200
committerJonas Smedegaard <dr@jones.dk>2017-05-16 13:46:54 +0200
commit4cf5f65c2eb911b3f94cbbaa8480b588173a3fd8 (patch)
treed1b704a64eed7e4ad1b7fd7b5b454be7d101c0a0
parent3822b5e619e06c0da03ab56f77a008ecafcb944d (diff)
Resolve bitrate based on height.
-rwxr-xr-xbin/capture+encode+serve10
-rwxr-xr-xbin/decode+edit+encode10
-rwxr-xr-xbin/decode+edit+encodeDV10
-rwxr-xr-xbin/decode+edit+loop+encode+stream10
-rwxr-xr-xbin/encodevideo+loop+stream12
-rwxr-xr-xbin/loop+encode+stream12
-rwxr-xr-xbin/stream15
7 files changed, 70 insertions, 9 deletions
diff --git a/bin/capture+encode+serve b/bin/capture+encode+serve
index e3fce44..83af18c 100755
--- a/bin/capture+encode+serve
+++ b/bin/capture+encode+serve
@@ -47,7 +47,15 @@ my $HEIGHT = 240;
my $FRAMERATE = 25;
my $AUDIORATE = 48000;
-my $VBITRATE = 256000;
+my $VBITRATE;
+
+# inspired by Apple HLS recommendations
+if ( $HEIGHT le 234 ) { $VBITRATE = 145000 }
+elsif ( $HEIGHT le 270 ) { $VBITRATE = 365000 }
+elsif ( $HEIGHT le 360 ) { $VBITRATE = 730000 }
+elsif ( $HEIGHT le 432 ) { $VBITRATE = 1100000 }
+elsif ( $HEIGHT le 540 ) { $VBITRATE = 2000000 }
+elsif ( $HEIGHT le 720 ) { $VBITRATE = 3000000 }
my $VCAPS = "video/x-raw,height=$HEIGHT";
my $ACAPS = "audio/x-raw,rate=$AUDIORATE,channels=2,depth=16";
diff --git a/bin/decode+edit+encode b/bin/decode+edit+encode
index 6f86654..421dc4d 100755
--- a/bin/decode+edit+encode
+++ b/bin/decode+edit+encode
@@ -9,7 +9,15 @@ LOGO=../../content/icon_small.png
OUTPUT=../tmp/omni/show0/earth.webm
HEIGHT=360
-VBITRATE=256000
+
+# inspired by Apple HLS recommendations
+ if [ $HEIGHT -le 234 ]; then VBITRATE=145000;
+elif [ $HEIGHT -le 270 ]; then VBITRATE=365000;
+elif [ $HEIGHT -le 360 ]; then VBITRATE=730000;
+elif [ $HEIGHT -le 432 ]; then VBITRATE=1100000;
+elif [ $HEIGHT -le 540 ]; then VBITRATE=2000000;
+elif [ $HEIGHT -le 720 ]; then VBITRATE=3000000;
+fi
mkdir -p $(dirname "$OUTPUT")
diff --git a/bin/decode+edit+encodeDV b/bin/decode+edit+encodeDV
index 2a09fe1..c33635a 100755
--- a/bin/decode+edit+encodeDV
+++ b/bin/decode+edit+encodeDV
@@ -9,7 +9,15 @@ LOGO=../../content/icon_small.png
OUTPUT=../tmp/omni/show0/earth.dv
HEIGHT=360
-VBITRATE=256000
+
+# inspired by Apple HLS recommendations
+ if [ $HEIGHT -le 234 ]; then VBITRATE=145000;
+elif [ $HEIGHT -le 270 ]; then VBITRATE=365000;
+elif [ $HEIGHT -le 360 ]; then VBITRATE=730000;
+elif [ $HEIGHT -le 432 ]; then VBITRATE=1100000;
+elif [ $HEIGHT -le 540 ]; then VBITRATE=2000000;
+elif [ $HEIGHT -le 720 ]; then VBITRATE=3000000;
+fi
mkdir -p $(dirname "$OUTPUT")
diff --git a/bin/decode+edit+loop+encode+stream b/bin/decode+edit+loop+encode+stream
index 6b469a5..e150957 100755
--- a/bin/decode+edit+loop+encode+stream
+++ b/bin/decode+edit+loop+encode+stream
@@ -20,7 +20,15 @@ FIRSTPORT=${2:-5002} # even number - next 3 ports used too
ITERATIONS=${3-0} # endless by default
HEIGHT=360
-VBITRATE=256000
+
+# inspired by Apple HLS recommendations
+ if [ $HEIGHT -le 234 ]; then VBITRATE=145000;
+elif [ $HEIGHT -le 270 ]; then VBITRATE=365000;
+elif [ $HEIGHT -le 360 ]; then VBITRATE=730000;
+elif [ $HEIGHT -le 432 ]; then VBITRATE=1100000;
+elif [ $HEIGHT -le 540 ]; then VBITRATE=2000000;
+elif [ $HEIGHT -le 720 ]; then VBITRATE=3000000;
+fi
# based on http://www.webmproject.org/docs/encoder-parameters/#real-time-cbr-encoding-and-streaming
# + loop-in-filter trick based on http://video.stackexchange.com/a/16933
diff --git a/bin/encodevideo+loop+stream b/bin/encodevideo+loop+stream
index 39e4b21..fb2b3b7 100755
--- a/bin/encodevideo+loop+stream
+++ b/bin/encodevideo+loop+stream
@@ -13,7 +13,17 @@ fi
FIRSTPORT=${2:-5002} # even number - next 3 ports used too
-VBITRATE=256000
+# TODO: resolve this or resize based on it
+HEIGHT=360
+
+# inspired by Apple HLS recommendations
+ if [ $HEIGHT -le 234 ]; then VBITRATE=145000;
+elif [ $HEIGHT -le 270 ]; then VBITRATE=365000;
+elif [ $HEIGHT -le 360 ]; then VBITRATE=730000;
+elif [ $HEIGHT -le 432 ]; then VBITRATE=1100000;
+elif [ $HEIGHT -le 540 ]; then VBITRATE=2000000;
+elif [ $HEIGHT -le 720 ]; then VBITRATE=3000000;
+fi
# based on http://www.webmproject.org/docs/encoder-parameters/#real-time-cbr-encoding-and-streaming
# + Add 1s latency (deadline)
diff --git a/bin/loop+encode+stream b/bin/loop+encode+stream
index 8d28767..cc21629 100755
--- a/bin/loop+encode+stream
+++ b/bin/loop+encode+stream
@@ -19,7 +19,17 @@ ACHANNELS=2
AFRAMERATE=48000
ABITRATE=32000
-VBITRATE=256000
+# TODO
+HEIGHT=360
+
+# inspired by Apple HLS recommendations
+ if [ $HEIGHT -le 234 ]; then VBITRATE=145000;
+elif [ $HEIGHT -le 270 ]; then VBITRATE=365000;
+elif [ $HEIGHT -le 360 ]; then VBITRATE=730000;
+elif [ $HEIGHT -le 432 ]; then VBITRATE=1100000;
+elif [ $HEIGHT -le 540 ]; then VBITRATE=2000000;
+elif [ $HEIGHT -le 720 ]; then VBITRATE=3000000;
+fi
# based on http://www.webmproject.org/docs/encoder-parameters/#real-time-cbr-encoding-and-streaming
# + Add 1s latency (deadline)
diff --git a/bin/stream b/bin/stream
index 4c684eb..8a9c4e3 100755
--- a/bin/stream
+++ b/bin/stream
@@ -81,9 +81,18 @@ AFRAMERATE=24000
ABITRATE=16000
# FIXME: support multiple heights
-HEIGHTS_WEBM=234
-HEIGHTS_MPEG=234
-VBITRATE=145000
+HEIGHT=234
+HEIGHTS_WEBM="$HEIGHT"
+HEIGHTS_MPEG="$HEIGHT"
+
+# inspired by Apple HLS recommendations
+ if [ $HEIGHT -le 234 ]; then VBITRATE=145000;
+elif [ $HEIGHT -le 270 ]; then VBITRATE=365000;
+elif [ $HEIGHT -le 360 ]; then VBITRATE=730000;
+elif [ $HEIGHT -le 432 ]; then VBITRATE=1100000;
+elif [ $HEIGHT -le 540 ]; then VBITRATE=2000000;
+elif [ $HEIGHT -le 720 ]; then VBITRATE=3000000;
+fi
# shellcheck disable=SC2048,SC2059
echo_n() {