aboutsummaryrefslogtreecommitdiffstats
path: root/encode-gst.sh
blob: 255b4be8bc13865f74a8989c263fcf06be8cc3b5 (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
45
46
47
48
#!/bin/bash
#
# Encode one programme using gstreamer.
#
# Status: Experimental

URL=$1
ID=$2
DST=$3

QUEUEDELAY=400000 #400ms

BITRATE=80
RATE=32000

if [[ "$DST" == "" ]]
then
    echo "Usage $0 url id destination"
    exit 1
fi

while true
do

    gst-launch -q \
            uridecodebin uri=$URL ! \
            queue "max-size-time=$QUEUEDELAY" ! \
            audioresample quality=8 ! \
            audioconvert ! \
            audio/x-raw-int, "rate=$RATE,format=S16LE,channels=2" ! \
            filesink location="/dev/stdout" | \
        dabplus-enc -i /dev/stdin -b $BITRATE -r $RATE -f raw -a -o $DST

    R=$?

    NOW=$(date)

    mail -s "Encoder $ID restart $URL" matthias+odrge1@mpb.li << EOF
The encoder id:$ID
encoding $URL -> $DST with gstreamer was restarted at
$NOW

The return code was $R

EOF

    sleep 5
done