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.
51 lines
869 B
Bash
51 lines
869 B
Bash
#!/bin/bash
|
|
|
|
#########################
|
|
# VARS
|
|
#########################
|
|
|
|
pid=$$
|
|
stderrfile="/tmp/ffmpeg-$pid.stderr"
|
|
logfile="/tmp/ffmpeg.log"
|
|
|
|
#########################
|
|
# UTILS
|
|
#########################
|
|
|
|
function log() {
|
|
echo "[$(date '+%Y-%m-%d %H:%M:%S')] [$1] $2" >> $logfile
|
|
}
|
|
function newline() {
|
|
echo "" >> $logfile
|
|
}
|
|
function info() {
|
|
log "INFO" "$1"
|
|
}
|
|
|
|
function handle_error() {
|
|
log "ERROR" "Error on line $(caller)"
|
|
endprocess
|
|
}
|
|
|
|
function endprocess() {
|
|
info "========================================[end ffmpeg $pid]"
|
|
newline
|
|
rm -f "$stderrfile"
|
|
exit 1
|
|
}
|
|
|
|
#########################
|
|
# ENTRYPOINT
|
|
#########################
|
|
|
|
trap endprocess SIGTERM
|
|
trap handle_error ERR
|
|
|
|
newline
|
|
info "========================================[start ffmpeg $pid]"
|
|
info "DEFAULT_ARGS: $*"
|
|
|
|
/var/packages/ffmpeg/target/bin/ffmpeg "$@" 2> $stderrfile
|
|
|
|
endprocess
|