summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2017-05-11 11:48:26 +0200
committerJonas Smedegaard <dr@jones.dk>2017-05-11 11:56:25 +0200
commitb450c785f35dc0dd66990b3a75aa5e96b62d0a88 (patch)
tree367c7d5bde789f9ed6398d73e2f5764b2050e247 /bin
parent61ba220b60087b62410b6709005f8ddfbdd711d6 (diff)
Process audio before video.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/recv-gst-rtp-v-a50
-rwxr-xr-xbin/send-gst-rtp-v-a43
2 files changed, 47 insertions, 46 deletions
diff --git a/bin/recv-gst-rtp-v-a b/bin/recv-gst-rtp-v-a
index 1da2106..dbf21c0 100755
--- a/bin/recv-gst-rtp-v-a
+++ b/bin/recv-gst-rtp-v-a
@@ -4,12 +4,12 @@
set -e
CAMIP=${CAMIP:-$1} # origin host - default: use multicast group
-VCOUNT=${VCOUNT:-${2:-1}} # number of video stream(s) to display - default: 1
-ACOUNT=${ACOUNT:-${3:-0}} # number of audio stream(s) to play - default: 0
-VFORMAT=${VFORMAT:-$4} # H264 VP8 RAW - default: RAW
-AFORMAT=${AFORMAT:-$5} # AMR OPUS RAW - default: RAW
-VSINK=${VSINK:-autovideosink}
+ACOUNT=${ACOUNT:-${2:-0}} # number of audio stream(s) to play - default: 0
+VCOUNT=${VCOUNT:-${3:-1}} # number of video stream(s) to display - default: 1
+AFORMAT=${AFORMAT:-$4} # AMR OPUS RAW - default: RAW
+VFORMAT=${VFORMAT:-$5} # H264 VP8 RAW - default: RAW
ASINK=${ASINK:-autoaudiosink}
+VSINK=${VSINK:-autovideosink}
set -u
# set multicast groups (also for recorder host) if camera host is wildcard
@@ -22,25 +22,6 @@ CAMHOST="${CAMIP:+host=$CAMIP}${CAMMIP:+host=$CAMMIP auto-multicast=true}"
ABUFFERS=80000
NETLATENCY=20
-case "$VFORMAT" in
- H264)
- VCAPS=application/x-rtp,media=video,clock-rate=90000,payload=96,encoding-name=H264
- VDEC="rtph264depay ! avdec_h264"
- ;;
- VP8)
- VCAPS=application/x-rtp,media=video,clock-rate=90000,payload=96,encoding-name=VP8
- VDEC="rtpvp8depay ! vp8dec"
- ;;
- RAW|'')
- VCAPS=application/x-rtp,media=video,clock-rate=90000,encoding-name=RAW,sampling=YCbCr-4:2:0,depth="(string)8",width="(string)432",height="(string)240",payload=96,a-framerate=30
- VDEC="rtpvrawdepay ! videoconvert ! queue"
- ;;
- *)
- echo "ERROR: Unsupported video format: \"$VFORMAT\""
- exit 1
- ;;
-esac
-
case "$AFORMAT" in
AMR)
ACAPS=application/x-rtp,media=audio,clock-rate=8000,encoding-name=AMR,encoding-params="(string)1",octet-align="(string)1",payload=96
@@ -60,6 +41,25 @@ case "$AFORMAT" in
;;
esac
+case "$VFORMAT" in
+ H264)
+ VCAPS=application/x-rtp,media=video,clock-rate=90000,payload=96,encoding-name=H264
+ VDEC="rtph264depay ! avdec_h264"
+ ;;
+ VP8)
+ VCAPS=application/x-rtp,media=video,clock-rate=90000,payload=96,encoding-name=VP8
+ VDEC="rtpvp8depay ! vp8dec"
+ ;;
+ RAW|'')
+ VCAPS=application/x-rtp,media=video,clock-rate=90000,encoding-name=RAW,sampling=YCbCr-4:2:0,depth="(string)8",width="(string)432",height="(string)240",payload=96,a-framerate=30
+ VDEC="rtpvrawdepay ! videoconvert ! queue"
+ ;;
+ *)
+ echo "ERROR: Unsupported video format: \"$VFORMAT\""
+ exit 1
+ ;;
+esac
+
stream() {
ID=$1
CAPS=$2
@@ -77,6 +77,6 @@ stream() {
gst-launch-1.0 -v \
rtpbin name=rtpbin latency=$NETLATENCY drop-on-latency=true \
$(n=0;\
- for i in $(seq "$VCOUNT"); do n=$((n+1)); stream "$n" "$VCAPS" "$VDEC ! $VSINK"; done;\
for i in $(seq "$ACOUNT"); do n=$((n+1)); stream "$n" "$ACAPS" "$ADEC ! $ASINK buffer-time=$ABUFFERS"; done;\
+ for i in $(seq "$VCOUNT"); do n=$((n+1)); stream "$n" "$VCAPS" "$VDEC ! $VSINK"; done;\
)
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