-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathffdialtone
executable file
·39 lines (27 loc) · 1.02 KB
/
ffdialtone
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
#!/usr/bin/env bash
# ffdialtone: Generate a US (North American) dialtone with the given duration.
set -eo pipefail
function help {
echo "Usage: ffdialtone <duration> <output>"
exit
}
function installed {
cmd=$(command -v "${1}")
[[ -n "${cmd}" ]] && [[ -f "${cmd}" ]]
return ${?}
}
function cleanup {
rm -f "${input350}"
rm -f "${input440}"
}
trap cleanup EXIT
[[ $# -eq 2 && ! -f $2 ]] || help
installed ffmpeg || { >&2 echo "Missing ffmpeg."; exit 1; }
input350=$(mktemp -u ffdialtone-input350-XXXXX.wav)
input440=$(mktemp -u ffdialtone-input440-XXXXX.wav)
ffmpeg -f lavfi -i "sine=frequency=350:duration=${1}" -af "volume=-13dB" "${input350}"
ffmpeg -f lavfi -i "sine=frequency=440:duration=${1}" -af "volume=-13dB" "${input440}"
# if you'd like to output in GSM full-rate:
# ffmpeg -i "${input350}" -i "${input440}" -filter_complex "amix=inputs=2:duration=first" \
# -ar 8000 -ab 13000 -ac 1 "${2}"
ffmpeg -i "${input350}" -i "${input440}" -filter_complex "amix=inputs=2:duration=first" "${2}"