39 lines
931 B
Bash
Executable file
39 lines
931 B
Bash
Executable file
#!/bin/sh
|
|
#
|
|
# Parameter: INPUTFILES
|
|
#
|
|
|
|
set -eu
|
|
|
|
# eine Sample-Rate von weniger als 26000 bereitet wohl Probleme - das neue ogg ist dann tot
|
|
ENC_OPTIONS="--quality=2 --max-bitrate=64 --resample=26000"
|
|
# the input encoding will be ingnored for the wav-output of mp3-decoder
|
|
INPUT_OPTIONS="--raw --raw-chan=1 --raw-bits=16 --raw-rate=44100"
|
|
|
|
function decode_input()
|
|
{
|
|
if [[ "$1" =~ "\.mp3$" ]]
|
|
then mp3-decoder --wav - "$1"
|
|
else oggdec --quiet -R -b 16 -o - "$1"
|
|
fi
|
|
}
|
|
|
|
function check_file()
|
|
{
|
|
if [[ "$1" =~ "\.mp3$" ]] || [[ "$1" =~ "\.ogg$" ]]
|
|
then if [ -e "$1" ]
|
|
then return 0
|
|
else echo "die Datei ($1) exisitiert nicht!" >&2
|
|
return 1
|
|
fi
|
|
else echo "ungueltige Datei ($1): nur 'mp3' oder 'ogg' werden unterstuetzt"
|
|
return 2
|
|
fi
|
|
}
|
|
|
|
######### los geht's ##########
|
|
|
|
for a in $@
|
|
do check_file "$1" && decode_input "$1" | oggenc $INPUT_OPTIONS $ENC_OPTIONS --output="${a%.*}-low.ogg" -
|
|
done
|