diff options
Diffstat (limited to 'bin')
-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:+\ |