summaryrefslogtreecommitdiff
path: root/bin/decode+edit+loop+encode+stream
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2017-05-18 09:39:53 +0200
committerJonas Smedegaard <dr@jones.dk>2017-05-18 09:39:53 +0200
commitcdbf4dee39cdd3dc083299d88d619effc1e72e14 (patch)
tree9b075856b46cdb4a764791c3d9e2afaa0fdc704b /bin/decode+edit+loop+encode+stream
parent39bc48eb0e8b9a2b8d43d6f1a612c12d0c70ae23 (diff)
Generalize encodings as functions.
Diffstat (limited to 'bin/decode+edit+loop+encode+stream')
-rwxr-xr-xbin/decode+edit+loop+encode+stream14
1 files changed, 9 insertions, 5 deletions
diff --git a/bin/decode+edit+loop+encode+stream b/bin/decode+edit+loop+encode+stream
index 6e65697..8dba934 100755
--- a/bin/decode+edit+loop+encode+stream
+++ b/bin/decode+edit+loop+encode+stream
@@ -54,6 +54,14 @@ elif [ $BITS -le 921600 ]; then # 720p → 921600
SPEED_VP8=15
fi
+encode_vp8() { bitrate=$1; speed=$2;
+ echo_n "-codec:v vp8 -quality realtime -deadline 1000000 -cpu-used $speed \
+ -b:v $bitrate -minrate $bitrate -maxrate $bitrate \
+ -undershoot-pct 95 -bufsize $((6000*bitrate/1000)) -rc_init_occupancy $((4000*bitrate/1000)) \
+ -max-intra-rate 0 \
+ -qmin 4 -qmax 56"
+}
+
# 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
# + scale+watermark trick based on http://stackoverflow.com/a/10937357
@@ -67,9 +75,5 @@ ffmpeg -hide_banner -threads auto -re \
"[0:v]format=pix_fmts=yuv420p,scale=iw*sar*$HEIGHT/ih:$HEIGHT,setsar=1[bg];
[bg][1:v]overlay=main_w-overlay_w-20:main_h-overlay_h-20[v]" \
-map '[v]' \
- -codec:v vp8 -quality realtime -deadline 1000000 -cpu-used "$SPEED_VP8" \
- -b:v "$VBITRATE" -minrate "$VBITRATE" -maxrate "$VBITRATE" \
- -undershoot-pct 95 -bufsize $((6000*VBITRATE/1000)) -rc_init_occupancy $((4000*VBITRATE/1000)) \
- -max-intra-rate 0 \
- -qmin 4 -qmax 56 \
+ $(encode_vp8 "$VBITRATE" "$SPEED_VP8") \
-f rtp -payload_type 100 "rtp://$IP:$((FIRSTPORT+2))?pkt_size=1200"