75 lines
2.4 KiB
Bash
75 lines
2.4 KiB
Bash
#!/bin/bash
|
|
encodeFile::mp3() {
|
|
lameopts=(${ionice}lame --quiet)
|
|
lameopts+=(-v --abr ${destinationquality[$destination]})
|
|
[ -n "$album" ] && lameopts+=(--tl "$album" )
|
|
[ -n "$artist" ] && lameopts+=(--ta "$artist")
|
|
[ -n "$genre" ] && lameopts+=(--tg "$genre")
|
|
[ -n "$title" ] && lameopts+=(--tt "$title")
|
|
[ -n "$track" ] && lameopts+=(--tn "$track")
|
|
[ -n "$year" ] && lameopts+=(--ty "$year")
|
|
if (( ${destinationnoresample[$destination]:-0} == 1 ))
|
|
then
|
|
# If 'rate' is not one of these value, it cannot be encoded to
|
|
# MP3, in which case we'd be better of letting lame decide which
|
|
# rate to use.
|
|
if [ -n "${destinationfrequency["$destination"]}" ]
|
|
then
|
|
case ${destinationfrequency["$destination"]} in
|
|
48000) lameopts+=(--resample 48) ;;
|
|
44100) lameopts+=(--resample 44.1) ;;
|
|
32000) lameopts+=(--resample 32) ;;
|
|
24000) lameopts+=(--resample 24) ;;
|
|
22050) lameopts+=(--resample 22.05) ;;
|
|
16000) lameopts+=(--resample 16) ;;
|
|
12000) lameopts+=(--resample 12) ;;
|
|
11025) lameopts+=(--resample 11.025) ;;
|
|
8000) lameopts+=(--resample 8) ;;
|
|
esac
|
|
elif (( rate > 48000 ))
|
|
then
|
|
lameopts+=(--resample 48)
|
|
else
|
|
case $rate in
|
|
48000) lameopts+=(--resample 48) ;;
|
|
44100) lameopts+=(--resample 44.1) ;;
|
|
32000) lameopts+=(--resample 32) ;;
|
|
24000) lameopts+=(--resample 24) ;;
|
|
22050) lameopts+=(--resample 22.05) ;;
|
|
16000) lameopts+=(--resample 16) ;;
|
|
12000) lameopts+=(--resample 12) ;;
|
|
11025) lameopts+=(--resample 11.025) ;;
|
|
8000) lameopts+=(--resample 8) ;;
|
|
esac
|
|
fi
|
|
fi
|
|
lameopts+=("$tempdir/$tmpfile.wav" "$destdir/$destfile.mp3")
|
|
encodetaskid=$(
|
|
Insert tasks <<-EOInsert
|
|
key ${fileid}lame$destination
|
|
requires ${soxtaskid:-$decodetaskid}
|
|
required ${soxtaskid:-$decodetaskid}
|
|
fileid $destfileid
|
|
filename $destdir/$destfile.mp3
|
|
$(
|
|
for key in ${!lameopts[@]}
|
|
do
|
|
cleanedopts="${lameopts[key]//\&/\\\&}"
|
|
cleanedopts="${cleanedopts//\[/\\[}"
|
|
cleanedopts="${cleanedopts//\]/\\]}"
|
|
cleanedopts="${cleanedopts//\{/\\{}"
|
|
cleanedopts="${cleanedopts//\}/\\\}}"
|
|
echo "cmd_arg$key $cleanedopts"
|
|
done
|
|
)
|
|
cleanup $tempdir/$tmpfile.wav
|
|
source_file $fileid
|
|
status 0
|
|
rename_pattern ${destinationrenamepath[$destination]}/${destinationrename[$destination]}
|
|
fat32compat ${destinationfat32compat["$destination"]}
|
|
ascii ${destinationascii["$destination"]}
|
|
EOInsert
|
|
)
|
|
progressSpin
|
|
}
|