228 lines
4.5 KiB
Bash
228 lines
4.5 KiB
Bash
#!/bin/bash
|
|
|
|
setupDestination() {
|
|
cat <<-EODesc
|
|
|
|
Format:
|
|
vorbis, opus or mp3. Other formats may appear in the future.
|
|
EODesc
|
|
comeagain() {
|
|
read \
|
|
-e \
|
|
${destinationformat["$destination"]+-i"${destinationformat["$destination"]}"}\
|
|
-p 'Format: ' \
|
|
value
|
|
case "$value" in
|
|
'mp3')
|
|
destinationformat["$destination"]=mp3
|
|
lameneeded=1
|
|
;;
|
|
'opus')
|
|
destinationformat["$destination"]=opus
|
|
opusencneeded=1
|
|
;;
|
|
'vorbis'|'ogg')
|
|
destinationformat["$destination"]=vorbis
|
|
oggencneeded=1
|
|
;;
|
|
*)
|
|
echo "Unsupported destination format: $value" >&2
|
|
comeagain
|
|
;;
|
|
esac
|
|
}
|
|
comeagain
|
|
cat <<-EODesc
|
|
|
|
Path (path):
|
|
Where to store transcoded files (will be created if it does not
|
|
exist).
|
|
EODesc
|
|
read \
|
|
-e \
|
|
-p'Path: ' \
|
|
${destinationpath["$destination"]+-i"${destinationpath["$destination"]}"}\
|
|
destinationpath["$destination"]
|
|
case ${destinationformat["$destination"]} in
|
|
vorbis)
|
|
cat <<-EODesc
|
|
|
|
Quality (integer):
|
|
The quality parameter of oggenc. See man oggenc for more info.
|
|
EODesc
|
|
expr='^[0-9]*$'
|
|
comeagain() {
|
|
read \
|
|
-p'Quality: ' \
|
|
-e \
|
|
-i \
|
|
${destinationquality["$destination"]:-3}\
|
|
value
|
|
if ! [[ $value =~ $expr ]]
|
|
then
|
|
echo "Invalid quality value: $value" >&2
|
|
comeagain
|
|
fi
|
|
}
|
|
comeagain
|
|
destinationquality["$destination"]=$value
|
|
;;
|
|
opus)
|
|
cat <<-EODesc
|
|
|
|
Bitrate (kbps, integer):
|
|
Set (VBR) bitrate to <bitrate>. Note that while Opus allows for
|
|
decimal values, AtOM does not. The reason for this is simple: we do
|
|
numeric comparisons, and Bash only manipulates integers.
|
|
EODesc
|
|
expr='^[0-9]*$'
|
|
comeagain() {
|
|
read \
|
|
-e \
|
|
-i \
|
|
${destinationquality["$destination"]:-128}\
|
|
-p 'Bitrate: '
|
|
value
|
|
if ! [[ $value =~ $expr ]]
|
|
then
|
|
echo "Invalid bitrate value: $value" >&2
|
|
comeagain
|
|
fi
|
|
}
|
|
comeagain
|
|
destinationquality["$destination"]=$value
|
|
cat <<-EODesc
|
|
|
|
Loss (percent, integer):
|
|
If you intend to stream the resulting files over an unreliable
|
|
protocol, you may want to make use of Opus' Forward Error
|
|
Correction algorythm. See the Opus-codec.org website for details.
|
|
EODesc
|
|
comeagain() {
|
|
read \
|
|
-e \
|
|
-i \
|
|
${destinationloss["$destination"]:-0}\
|
|
value
|
|
if ! [[ $value =~ $expr ]]
|
|
then
|
|
echo "Invalid loss value: $value" >&2
|
|
comeagain
|
|
fi
|
|
}
|
|
comeagain
|
|
destinationloss["$destination"]=$value
|
|
;;
|
|
mp3)
|
|
cat <<-EODesc
|
|
|
|
Bitrate (kbps, integer):
|
|
Set (ABR) bitrate to <bitrate>.
|
|
EODesc
|
|
expr='^[0-9]*$'
|
|
comeagain() {
|
|
read \
|
|
-e \
|
|
-i \
|
|
${destinationquality["$destination"]:-128}\
|
|
value
|
|
if ! [[ $value =~ $expr ]]
|
|
then
|
|
echo "Invalid bitrate value: $value" >&2
|
|
comeagain
|
|
fi
|
|
}
|
|
comeagain
|
|
destinationquality["$destination"]=$value
|
|
cat <<-EODesc
|
|
|
|
Prevent resampling (boolean):
|
|
LAME may decide to encode your file to a lower sampling-rate if you
|
|
use a low bitrate. Setting this to yes will append --resample
|
|
<original file's rate>, preventing any resampling from happening.
|
|
EODesc
|
|
case ${destinationnoresample["$destination"]} in
|
|
0) initialvalue=n ;;
|
|
1) initialvalue=y ;;
|
|
*) unset initialvalue ;;
|
|
esac
|
|
comeagain() {
|
|
read \
|
|
-e \
|
|
${initialvalue+-i $initialvalue}\
|
|
-p'Prevent resampling (y/N): ' \
|
|
value
|
|
case $value in
|
|
[yY])
|
|
destinationnoresample["$destination"]=1
|
|
;;
|
|
''|[nN])
|
|
destinationnoresample["$destination"]=0
|
|
;;
|
|
*)
|
|
comeagain
|
|
;;
|
|
esac
|
|
}
|
|
comeagain
|
|
;;
|
|
esac
|
|
cat <<-EODesc
|
|
|
|
[Optional parameters]
|
|
Now you will have the opportunity to configure "advanced" parameters
|
|
for $destination. You may leave any of these fields blank.
|
|
EODesc
|
|
cat <<-EODesc
|
|
|
|
Normalize (boolean):
|
|
Normalize output files.
|
|
EODesc
|
|
comeagain() {
|
|
:
|
|
}
|
|
comeagain
|
|
cat <<-EODesc
|
|
EODesc
|
|
comeagain() {
|
|
:
|
|
}
|
|
comeagain
|
|
cat <<-EODesc
|
|
EODesc
|
|
comeagain() {
|
|
:
|
|
}
|
|
comeagain
|
|
cat <<-EODesc
|
|
EODesc
|
|
comeagain() {
|
|
:
|
|
}
|
|
comeagain
|
|
cat <<-EODesc
|
|
EODesc
|
|
comeagain() {
|
|
:
|
|
}
|
|
comeagain
|
|
cat <<-EODesc
|
|
EODesc
|
|
comeagain() {
|
|
:
|
|
}
|
|
comeagain
|
|
cat <<-EODesc
|
|
EODesc
|
|
comeagain() {
|
|
:
|
|
}
|
|
comeagain
|
|
cat <<-EODesc
|
|
EODesc
|
|
comeagain() {
|
|
:
|
|
}
|
|
comeagain
|
|
}
|