Voici un petit script qui permet de convertir une liste de fichiers audio (Wav --> AC3, Mp3 en org)
Code:
#!/bin/bash
cd `dirname $0`
#Variables
VERSION="0.5"
if [ -e /tmp/rename.all ]
then
rm -f /tmp/rename.all
fi
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 a 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 repertoire courant au format OGG/VORBIS."
echo
echo "Formats reconnus :"
echo -e "\tEn entree : Tous les formats reconnus par MPlayer."
echo -e "\tEn sortie : aac, ac3, flac, mp2, mp3, ogg, wav."
echo
echo "Dependances :"
echo -e "\tfaac, flac, ffmpeg, lame, mplayer, oggenc, toolame."
echo
echo "Liste des options utilisables :"
echo -e "\t-b : Permet de choisir le bitrate (uniquement pour l'aac, l'ac3, le mp2, le mp3 et l'ogg)."
echo -e "\t-h --help : Affichage de cette aide."
echo -e "\t-v --version : Affiche la version de audio2all."
echo
exit
}
while getopts i:o:b: option
do
case $option in
"i" )
INPUT="$OPTARG"
;;
"o" )
OUTPUT="$OPTARG"
;;
"b" )
BITRATE="$OPTARG"
;;
esac
done
if [ ! ${1} ] || [ "${1}" = "-h" ] || [ "${1}" = "--help" ]
then
AfficherAide;exit 0
fi
if [ "${1}" = "-v" ] || [ "${1}" = "--version" ]
then
echo "audio2all v. "${VERSION}"";exit 0
fi
for i in *.${INPUT}
do
mplayer "${i}" -ao pcm:file="${i}.wav"
done
rm -f *.${INPUT}
case ${OUTPUT} in
"wav" )
cat << EOF > /tmp/rename.all
#!/bin/bash
for i in *.wav
do
x=\`echo "\${i}"|sed -e 's/${INPUT}.wav/wav/'\`
mv "\${i}" "\${x}"
done
rm -f /tmp/rename.all
EOF
chmod +x /tmp/rename.all
exec /tmp/rename.all
;;
"mp3" )
for i in *.wav
do
if [ "${BITRATE}" ]
then
lame -b ${BITRATE} "${i}"
else
lame --vbr-new "${i}"
fi
rm -f "${i}"
done
cat << EOF > /tmp/rename.all
#!/bin/bash
for i in *.mp3
do
x=\`echo "\${i}"|sed -e 's/${INPUT}.wav.mp3/mp3/'\`
mv "\${i}" "\${x}"
done
rm -f /tmp/rename.all
EOF
chmod +x /tmp/rename.all
exec /tmp/rename.all
;;
"aac" )
for i in *.wav
do
if [ "${BITRATE}" ]
then
faac -b ${BITRATE} "${i}"
else
faac "${i}"
fi
rm -f "${i}"
done
cat << EOF > /tmp/rename.all
#!/bin/bash
for i in *.aac
do
x=\`echo "\${i}"|sed -e 's/${INPUT}.aac/aac/'\`
mv "\${i}" "\${x}"
done
rm -f /tmp/rename.all
EOF
chmod +x /tmp/rename.all
exec /tmp/rename.all
;;
"ogg" )
for i in *.wav
do
if [ "${BITRATE}" ]
then
oggenc -b ${BITRATE} "${i}"
else
oggenc "${i}"
fi
rm -f "${i}"
done
cat << EOF > /tmp/rename.all
#!/bin/bash
for i in *.ogg
do
x=\`echo "\${i}"|sed -e 's/${INPUT}.ogg/ogg/'\`
mv "\${i}" "\${x}"
done
rm -f /tmp/rename.all
EOF
chmod +x /tmp/rename.all
exec /tmp/rename.all
;;
"flac" )
for i in *.wav
do
flac --delete-input-file "${i}"
done
cat << EOF > /tmp/rename.all
#!/bin/bash
for i in *.flac
do
x=\`echo "\${i}"|sed -e 's/${INPUT}.flac/flac/'\`
mv "\${i}" "\${x}"
done
rm -f /tmp/rename.all
EOF
chmod +x /tmp/rename.all
exec /tmp/rename.all
;;
"mp2" )
for i in *.wav
do
if [ "${BITRATE}" ]
then
toolame -b "${BITRATE}" "${i}"
else
toolame "${i}"
fi
rm -f "${i}"
done
cat << EOF > /tmp/rename.all
#!/bin/bash
for i in *.mp2
do
x=\`echo "\${i}"|sed -e 's/${INPUT}.mp2/mp2/'\`
mv "\${i}" "\${x}"
done
rm -f /tmp/rename.all
EOF
chmod +x /tmp/rename.all
exec /tmp/rename.all
;;
"ac3" )
for i in *.wav
do
if [ "${BITRATE}" ]
then
ffmpeg -y -i "${i}" -f ac3 -ab "${BITRATE}" -ar 48000 -ac 2 "${i}"
else
ffmpeg -y -i "${i}" -f ac3 -ab 448 -ar 48000 -ac 2 "${i}"
fi
rm -f "${i}"
done
cat << EOF > /tmp/rename.all
#!/bin/bash
for i in *.ac3
do
x=\`echo "\${i}"|sed -e 's/${INPUT}.wav.ac3/ac3/'\`
mv "\${i}" "\${x}"
done
rm -f /tmp/rename.all
EOF
chmod +x /tmp/rename.all
exec /tmp/rename.all
;;
esac
La source trouvee dans le forum de Lea-Linux.org (
http://lea-linux.org/pho/read/20/254778)
On ne sait jamais ca peut utile
