aboutsummaryrefslogtreecommitdiffstats
path: root/encode-url-gst-dabplus.sh
blob: b05d7bb86366dc90b76bb9d9709c7782492368ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
#
# Read a URL using gstreamer, and encode with fdk-aac-dabplus-enc
#
URL=$1
BITRATE=$2
DST=$3
QUEUEDELAY=400000 #400ms

GSTREAMER_VERSION="1"

if [ "$DST" == "" ]
then
    echo "Usage:"
    echo " $0 <url> <bitrate> <zmq destination>"
    exit 1
fi


if [ "$GSTREAMER_VERSION" == "1" ]
then
    gst-launch-1.0 -q \
        uridecodebin uri=$URL ! \
        queue "max-size-time=$QUEUEDELAY" ! \
        audioresample quality=8 ! \
        audioconvert ! \
        audio/x-raw, 'rate=48000,format=S16LE,channels=2' ! \
        filesink location="/dev/stdout" | \
        dabplus-enc \
            -i /dev/stdin -b $BITRATE -f raw -a -o "${DST}"

elif [ "$GSTREAMER_VERSION" == "0" ]
then
    gst-launch -q \
        uridecodebin uri=$URL ! \
        queue "max-size-time=$QUEUEDELAY" ! \
        audioresample quality=8 ! \
        audioconvert ! \
        audio/x-raw-int, 'rate=48000,format=S16LE,channels=2' ! \
        filesink location="/dev/stdout" | \
        dabplus-enc \
            -i /dev/stdin -b $BITRATE -f raw -a -o "${DST}"
fi