summaryrefslogtreecommitdiff
path: root/bin/capture+encode+serve
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2017-05-17 08:44:33 +0200
committerJonas Smedegaard <dr@jones.dk>2017-05-17 08:44:33 +0200
commit363f4d522d8ef47dd30537371e7d7ebc53730a48 (patch)
tree4f2c5741f0e5ec0e798aead20555c423d732f38d /bin/capture+encode+serve
parent32f01bcedc57b2aef30bbbd37d02ffa77a219a41 (diff)
Vary x264 speed based on height, and make not on doing same for vpx.
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";