-
Notifications
You must be signed in to change notification settings - Fork 2
/
magic.sh
executable file
·58 lines (57 loc) · 1.34 KB
/
magic.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
51
52
53
54
55
56
57
58
#!/bin/bash
# This script disables transcode for videos which already have aac audio
magic=0
i=0
input=false
for arg in "$@"; do
((i++))
next=$((i+1))
if [[ "$arg" == "-i" ]]; then
input=true
fi
if [[ "$arg" =~ -codec:[0-9] && "${@:$next:1}" == "aac" && $magic == 0 && $input == false ]]; then
((magic++))
continue
fi
if [[ "$arg" == "aac" && $magic == 1 ]]; then
((magic++))
continue
fi
if [[ "$arg" == "-codec:1" && $magic == 2 ]]; then
((magic++))
fi
if [[ "$arg" == "aac" && $magic == 3 ]]; then
args[$i]="copy"
((magic++))
continue
fi
if [[ "$arg" == "-ar:1" && $magic == 4 ]]; then
args[$i]="-copypriorss:1"
((magic++))
continue
fi
if [[ "$arg" == "48000" && $magic == 5 ]]; then
args[$i]="0"
((magic++))
continue
fi
if [[ "$arg" == "-channel_layout:1" && $magic == 6 ]]; then
((magic++))
continue
fi
if [[ "$arg" == "stereo" && $magic == 7 ]]; then
((magic++))
continue
fi
if [[ "$arg" == "-b:1" && $magic == 8 ]]; then
((magic++))
continue
fi
if [[ "$arg" == "256k" && $magic == 9 ]]; then
((magic++))
continue
fi
args[$i]=$(printf "%q" "$arg")
done
set -- "${args[@]}"
eval "/opt/plex/Application/Plex\ Transcoder_ $@"