You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
videostation-ffmpeg-patcher/wrappers/gst-launch-1.0.sh

70 lines
1.1 KiB
Bash

#!/bin/bash
#########################
# VARS
#########################
pid=$$
child=""
stderrfile="/tmp/gstlaunch-$pid.stderr"
errcode=0
#########################
# UTILS
#########################
log() {
local now
now=$(date '+%Y-%m-%d %H:%M:%S')
echo "[$now] [$1] $2" >> $stderrfile
}
newline() {
echo "" >> $stderrfile
}
info() {
log "INFO" "$1"
}
handle_error() {
log "ERROR" "An error occurred"
newline
errcode=1
endprocess
}
endprocess() {
info "========================================[end gst $pid]"
newline
if [[ $errcode -eq 1 ]]; then
cp "$stderrfile" "$stderrfile.prev"
fi
rm "$stderrfile"
if [[ "$child" != "" ]]; then
kill "$child"
fi
exit $errcode
}
#########################
# ENTRYPOINT
#########################
trap endprocess SIGINT SIGTERM
trap handle_error ERR
rm -f /tmp/gstlaunch*.stderr.prev
newline
info "========================================[start gst-launch $pid]"
info "GST_ARGS: $*"
/var/packages/VideoStation/target/bin/gst-launch-1.0.orig "$@" 2>> $stderrfile &
child=$!
wait "$child"
endprocess