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.
62 lines
996 B
Bash
62 lines
996 B
Bash
#!/bin/bash
|
|
|
|
#########################
|
|
# VARS
|
|
#########################
|
|
|
|
pid=$$
|
|
child=""
|
|
stderrfile="/tmp/ffmpeg-$pid.stderr"
|
|
errcode=0
|
|
|
|
#########################
|
|
# UTILS
|
|
#########################
|
|
|
|
function log() {
|
|
echo "[$(date '+%Y-%m-%d %H:%M:%S')] [$1] $2" >> $stderrfile
|
|
}
|
|
function newline() {
|
|
echo "" >> $stderrfile
|
|
}
|
|
function info() {
|
|
log "INFO" "$1"
|
|
}
|
|
|
|
function handle_error() {
|
|
log "ERROR" "An error occurred"
|
|
newline
|
|
errcode=1
|
|
endprocess
|
|
}
|
|
|
|
function endprocess() {
|
|
info "========================================[end ffmpeg $pid]"
|
|
newline
|
|
rm -f "$stderrfile"
|
|
|
|
if [[ "$child" != "" ]]; then
|
|
kill -9 "$child"
|
|
fi
|
|
|
|
exit $errcode
|
|
}
|
|
|
|
#########################
|
|
# ENTRYPOINT
|
|
#########################
|
|
|
|
trap endprocess SIGINT SIGTERM
|
|
trap handle_error ERR
|
|
|
|
newline
|
|
info "========================================[start ffmpeg $pid]"
|
|
info "DEFAULT_ARGS: $*"
|
|
|
|
/var/packages/@ffmpeg_version@/target/bin/ffmpeg "$@" <&0 2> $stderrfile &
|
|
|
|
child=$!
|
|
wait $child
|
|
|
|
endprocess
|