From ebbb355e6b74af1fad5cec8397abea2764b8ba57 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Sat, 6 May 2017 21:57:56 +0200 Subject: Generalize function tee_rtp(). --- bin/stream | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'bin/stream') 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)))}" } -- cgit v1.2.3