Skip to content

Commit f5d6874

Browse files
authored
Multitry ffmpeg (#100)
* Add multi-try ffmpeg
1 parent cea1126 commit f5d6874

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

wrappers/ffmpeg.sh

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,13 @@ handle_error() {
3333
log "ERROR" "An error occurred"
3434
newline
3535
errcode=1
36-
endprocess
36+
kill_child
37+
}
38+
39+
kill_child() {
40+
if [[ "$child" != "" ]]; then
41+
kill "$child"
42+
fi
3743
}
3844

3945
endprocess() {
@@ -44,12 +50,9 @@ endprocess() {
4450
cp "$stderrfile" "$stderrfile.prev"
4551
fi
4652

53+
kill_child
4754
rm -f "$stderrfile"
4855

49-
if [[ "$child" != "" ]]; then
50-
kill "$child"
51-
fi
52-
5356
exit $errcode
5457
}
5558

@@ -114,8 +117,26 @@ info "========================================[start ffmpeg $pid]"
114117
info "DEFAULT ARGS: $*"
115118
info "UPDATED ARGS: ${args[*]}"
116119

117-
"/var/packages/${ffmpeg_version}/target/bin/ffmpeg" "${args[@]}" <&0 2>> $stderrfile &
120+
info "Trying with VideoStation's ffmpeg with fixed args..."
121+
/var/packages/VideoStation/target/bin/ffmpeg.orig "${args[@]}" <&0 2>> $stderrfile &
122+
child=$!
123+
wait "$child"
124+
125+
if [[ $errcode -eq 0 ]]; then
126+
endprocess
127+
fi
128+
129+
info "Trying with VideoStation's ffmpeg with default args..."
130+
/var/packages/VideoStation/target/bin/ffmpeg.orig "$@" <&0 2>> $stderrfile &
131+
child=$!
132+
wait "$child"
118133

134+
if [[ $errcode -eq 0 ]]; then
135+
endprocess
136+
fi
137+
138+
info "Trying with SC's ffmpeg and fixed args..."
139+
"/var/packages/${ffmpeg_version}/target/bin/ffmpeg" "${args[@]}" <&0 2>> $stderrfile &
119140
child=$!
120141
wait "$child"
121142

0 commit comments

Comments
 (0)