[18/05/2009]
Facile, con lame e id3!
Questo script ricrea tutti gli mp3 presenti nella directory corrente (o in quella passata in input, o solo il file specificato) sotto la cartella OUTPUT effettuando un resampling a 128kbps. Utile per risparmiare spazio se si hanno mp3 con bitrate molto alto. Il comando id3 estrae i tag ID3 del sorgente che vengono passati a lame per l'encoding (altrimenti lame "perde" i tag).
#!/bin/bash
album=$1
IFS="
"
tmpfile=`mktemp`
for i in `find $album -name "*mp3"` ; do
newdir=OUTPUT/`dirname $i`
[ -d $newdir ] || mkdir -p $newdir
id3 -Rl "$i" |sed -e 's/ *$//g' -e 's/:$//' > $tmpfile
tt=`grep ^Title: $tmpfile| sed -e "s/Title: //"`
ta=`grep ^Artist: $tmpfile| sed -e "s/Artist: //"`
tl=`grep ^Album: $tmpfile| sed -e "s/Album: //"`
ty=`grep ^Year: $tmpfile| sed -e "s/Year: //"`
tc=`grep ^Comment: $tmpfile| sed -e "s/Comment: //"`
tn=`grep ^Track: $tmpfile| sed -e "s/Track: //"`
tg=`grep ^Genre: $tmpfile| awk '{a=$NF; b=index(a,")"); print substr(a,2,b-2)}'`
lame --mp3input -b 128 \
--tt "$tt" --ta "$ta" --tl "$tl" --ty "$ty" \
--tc "$tc" --tn "$tn" --tg "$tg" "$i" "OUTPUT/$i"
done
rm $tmpfile
Categoria: Linux -
Autore: ludovico -
Inserisci Commento