From b450c785f35dc0dd66990b3a75aa5e96b62d0a88 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Thu, 11 May 2017 11:48:26 +0200 Subject: Process audio before video. --- bin/send-gst-rtp-v-a | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) (limited to 'bin/send-gst-rtp-v-a') diff --git a/bin/send-gst-rtp-v-a b/bin/send-gst-rtp-v-a index f8b548b..aaadd38 100755 --- a/bin/send-gst-rtp-v-a +++ b/bin/send-gst-rtp-v-a @@ -18,49 +18,50 @@ set -u RECHOST="${RECIP:+host=$RECIP}${RECMIP:+host=$RECMIP auto-multicast=true}" CAMHOST="${CAMMIP:+address=$CAMMIP auto-multicast=true}" -HEIGHT=240 -FRAMERATE=25 AUDIORATE=48000 -VCAPS=video/x-raw,height="$HEIGHT" -ACAPS=audio/x-raw,rate="$AUDIORATE",channels=2,depth=16 - # * http://stackoverflow.com/a/42237307 ABUFFERS=20000 +HEIGHT=240 +FRAMERATE=25 + +ACAPS=audio/x-raw,rate="$AUDIORATE",channels=2,depth=16 +VCAPS=video/x-raw,height="$HEIGHT" + # * force threads using queues - see http://stackoverflow.com/a/30738533 # * generous queue sizes inspired by https://wiki.xiph.org/GST_cookbook QUEUE=" queue max-size-bytes=100000000 max-size-time=0" -case "$VFORMAT" in - H264) - # * let x264 use low-latency sliced-threads (i.e. don't disable treads) - VENC="x264enc speed-preset=ultrafast tune=zerolatency bitrate=800 byte-stream=true key-int-max=15 intra-refresh=true option-string=\"slice-max-size=8192:vbv-maxrate=80:vbv-bufsize=10\" ! video/x-h264,profile=baseline ! $QUEUE ! rtph264pay" +case "$AFORMAT" in + AMR) + AENC="amrnbenc ! $QUEUE ! rtpamrpay" ;; - VP8) - VENC="vp8enc cpu-used=10 threads=2 deadline=10000 ! video/x-vp8 ! $QUEUE ! rtpvp8pay" + OPUS) + AENC="opusenc ! $QUEUE ! rtpopuspay" ;; RAW|'') - VENC="rtpvrawpay" + AENC="rtpL16pay" ;; *) - echo "ERROR: Unsupported video format: \"$VFORMAT\"" + echo "ERROR: Unsupported audio format: \"$AFORMAT\"" exit 1 ;; esac -case "$AFORMAT" in - AMR) - AENC="amrnbenc ! $QUEUE ! rtpamrpay" +case "$VFORMAT" in + H264) + # * let x264 use low-latency sliced-threads (i.e. don't disable treads) + VENC="x264enc speed-preset=ultrafast tune=zerolatency bitrate=800 byte-stream=true key-int-max=15 intra-refresh=true option-string=\"slice-max-size=8192:vbv-maxrate=80:vbv-bufsize=10\" ! video/x-h264,profile=baseline ! $QUEUE ! rtph264pay" ;; - OPUS) - AENC="opusenc ! $QUEUE ! rtpopuspay" + VP8) + VENC="vp8enc cpu-used=10 threads=2 deadline=10000 ! video/x-vp8 ! $QUEUE ! rtpvp8pay" ;; RAW|'') - AENC="rtpL16pay" + VENC="rtpvrawpay" ;; *) - echo "ERROR: Unsupported audio format: \"$AFORMAT\"" + echo "ERROR: Unsupported video format: \"$VFORMAT\"" exit 1 ;; esac @@ -82,8 +83,8 @@ stream() { gst-launch-1.0 -v \ rtpbin name=rtpbin \ $(n=0;\ - for dev in $VDEVICES; do n=$((n+1)); stream "$n" "v4l2src device=$dev ! $QUEUE ! videoconvert ! $VCAPS ! $QUEUE ! $VENC ! $QUEUE"; done;\ for dev in $ADEVICES; do n=$((n+1)); stream "$n" "alsasrc device=$dev buffer-time=$ABUFFERS ! $QUEUE ! audioconvert ! $QUEUE ! $AENC ! $QUEUE"; done;\ + for dev in $VDEVICES; do n=$((n+1)); stream "$n" "v4l2src device=$dev ! $QUEUE ! videoconvert ! $VCAPS ! $QUEUE ! $VENC ! $QUEUE"; done;\ ) set -e -- cgit v1.2.3