-
Notifications
You must be signed in to change notification settings - Fork 0
/
ff-remux.sh
executable file
·108 lines (97 loc) · 2.13 KB
/
ff-remux.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
function warn {
printf '\e[36m%s\e[m\n' "$*"
}
function log {
unset PS4
sx=$((set -x
: "$@") 2>&1)
warn "${sx:2}"
"$@"
}
function hx {
printf 0x%04x%04x $*
}
function bf {
regtool set /user/console/ScreenBufferSize $(hx 2000 $1)
regtool set /user/console/WindowSize $(hx 25 $1)
cygstart bash $2
kill -7 $$ $PPID
}
function hr {
sed '
1d
$d
s/ //
' <<< "$1"
}
function ug {
hr '
ff-remux.sh [-c choice] [-u] [-a artist] [-t title] [files]
-u instead of literal metadata, interpret "-a" and "-t" values as fields for
"cut" of input filename
'
for each in "${ga[@]}"
do
printf '%2s %s\n' $((++bar)) "$each"
done
exit
}
ga=(
'ffmpeg -i %q %q.wav'
'ffmpeg -i %q %q.flac'
'ffmpeg -i %q -c copy %q.flv'
'ffmpeg -i %q -c copy %q.mp4'
'ffmpeg -i %q -c copy -sn %q.mp4'
'ffmpeg -i %q -c copy %q.m4a'
'ffmpeg -i %q -c copy -vn %q.m4a'
'ffmpeg -i %q -c copy -vn %q.mp3'
'ffmpeg -i %q -c copy -vn -movflags faststart %q.m4a'
'ffmpeg -i %q -c copy -vn -movflags faststart -metadata artist=%q \
-metadata title=%q %q.m4a'
'ffmpeg -i %q -vn -b:a 256k -movflags faststart %q.m4a'
'ffmpeg -i %q -c:v copy -b:a 256k -ac 2 -clev 3dB -slev -6dB %q.mp4'
'ffmpeg -i %q -b:a 256k -ac 2 -clev 3dB -slev -6dB %q.mp4'
)
while getopts c:ua:t: name
do
case $name in
c) ci=$OPTARG ;;
u) (( fd++ )) ;;
a) ai=$OPTARG ;;
t) te=$OPTARG ;;
esac
done
shift $((--OPTIND))
(( $# )) || ug
seq ${#ga[*]} | grep -qx "$ci" || ug
up=${ga[ci-1]}
[[ $up =~ artist ]] && [[ ! $ai ]] && ug
[[ $up =~ title ]] && [[ ! $te ]] && ug
for ip
do
ib=${ip%.*}
ie=${ip##*.}
oe=${up##*.}
ae[0]=$ip
if (( fd ))
then
ae[1]=$(cut --de "-" --ou " " --fi "$ai" <<< "$ip")
ae[2]=$(cut --de "-" --ou " " --fi "$te" <<< "$ip")
elif [[ $up =~ metadata ]]
then
ae[1]=$ai
ae[2]=$te
fi
ae[3]=$ib
[[ $oe = $ie ]] && ae[3]+='~'
printf -v stage2 "$up" "${ae[@]}"
(( oc++ )) && ao+=("echo")
ao+=("log $stage2 -hide_banner")
done
ao+=("warn Press any key to continue...")
ao+=("read")
ao+=("rm rx.sh")
ao+=("bf 80")
printf '%s\n' "${ao[@]}" > rx.sh
export -f bf hx log warn
bf 88 rx.sh