diff options
author | Jonas Smedegaard <dr@jones.dk> | 2017-05-22 13:51:33 +0200 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2017-05-22 13:51:33 +0200 |
commit | 7c9db99d91a30cf3be973fe02a0c77173960dd51 (patch) | |
tree | 9a12f42ef72278c32916e274c4043b82e00f8239 /bin/stream | |
parent | c4bb1cbe780f0b797a3ca2b39c124f85f4ef4551 (diff) |
Generalize function mux_webm().
Diffstat (limited to 'bin/stream')
-rwxr-xr-x | bin/stream | 29 |
1 files changed, 24 insertions, 5 deletions
@@ -102,7 +102,7 @@ fi [ -z "$XINPUT" ] || [ $XINPUT -eq 1 ] || exit1 "Too many arguments: Max. 1 multimedia source" [ -n "${NOAUDIO:-}" ] || [ -z "$AINPUT$XINPUT" ] || HASAUDIO=1 [ -n "${NOVIDEO:-}" ] || [ -z "$VINPUT$XINPUT" ] || HASVIDEO=1 -[ -z "${HASAUDIO:-}" ] || [ -z "${HASVIDEO:-}" ] || HASMULTIMEDIA=1 +TARGETS_WEBM="${HASAUDIO:+rtp_video} ${HASVIDEO:+rtp_audio}" VSTREAMINDEX=1 [ -n "$AINPUT" ] || VSTREAMINDEX=0 @@ -242,6 +242,28 @@ tee_rtp() { stream=$1; pt=$2; port=$3; echo_n "[select=\'$stream\':f=rtp:payload_type=$pt]rtp://$IP:$port?pkt_size=1440" } +mux_webm() { + muxcount=$(echo "$TARGETS_WEBM" | wc --words) + if [ $muxcount -lt 2 ]; then + case "$TARGETS_WEBM" in + rtp_audio) echo_n "-f rtp -payload_type 111 rtp://$IP:$FIRSTPORT?pkt_size=1440";; + rtp_video) echo_n "-f rtp -payload_type 100 rtp://$IP:$((FIRSTPORT+2))?pkt_size=1440";; + *) exit1 "Unsupported muxing $TARGETS_WEBM";; + esac + else + echo_n "-f tee " + for muxing in $TARGETS_WEBM; do + case "$muxing" in + rtp_audio) echo_n "[select=\'a\':f=rtp:payload_type=111]rtp://$IP:$FIRSTPORT?pkt_size=1440";; + rtp_video) echo_n "[select=\'v\':f=rtp:payload_type=100]rtp://$IP:$((FIRSTPORT+2))?pkt_size=1440";; + *) exit1 "Unsupported muxing $muxing";; + esac + muxcount=$((muxcount-1)) + [ $muxcount -lt 1 ] || echo_n '|' + done + fi +} + ffmpeg -hide_banner -threads auto \ ${ALSA:+-f alsa -sample_rate "$AFRAMERATE_SRC" -channels "$ACHANNELS" -thread_queue_size 2048 -i "$ALSA"} \ ${DVCAM:+-f iec61883 -thread_queue_size 64 -i $DVCAM} \ @@ -263,10 +285,7 @@ ffmpeg -hide_banner -threads auto \ $(encode_opus) } \ ${HASVIDEO:+\ $(encode_vp8 "$VBITRATE" "$SPEED_VP8") } \ - -f tee \ - "${HASAUDIO:+$(tee_rtp a 111 "$FIRSTPORT")} - ${HASMULTIMEDIA:+|} - ${HASVIDEO:+$(tee_rtp v 100 $((FIRSTPORT+2)))}" } \ + $(mux_webm) } \ ${ENCODINGS_MPEG:+\ ${HASAUDIO:+-map '0:a' }${HASVIDEO:+$(printf_each ' -map [v%smpeg]' "$ENCODINGS_MPEG") } -shortest \ ${HASAUDIO:+\ |