summaryrefslogtreecommitdiff
path: root/bin/stream
diff options
context:
space:
mode:
Diffstat (limited to 'bin/stream')
-rwxr-xr-xbin/stream32
1 files changed, 22 insertions, 10 deletions
diff --git a/bin/stream b/bin/stream
index ce90206..6e3ecdb 100755
--- a/bin/stream
+++ b/bin/stream
@@ -178,6 +178,24 @@ filter_split_codec() { heights_webm=$1; heights_mpeg=$2;
printf_each "[v%s]split=$codeccount$(printf_each '[v%swebm]' "$heights_webm")$(printf_each '[v%smpeg]' "$heights_mpeg")" "$HEIGHTS"
}
+encode_opus() {
+ echo_n "-codec:a libopus -ac $ACHANNELS -ar $AFRAMERATE_OPUS -b:a $ABITRATE_OPUS"
+}
+encode_aac() {
+ echo_n "-codec:a aac -strict experimental -ac $ACHANNELS -ar $AFRAMERATE_AAC -b:a $((ACHANNELS*ABITRATE_AAC))"
+}
+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"
+}
+encode_x264() { bitrate=$1; speed=$2;
+ echo_n "-codec:v libx264 -preset $speed -tune zerolatency \
+ -maxrate $bitrate -bufsize $((bitrate*2)) -crf 23 \
+ -force_key_frames 'expr:gte(t,n_forced*2)'"
+}
tee_rtp() { stream=$1; pt=$2; port=$3;
echo_n "[select=\'$stream\':f=rtp:payload_type=$pt]rtp://$IP:$port?pkt_size=1200"
}
@@ -207,13 +225,9 @@ ffmpeg -hide_banner -threads auto \
${HEIGHTS_WEBM:+\
${HASAUDIO:+-map '0:a' }${HASVIDEO:+$(printf_each ' -map [v%swebm]' "$HEIGHTS_WEBM") } -shortest \
${HASAUDIO:+\
- -codec:a libopus -ac "$ACHANNELS" -ar "$AFRAMERATE_OPUS" -b:a "$ABITRATE_OPUS" } \
+ $(encode_opus) } \
${HASVIDEO:+\
- -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 tee \
"${HASAUDIO:+\
$(tee_rtp a 111 "$FIRSTPORT")|\
@@ -222,9 +236,7 @@ ffmpeg -hide_banner -threads auto \
${HEIGHTS_MPEG:+\
${HASAUDIO:+-map '0:a' }${HASVIDEO:+$(printf_each ' -map [v%smpeg]' "$HEIGHTS_MPEG") } -shortest \
${HASAUDIO:+\
- -codec:a aac -strict experimental -ac "$ACHANNELS" -ar "$AFRAMERATE_AAC" -b:a $((ACHANNELS*ABITRATE_AAC)) } \
+ $(encode_aac) } \
${HASVIDEO:+\
- -codec:v libx264 -preset "$SPEED_X264" -tune zerolatency \
- -maxrate "$VBITRATE" -bufsize "$((VBITRATE*2))" -crf 23 } \
- -force_key_frames 'expr:gte(t,n_forced*2)' \
+ $(encode_x264 "$VBITRATE" "$SPEED_X264") } \
-f rtp_mpegts rtp://$IP:10000 }