From 9c843caf241752d9e389b08b2d447ba6df81b438 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Wed, 8 Mar 2017 23:58:30 +0100 Subject: Limit network latency. --- bin/recv-gst-rtp-v-a | 8 ++++++-- bin/send-gst-rtp-v-a | 5 ++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/bin/recv-gst-rtp-v-a b/bin/recv-gst-rtp-v-a index 17cd16e..daffd25 100755 --- a/bin/recv-gst-rtp-v-a +++ b/bin/recv-gst-rtp-v-a @@ -18,6 +18,10 @@ set -u RECHOST="${RECMIP:+address=$RECMIP auto-multicast=true}" CAMHOST="${CAMIP:+host=$CAMIP}${CAMMIP:+host=$CAMMIP auto-multicast=true}" +# http://stackoverflow.com/a/42237307 +ABUFFERS=80000 +NETLATENCY=20 + case "$VFORMAT" in H264) VCAPS=application/x-rtp,media=video,clock-rate=90000,payload=96,encoding-name=H264 @@ -63,6 +67,6 @@ stream() { } gst-launch-1.0 -v \ - rtpbin name=rtpbin \ + rtpbin name=rtpbin latency=$NETLATENCY drop-on-latency=true \ $(for i in $(seq "${VCOUNT:-1}"); do stream "$i" "$VCAPS" "$VDEC ! $VSINK"; done) \ - $(for j in $(seq "${ACOUNT:-0}"); do stream $((VCOUNT+j)) "$ACAPS" "$ADEC ! $ASINK"; done) + $(for j in $(seq "${ACOUNT:-0}"); do stream $((VCOUNT+j)) "$ACAPS" "$ADEC ! $ASINK buffer-time=$ABUFFERS"; done) diff --git a/bin/send-gst-rtp-v-a b/bin/send-gst-rtp-v-a index cd7b4c4..cc30c0e 100755 --- a/bin/send-gst-rtp-v-a +++ b/bin/send-gst-rtp-v-a @@ -25,6 +25,9 @@ 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 + # * 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" @@ -72,6 +75,6 @@ n=0 gst-launch-1.0 -v \ rtpbin name=rtpbin \ $(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 ! $QUEUE ! audioconvert ! $QUEUE ! $AENC ! $QUEUE"; done) + for dev in $ADEVICES; do n=$((n+1)); stream "$n" "alsasrc device=$dev buffer-time=$ABUFFERS ! $QUEUE ! audioconvert ! $QUEUE ! $AENC ! $QUEUE"; done) set -e -- cgit v1.2.3