aboutsummaryrefslogtreecommitdiffstats
path: root/encode-libvlc.sh
diff options
context:
space:
mode:
Diffstat (limited to 'encode-libvlc.sh')
-rwxr-xr-xencode-libvlc.sh116
1 files changed, 0 insertions, 116 deletions
diff --git a/encode-libvlc.sh b/encode-libvlc.sh
deleted file mode 100755
index 361a743..0000000
--- a/encode-libvlc.sh
+++ /dev/null
@@ -1,116 +0,0 @@
-#!/bin/bash
-#
-# Encode programme using libVLC input from
-# dabplus-enc or toolame
-#
-# monitor processes, and restart if necessary
-# Optionally send an email when restart happens
-
-printerr() {
- echo -e "\033[01;31m$1\033[0m"
- logger -p local0.error -t "$ID" "$1"
-}
-
-printmsg() {
- echo -e "\033[01;32m$1\033[0m"
- logger -p local0.notice -t "$ID" "$1"
-}
-
-set -u
-
-# check number of arguments
-if [[ "$#" -lt 3 ]] ; then
- echo "Usage $0 url id destination [encoder]"
- echo "Encoder shall be 'dabplus-enc' or 'toolame'"
- exit 1
-fi
-
-URL=$1
-ID=$2
-DST=$3
-
-if [[ "$#" -gt 3 ]] ; then
- ENC=$4
-else
- ENC="dabplus-enc"
-fi
-
-if [[ "$#" -gt 4 ]]; then
- shift 4
- OPTIONS=$@
-else
- if [[ "$ENC" == "dabplus-enc" ]]; then
- OPTIONS="-b 80 -r 32000"
- else
- OPTIONS="-b 128 -s 48 -L"
- fi
-fi
-
-running=1
-
-encoderpid=0
-
-# The trap for Ctrl-C
-sigint_trap() {
- printerr "Got Ctrl-C, killing mplayer and encoder"
- running=0
-
- if [[ "$encoderpid" != "0" ]] ; then
- kill -TERM $encoderpid
- sleep 2
- kill -KILL $encoderpid
- fi
-
- printmsg "quitting"
- exit
-}
-
-trap sigint_trap SIGTERM
-trap sigint_trap SIGINT
-
-while [[ "$running" == "1" ]]
-do
-
- printmsg "Launching encoder"
- if [[ "$ENC" == "dabplus-enc" ]] ; then
- dabplus-enc -v "$URL" $OPTIONS -o "$DST" -l &
- encoderpid=$!
- elif [[ "$ENC" == "toolame" ]] ; then
- toolame $OPTIONS -V "$URL" "$DST" &
- encoderpid=$!
- fi
- printerr "Detected crash of encoder!"
-
- sleep 5
-
- checkloop=1
- while [[ "$checkloop" == "1" ]]
- do
- sleep 2
-
- kill -s 0 $encoderpid
- if [[ "$?" != "0" ]] ; then
- printerr "the encoder died"
-
- encoderpid=0
- checkloop=0
- fi
- done
-
- MAILTO=$(cat site/mail-warning.txt)
-
- if [[ "$MAILTO" != "" ]] ; then
- NOW=$(date)
-
- mail -s "Encoder $ID restart $URL" "$MAILTO" << EOF
-The encoder id:$ID
-encoding $URL -> $DST using encode-libvlc was restarted at
-$NOW
-
-EOF
-
- fi
- sleep 5
-
-done
-