summaryrefslogtreecommitdiff
path: root/bin/stream
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2017-05-06 21:57:56 +0200
committerJonas Smedegaard <dr@jones.dk>2017-05-06 22:14:03 +0200
commitebbb355e6b74af1fad5cec8397abea2764b8ba57 (patch)
tree1aaba3459db5cf66bec1628c2f20bc3c16e85b9c /bin/stream
parentd3e6dec404ac9137351e7a42db7c00fd7458213e (diff)
Generalize function tee_rtp().
Diffstat (limited to 'bin/stream')
-rwxr-xr-xbin/stream12
1 files changed, 8 insertions, 4 deletions
diff --git a/bin/stream b/bin/stream
index a0a2fae..f3fa019 100755
--- a/bin/stream
+++ b/bin/stream
@@ -103,6 +103,10 @@ printf_each() {
done
}
+# shellcheck disable=SC2059
+tee_rtp() { stream=$1; pt=$2; port=$3;
+ printf "[select=\'$stream\':f=rtp:payload_type=$pt]rtp://$IP:$port?pkt_size=1200"; }
+
# * scale+watermark trick based on http://stackoverflow.com/a/10937357
# * routing based on http://trac.ffmpeg.org/wiki/Creating%20multiple%20outputs#Teepseudo-muxer
# * VP8 encoding based on http://www.webmproject.org/docs/encoder-parameters/#real-time-cbr-encoding-and-streaming
@@ -138,9 +142,9 @@ ffmpeg -hide_banner -threads auto -re \
-qmin 4 -qmax 56 } \
-f tee \
"${HASAUDIO:+\
- [select=\'a\':f=rtp:payload_type=111]rtp://$IP:$FIRSTPORT?pkt_size=1200| \
+ $(tee_rtp a 111 "$FIRSTPORT")|\
}${HASVIDEO:+\
- [select=\'v\':f=rtp:payload_type=100]rtp://$IP:$((FIRSTPORT+2))?pkt_size=1200}" } \
+ $(tee_rtp v 100 $((FIRSTPORT+2)))}" } \
${HEIGHTS_MPEG:+\
${HASAUDIO:+-map '0:a' }${HASVIDEO:+$(printf_each ' -map [v%smpeg]' "$HEIGHTS_MPEG") } \
${HASAUDIO:+\
@@ -151,6 +155,6 @@ ffmpeg -hide_banner -threads auto -re \
-maxrate "$VBITRATE" -bufsize "$((VBITRATE*2))" -crf 23 } \
-f tee \
"${HASAUDIO:+\
- [select=\'a\':f=rtp:payload_type=96]rtp://$IP:$((FIRSTPORT+4))?pkt_size=1200| \
+ $(tee_rtp a 96 $((FIRSTPORT+4)))|\
}${HASVIDEO:+\
- [select=\'v\':f=rtp:payload_type=97]rtp://$IP:$((FIRSTPORT+6))?pkt_size=1200}" }
+ $(tee_rtp v 97 $((FIRSTPORT+6)))}" }