summaryrefslogtreecommitdiff
path: root/bin/capture+encode+serve
diff options
context:
space:
mode:
Diffstat (limited to 'bin/capture+encode+serve')
-rwxr-xr-xbin/capture+encode+serve46
1 files changed, 36 insertions, 10 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";