summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/capture+encode+serve46
-rwxr-xr-xbin/decode+edit+encode1
-rwxr-xr-xbin/decode+edit+loop+encode+stream1
-rwxr-xr-xbin/encodevideo+loop+stream1
-rwxr-xr-xbin/loop+encode+stream1
-rwxr-xr-xbin/stream17
6 files changed, 50 insertions, 17 deletions
diff --git a/bin/capture+encode+serve b/bin/capture+encode+serve
index e87310f..29688f1 100755
--- a/bin/capture+encode+serve
+++ b/bin/capture+encode+serve
@@ -47,18 +47,44 @@ my $HEIGHT = 240;
my $FRAMERATE = 25;
my $AUDIORATE = 48000;
-my $SPEED_VPX = 15;
-my $SPEED_X264 = 'ultrafast';
-
-my $VBITRATE;
+# TODO: Vary vpx quality based on height
+my $SPEED_VPX = 15;
# 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 }
+# TODO: Externalize to site-specific configfile
+my ( $VBITRATE, $SPEED_X264, $SPEED_X264_ALONE );
+if ( $HEIGHT le 234 ) {
+ $VBITRATE = 145000;
+ $SPEED_X264 = 'slow';
+ $SPEED_X264_ALONE = 'fast';
+}
+elsif ( $HEIGHT le 270 ) {
+ $VBITRATE = 365000;
+ $SPEED_X264 = 'faster';
+ $SPEED_X264_ALONE = 'fast';
+}
+elsif ( $HEIGHT le 360 ) {
+ $VBITRATE = 730000;
+ $SPEED_X264 = 'faster';
+ $SPEED_X264_ALONE = 'fast';
+}
+elsif ( $HEIGHT le 432 ) {
+ $VBITRATE = 1100000;
+ $SPEED_X264 = 'veryfast';
+ $SPEED_X264_ALONE = 'fast';
+}
+elsif ( $HEIGHT le 540 ) {
+ $VBITRATE = 2000000;
+ $SPEED_X264 = 'toofast';
+ $SPEED_X264_ALONE = 'veryfast';
+}
+elsif ( $HEIGHT le 720 ) {
+ $VBITRATE = 3000000;
+ $SPEED_X264 = 'toofast';
+ $SPEED_X264_ALONE = 'ultrafast';
+}
+unless ($HEIGHTS_WEBM) { $SPEED_X264 = $SPEED_X264_ALONE }
+if ( toofast == $SPEED_X264 ) die "Not enough CPU - reduce size or streams";
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 a0eb208..73f4a68 100755
--- a/bin/decode+edit+encode
+++ b/bin/decode+edit+encode
@@ -10,6 +10,7 @@ OUTPUT=../tmp/omni/show0/earth.webm
HEIGHT=360
+# TODO: Vary vpx quality based on height
SPEED_VPX=4
# inspired by Apple HLS recommendations
diff --git a/bin/decode+edit+loop+encode+stream b/bin/decode+edit+loop+encode+stream
index ba70b02..a620eb1 100755
--- a/bin/decode+edit+loop+encode+stream
+++ b/bin/decode+edit+loop+encode+stream
@@ -21,6 +21,7 @@ ITERATIONS=${3-0} # endless by default
HEIGHT=360
+# TODO: Vary vpx quality based on height
SPEED_VPX=15
# inspired by Apple HLS recommendations
diff --git a/bin/encodevideo+loop+stream b/bin/encodevideo+loop+stream
index 94ea765..a8a5f76 100755
--- a/bin/encodevideo+loop+stream
+++ b/bin/encodevideo+loop+stream
@@ -16,6 +16,7 @@ FIRSTPORT=${2:-5002} # even number - next 3 ports used too
# TODO: resolve this or resize based on it
HEIGHT=360
+# TODO: Vary vpx quality based on height
SPEED_VPX=15
# inspired by Apple HLS recommendations
diff --git a/bin/loop+encode+stream b/bin/loop+encode+stream
index a4c84be..567ca82 100755
--- a/bin/loop+encode+stream
+++ b/bin/loop+encode+stream
@@ -22,6 +22,7 @@ ABITRATE_OPUS=48000
# TODO
HEIGHT=360
+# TODO: Vary vpx quality based on height
SPEED_VPX=15
# inspired by Apple HLS recommendations
diff --git a/bin/stream b/bin/stream
index 71b6713..ac5135f 100755
--- a/bin/stream
+++ b/bin/stream
@@ -88,17 +88,20 @@ HEIGHT=270
HEIGHTS_WEBM="$HEIGHT"
HEIGHTS_MPEG="$HEIGHT"
+# TODO: Vary vpx quality based on height
SPEED_VPX=15
-SPEED_X264=ultrafast
# 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;
+# TODO: Externalize to site-specific configfile
+ if [ $HEIGHT -le 234 ]; then VBITRATE=145000; SPEED_X264=slow; SPEED_X264_ALONE=fast;
+elif [ $HEIGHT -le 270 ]; then VBITRATE=365000; SPEED_X264=faster; SPEED_X264_ALONE=fast;
+elif [ $HEIGHT -le 360 ]; then VBITRATE=730000; SPEED_X264=faster; SPEED_X264_ALONE=fast;
+elif [ $HEIGHT -le 432 ]; then VBITRATE=1100000; SPEED_X264=veryfast; SPEED_X264_ALONE=fast;
+elif [ $HEIGHT -le 540 ]; then VBITRATE=2000000; SPEED_X264=toofast; SPEED_X264_ALONE=veryfast;
+elif [ $HEIGHT -le 720 ]; then VBITRATE=3000000; SPEED_X264=toofast; SPEED_X264_ALONE=ultrafast;
fi
+[ -n "$HEIGHTS_WEBM" ] || SPEED_X264="$SPEED_X264_ALONE"
+[ toofast != "$SPEED_X264" ] || exit1 "Not enough CPU - reduce size or streams"
# shellcheck disable=SC2048,SC2059
echo_n() {