summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2017-05-16 14:11:52 +0200
committerJonas Smedegaard <dr@jones.dk>2017-05-16 14:12:24 +0200
commit5919275dde112187c5aeedeb7b4a76de8a7eb3dd (patch)
treeff0ab343c2ea65adfd5bb585ae2d6f09e6349e49
parent3fe329a251c3b2dae13d3cc9663da231f5f49db4 (diff)
Introduce variables SPEED_VPX SPEED_H264.
-rwxr-xr-xbin/capture+encode+serve7
-rwxr-xr-xbin/decode+edit+encode4
-rwxr-xr-xbin/decode+edit+loop+encode+stream4
-rwxr-xr-xbin/encodevideo+loop+stream4
-rwxr-xr-xbin/loop+encode+stream4
-rwxr-xr-xbin/stream7
6 files changed, 22 insertions, 8 deletions
diff --git a/bin/capture+encode+serve b/bin/capture+encode+serve
index 83af18c..e87310f 100755
--- a/bin/capture+encode+serve
+++ b/bin/capture+encode+serve
@@ -47,6 +47,9 @@ my $HEIGHT = 240;
my $FRAMERATE = 25;
my $AUDIORATE = 48000;
+my $SPEED_VPX = 15;
+my $SPEED_X264 = 'ultrafast';
+
my $VBITRATE;
# inspired by Apple HLS recommendations
@@ -75,7 +78,7 @@ my %PIPELINE = (
# * let x264 use low-latency sliced-threads (i.e. don't disable treads)
VENC => [
- "x264enc speed-preset=ultrafast tune=zerolatency bitrate=800 byte-stream=true key-int-max=15 intra-refresh=true option-string=\"slice-max-size=8192:vbv-maxrate=80:vbv-bufsize=10\"",
+ "x264enc speed-preset=$SPEED_H264 tune=zerolatency bitrate=800 byte-stream=true key-int-max=15 intra-refresh=true option-string=\"slice-max-size=8192:vbv-maxrate=80:vbv-bufsize=10\"",
'video/x-h264,profile=baseline',
$QUEUE,
'rtph264pay',
@@ -86,7 +89,7 @@ my %PIPELINE = (
},
VP8 => {
VENC => [
- "vp8enc threads=4 cpu-used=15 deadline=1000000 end-usage=1 target-bitrate=$VBITRATE undershoot=95 keyframe-max-dist=999999 max-quantizer=56 deadline=5000 static-threshold=500",
+ "vp8enc threads=4 cpu-used=$SPEED_VPX deadline=1000000 end-usage=1 target-bitrate=$VBITRATE undershoot=95 keyframe-max-dist=999999 max-quantizer=56 deadline=5000 static-threshold=500",
'video/x-vp8',
$QUEUE,
'rtpvp8pay',
diff --git a/bin/decode+edit+encode b/bin/decode+edit+encode
index 421dc4d..1983b54 100755
--- a/bin/decode+edit+encode
+++ b/bin/decode+edit+encode
@@ -10,6 +10,8 @@ OUTPUT=../tmp/omni/show0/earth.webm
HEIGHT=360
+SPEED_VPX=4
+
# inspired by Apple HLS recommendations
if [ $HEIGHT -le 234 ]; then VBITRATE=145000;
elif [ $HEIGHT -le 270 ]; then VBITRATE=365000;
@@ -32,7 +34,7 @@ ffmpeg -hide_banner -threads auto -y -re \
[bg][1:v]overlay=main_w-overlay_w-20:main_h-overlay_h-20[v]" \
-map '[v]' \
-pix_fmt yuv420p \
- -codec:v vp8 -quality realtime -deadline 1000000 -cpu-used 4 \
+ -codec:v vp8 -quality realtime -deadline 1000000 -cpu-used "$SPEED_VPX" \
-b:v "$VBITRATE" -minrate "$VBITRATE" -maxrate "$VBITRATE" \
-undershoot-pct 95 -bufsize $((6000*VBITRATE/1000)) -rc_init_occupancy $((4000*VBITRATE/1000)) \
-max-intra-rate 0 \
diff --git a/bin/decode+edit+loop+encode+stream b/bin/decode+edit+loop+encode+stream
index e150957..5dbe82d 100755
--- a/bin/decode+edit+loop+encode+stream
+++ b/bin/decode+edit+loop+encode+stream
@@ -21,6 +21,8 @@ ITERATIONS=${3-0} # endless by default
HEIGHT=360
+SPEED_VPX=15
+
# inspired by Apple HLS recommendations
if [ $HEIGHT -le 234 ]; then VBITRATE=145000;
elif [ $HEIGHT -le 270 ]; then VBITRATE=365000;
@@ -43,7 +45,7 @@ ffmpeg -hide_banner -threads auto -re \
[bg][1:v]overlay=main_w-overlay_w-20:main_h-overlay_h-20[v]" \
-map '[v]' \
-pix_fmt yuv420p \
- -codec:v vp8 -quality realtime -deadline 1000000 -cpu-used 15 \
+ -codec:v vp8 -quality realtime -deadline 1000000 -cpu-used "$SPEED_VPX" \
-b:v "$VBITRATE" -minrate "$VBITRATE" -maxrate "$VBITRATE" \
-undershoot-pct 95 -bufsize $((6000*VBITRATE/1000)) -rc_init_occupancy $((4000*VBITRATE/1000)) \
-max-intra-rate 0 \
diff --git a/bin/encodevideo+loop+stream b/bin/encodevideo+loop+stream
index fb2b3b7..94ea765 100755
--- a/bin/encodevideo+loop+stream
+++ b/bin/encodevideo+loop+stream
@@ -16,6 +16,8 @@ FIRSTPORT=${2:-5002} # even number - next 3 ports used too
# TODO: resolve this or resize based on it
HEIGHT=360
+SPEED_VPX=15
+
# inspired by Apple HLS recommendations
if [ $HEIGHT -le 234 ]; then VBITRATE=145000;
elif [ $HEIGHT -le 270 ]; then VBITRATE=365000;
@@ -32,7 +34,7 @@ ffmpeg -hide_banner -threads auto -re \
-stream_loop -1 -i "$INPUT" \
-map '0:v' \
-pix_fmt yuv420p \
- -codec:v vp8 -quality realtime -deadline 1000000 -cpu-used 15 \
+ -codec:v vp8 -quality realtime -deadline 1000000 -cpu-used "$SPEED_VPX" \
-b:v "$VBITRATE" -minrate "$VBITRATE" -maxrate "$VBITRATE" \
-undershoot-pct 95 -bufsize $((6000*VBITRATE/1000)) -rc_init_occupancy $((4000*VBITRATE/1000)) \
-max-intra-rate 0 \
diff --git a/bin/loop+encode+stream b/bin/loop+encode+stream
index b767dca..3e5e7d7 100755
--- a/bin/loop+encode+stream
+++ b/bin/loop+encode+stream
@@ -22,6 +22,8 @@ ABITRATE_OPUS=32000
# TODO
HEIGHT=360
+SPEED_VPX=15
+
# inspired by Apple HLS recommendations
if [ $HEIGHT -le 234 ]; then VBITRATE=145000;
elif [ $HEIGHT -le 270 ]; then VBITRATE=365000;
@@ -41,7 +43,7 @@ ffmpeg -hide_banner -threads auto -re \
-f rtp -payload_type 111 "rtp://$IP:$FIRSTPORT?pkt_size=1200" \
-map '0:v' \
-pix_fmt yuv420p \
- -codec:v vp8 -quality realtime -deadline 1000000 -cpu-used 15 \
+ -codec:v vp8 -quality realtime -deadline 1000000 -cpu-used "$SPEED_VPX" \
-b:v "$VBITRATE" -minrate "$VBITRATE" -maxrate "$VBITRATE" \
-undershoot-pct 95 -bufsize $((6000*VBITRATE/1000)) -rc_init_occupancy $((4000*VBITRATE/1000)) \
-max-intra-rate 0 \
diff --git a/bin/stream b/bin/stream
index 846ebde..d044b24 100755
--- a/bin/stream
+++ b/bin/stream
@@ -88,6 +88,9 @@ HEIGHT=234
HEIGHTS_WEBM="$HEIGHT"
HEIGHTS_MPEG="$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;
@@ -176,7 +179,7 @@ ffmpeg -hide_banner -threads auto \
-codec:a libopus -ac "$ACHANNELS" -ar "$AFRAMERATE_OPUS" -b:a "$ABITRATE_OPUS" } \
${HASVIDEO:+\
-pix_fmt yuv420p \
- -codec:v vp8 -quality realtime -deadline 1000000 -cpu-used 15 \
+ -codec:v vp8 -quality realtime -deadline 1000000 -cpu-used "$SPEED_VPX" \
-b:v "$VBITRATE" -minrate "$VBITRATE" -maxrate "$VBITRATE" \
-undershoot-pct 95 -bufsize $((6000*VBITRATE/1000)) -rc_init_occupancy $((4000*VBITRATE/1000)) \
-max-intra-rate 0 \
@@ -192,7 +195,7 @@ ffmpeg -hide_banner -threads auto \
-codec:a aac -strict experimental -ac "$ACHANNELS" -ar "$AFRAMERATE_AAC" -b:a $((ACHANNELS*ABITRATE_AAC)) } \
${HASVIDEO:+\
-pix_fmt yuv420p \
- -codec:v libx264 -tune zerolatency -preset ultrafast \
+ -codec:v libx264 -tune zerolatency -preset "$SPEED_X264" \
-maxrate "$VBITRATE" -bufsize "$((VBITRATE*2))" -crf 23 } \
-force_key_frames 'expr:gte(t,n_forced*2)' \
-f rtp_mpegts rtp://$IP:10000 }