Necessita di mplayer e lame. Di default l' encoding mp3 avviene a 128k, nel raro caso vi servisse un bitrate maggiore usate -b come opzione a lame (es. -b 192).
[N.d.R. Ntropia: Lo script si può usare specificando le directory di origine e destinazione:wma2mp3 ./canzoni_wma/ ./canzoni_mp3/
oppure senza alcun argomento, lavorando su tutti i files di input e scrivendo i files di output in mp3 direttamente nella directory dove viene lanciato. ]
#!/bin/bash ########### # # WM2MP3 - Wma/Mpc to mp3 converter # ------------------------------ # by Old Sparky - oldsparky@bmlabs.net # # - Description: this script allow you to convert your wma or mpc files to # mp3 and clean filename from space and boring special chars. Usefull if # your cheap player read only this audio format. # # - Changelog: # 01/10/2006 first version; # 15/10/2006 added some control routines; # 24/10/2006 fixed some minor bugs; # 30/12/2006 added mpc format conversion and some control routines (mplayer # has some troubles with libmpcdec at this time) # # - LICENSE: WM2MP3 is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the Free # Software Foundation; either version 2, or (at your option) any later version. # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. # You should have received a copy of the GNU General Public License along with # this program. If not, write to the Free Software Foundation, Inc., 59 Temple # Place - Suite 330, Boston, MA 02111-1307, USA. # ############################################################################### # vars bitrate="192" # MP3 bitrate in Kbit # some controls if ! MPLAYER=`which mplayer` then echo "ERR: mplayer binary not found" exit 1 fi if ! MPC123=`which mpc123` then echo "ERR: mpc123 binary not found" exit 1 fi if ! LAME=`which lame` then echo "ERR: lame binary not found" exit 1 fi if ! SED=`which sed` then echo "ERR: sed binary not found" exit 1 fi src="$PWD" dest="$PWD" [ -d "$1" ] && src="$1" [ -d "$2" ] && dest="$2" if ! [ -w "$dest" ] then echo "WRN: $dest is not writable, using /tmp instead." dest="/tmp" fi if [ `ls -l $src | grep -ce "\.[WwMm][MmPp][AaCc]"` -le 0 ] then echo "ERR: There aren't WMA or MPC files in $src." exit 1 fi # encode with LAME from wav dump file for fname in $src/*.[WwMm][MmPp][AaCc] do if [ `echo $fname | grep -ce "\.[Ww][Mm][Aa]"` -eq 1 ] then $MPLAYER -vo null -vc dummy -af resample=44100 -ao pcm:file=/tmp/audiodump.wav "$fname" || exit 1 extens=".wma"; elif [ `echo $fname | grep -ce "\.[Mm][Pp][Cc]"` -eq 1 ] then $MPC123 -w /tmp/audiodump.wav "$fname" || exit 1 extens=".mpc"; fi fname_clear=`echo $fname|$SED 's/ /_/g'|$SED 's/_-_/-/g'|$SED 's/[+{;"\=?~()<>&*|$]//g'|$SED 's/__/_/g'` $LAME -b $bitrate -o -m s /tmp/audiodump.wav "$dest/`basename "$fname_clear" "$extens"`.mp3" || exit 1 done rm -rf /tmp/audiodump.wav exit 0 #EOF
Commenti
Inviato da paolo il Dom, 29/10/2006 - 04:40.
Ottimo!
Grazie per lo script, molto comodo, io amo il bash scripting!
Comunque, io preferisco utilizzare sempre il formato OGG quando posso, i lettori mp3 (appunto) non digeriscono questo formato aperto.
Comunque questo programmino è anche molto comodo:
http://badcomputer.org/unix/dir2ogg/
Inoltre è anche presente nel rep di Marillat.
Converto tutti i formati esistenti in OGG, che vi invito ad utilizzare più che potete quando il vostro sistema vi garantisce le principali libertà
Paolo
Paolo Mainardi
CTO Twinbit http://www.twinbit.it
Vice Presidente -- ILDN - Italian Linux DIstro Network
Inviato da OldSparky il Sab, 30/12/2006 - 15:32.
Re:: Ottimo!
Anch'io preferisco OGG o FLAC, ma putroppo come appunto dicevi, i lettori piu' comuni leggono mp3. Inoltre molti brani si trovano solo in formato mp3 e l' unica alternativa è quella di fare il ripping da sè (ormai divenuto anchesso illegale grazie al DRM), e quindi di "farsi una cultura" in merito.
.
Infatti i brani convertiti da lossy->lossy hanno un'ulteriore peggioramento qualitativo, ed è anche per questo che uso un bitrate a 128Kbit, anche se il wma originale è un 192, e appunto solo in rari casi con un bitrate maggiore. :-P
Inviato da ntropia il Mar, 02/01/2007 - 11:15.
Aggiornamento script wm2mp3
Lo script è stato aggiornato dall'Autore...
Grazie, OldSparky!
eNjoy
Chi ha intendimento conti il numero della Bestia, perché è un numero d'uomo; e il suo numero è...
rw-rw-rw-