-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathffmpeg-wrapper.sh
50 lines (39 loc) · 897 Bytes
/
ffmpeg-wrapper.sh
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
49
50
#!/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 (MediaServer) $pid]"
newline
rm -f "$stderrfile"
exit 1
}
#########################
# ENTRYPOINT
#########################
trap endprocess SIGTERM
trap handle_error ERR
newline
info "========================================[start ffmpeg (MediaServer) $pid]"
info "DEFAULT_ARGS: $*"
/var/packages/ffmpeg/target/bin/ffmpeg "$@" 2> $stderrfile
endprocess