dimanche, août 6 2006, 21:36
ogg2mp3
Par Guillaume Lelarge - Linux - Lien permanent
Pas vraiment bizarrement, il existe plein d'outils pour transformer un MP3 en OGG, mais pas grand chose (ou plutôt rien) pour l'opération inverse. Bien sûr, j'ai cherché une solution et j'ai fini par tomber sur ce billet. Problème : pas de récupération des tags. Du coup, j'ai modifié ce script pour en arriver à ceci :
find_tag() {
TAG=`ogginfo "$1" | grep -i "$2" | awk -F"=" '{print $2}'`
}
for fichier in $(find . -name "*.ogg")
do
mkdir -p `dirname mp3/${fichier}.mp3`
find_tag $fichier album && album=$TAG
find_tag $fichier artist && artiste=$TAG
find_tag $fichier title && titre=$TAG
find_tag $fichier track && piste=$TAG
ogg123 -d wav -f - ${fichier} | lame -h - > mp3/${fichier}.mp3
mp3info -a "$artiste" -l "$album" -t "$titre" -n "$piste" mp3/${fichier}.mp3
done
Pas mal, non ? 
un commentaire
Hello,
Merci pour ce script qui m'as bien servi ce soir. Mais il a quelques lacunes au niveau des espaces dans les noms de fichiers et les tag. Il manque les " ". et il y a encore l'extension ogg qui apparait dans le fichier mp3.
Voilà le script corrigé :
find_tag() {
TAG=`ogginfo "$1" | grep -i "$2" | awk -F"=" '{print $2}'`}
mkdir -p "mp3"
for fichier in *.ogg
do
fichier2="${fichier%.*}"
find_tag "$fichier" album && album=$TAG
find_tag "$fichier" artist && artiste=$TAG
find_tag "$fichier" title && titre=$TAG
find_tag "$fichier" track && piste=$TAG
ogg123 -d wav -f - "$fichier" | lame -h - > mp3/"$fichier2".mp3
mp3info -a "$artiste" -l "$album" -t "$titre" -n "$piste" mp3/"$fichier2".mp3
done