urpmi lame
#!/bin/bash
cd "`pwd`"
#Variables
VERSION="0.7.1"
AfficherAide()
{
echo "audio2all v. "${VERSION}" - Audio Format Converter (Universal Version)."
echo
echo "Usage :"
echo -e "\taudio2all -i [input extention] -o [output format] -b [bitrate]"
echo -e "\tIndiquez simplement l'extention des fichiers à convertir (sans le point) et le format de sortie."
echo
echo "Exemple :"
echo -e "\taudio2all -i mp3 -o ogg \tconvertira tous les fichiers mp3 du répertoire courant au format OGG/VORBIS."
echo
echo "Formats reconnus :"
echo -e "\tEn entrée : Tous les formats reconnus par FFmpeg, ape."
echo -e "\tEn sortie : aac, ac3, ape, flac, mp2, mp3, ogg, wav."
echo
echo "Dépendances :"
echo -e "\tFFmpeg, APE."
echo
echo "Liste des options utilisables :"
echo -e "\t-b : Permet de choisir le bitrate (sauf flac et wav)."
echo -e "\t-h --help : Affichage de cette aide."
echo -e "\t-v --version : Affiche la version de audio2all."
echo
exit
}
if [ ! ${1} ] || [ "${1}" = "-h" ] || [ "${1}" = "--help" ]
then
AfficherAide;exit 0
fi
if [ "${1}" = "-v" ] || [ "${1}" = "--version" ]
then
echo "audio2all v. "${VERSION}"";exit 0
fi
while getopts i
:b: option
do
case $option in
"i" )
INPUT="$OPTARG"
;;
"o" )
OUTPUT="$OPTARG"
;;
"b" )
BITRATE="$OPTARG"
;;
"r" )
RESAMPLE="$OPTARG"
;;
esac
done
Conv2ALL()
{
if [ "${OUTPUT}" != "wav" ] || [ "${OUTPUT}" !="flac" ]
then
ffmpeg -i "${i}" -f ${OUTPUT} -ab "${BITRATE}" -ac 2 "${INPUT}2${OUTPUT}"/"${y}"
else
ffmpeg -i "${i}" -f ${OUTPUT} "${INPUT}2${OUTPUT}"/"${y}"
fi
}
if [ "${INPUT}" = "ape" ]
then
for i in *.${INPUT}
do
y=`echo "${i}" | sed 's/ape$/wav/'`
mac "${i}" "${y}" -d
done
INPUT="wav"
fi
mkdir "${INPUT}2${OUTPUT}"
for i in *.${INPUT}
do
case ${OUTPUT} in
"mp3" )
y=`echo "${i}" | sed 's/...$/mp3/'`
if [ ! "${BITRATE}" ]
then
BITRATE="128"
fi
;;
"aac" )
y=`echo "${i}" | sed 's/...$/aac/'`
if [ ! "${BITRATE}" ]
then
BITRATE="128"
fi
;;
"ogg" )
y=`echo "${i}" | sed 's/...$/ogg/'`
if [ ! "${BITRATE}" ]
then
BITRATE="128"
fi
;;
"flac" )
y=`echo "${i}" | sed 's/...$/flac/'`
;;
"mp2" )
y=`echo "${i}" | sed 's/...$/mp2/'`
if [ ! "${BITRATE}" ]
then
BITRATE="224"
fi
;;
"ac3" )
y=`echo "${i}" | sed 's/...$/ac3/'`
if [ ! "${BITRATE}" ]
then
BITRATE="448"
fi
;;
"wav" )
y=`echo "${i}" | sed 's/...$/wav/'`
;;
esac
Conv2ALL
rm -f "${i}"
done
A nommer audio2all, à rendre éxécutable et à copier dans /usr/local/bin.
audio2all -i wav -o oggconvertira tous les fichiers WAV du répertoire courant en OGG/VORBIS.