summaryrefslogtreecommitdiff
path: root/bin/loop+encode+stream
diff options
context:
space:
mode:
Diffstat (limited to 'bin/loop+encode+stream')
-rwxr-xr-xbin/loop+encode+stream19
1 files changed, 13 insertions, 6 deletions
diff --git a/bin/loop+encode+stream b/bin/loop+encode+stream
index 3906552..5893ed3 100755
--- a/bin/loop+encode+stream
+++ b/bin/loop+encode+stream
@@ -55,6 +55,17 @@ elif [ $BITS -le 921600 ]; then # 720p → 921600
SPEED_VP8=15
fi
+encode_opus() {
+ echo_n "-codec:a libopus -ac $ACHANNELS -ar $AFRAMERATE_OPUS -b:a $ABITRATE_OPUS"
+}
+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
# + Add 1s latency (deadline)
# + Use same RTP payload types as GStreamer
@@ -62,12 +73,8 @@ ffmpeg -hide_banner -threads auto -re \
-stream_loop -1 -i "$INPUT" \
-vf format=pix_fmts=yuv420p \
-map '0:a' \
- -codec:a libopus -ac "$ACHANNELS" -ar "$AFRAMERATE_OPUS" -b:a "$ABITRATE_OPUS" \
+ $(encode_opus) \
-f rtp -payload_type 111 "rtp://$IP:$FIRSTPORT?pkt_size=1200" \
-map '0: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"