Pagine

sabato 14 agosto 2010

Script per convertire vari formati audio in mp3

GNU/Linux offre diverse soluzioni per convertire i file audio da un formato ad un altro.

Riporto uno script molto semplice, per la conversione di vari formati audio nel formato mp3, che può essere utile:
NB: verificate ed eventualmente aggiornate il corretto nome di GStreamer (nel mio caso gst-launch-0.10)
#!/bin/bash

GSTLAUNCH=gst-launch-0.10
ENCODER=lame
#ENCODEOPTIONS=preset=1001 quality=0
ENCODEOPTIONS=-h -b 160
INPUTEXTENSION=$1
OUTPUTEXTENSION=mp3

INPUTFILES=`find $2 -iname *.$INPUTEXTENSION -printf %p\"`

usage() {
echo "Usage is $0 "
echo "$0 will transcode all files with the specified extension"
echo "in the directory, and all subdirectories"
echo
echo "Example: "
echo "$0 m4a Music"
echo "Will convert all the *.m4a files in the ./Music directory"
echo "and all it's subdirectories to .mp3 files"
}

if [[ $# != 2 ]] ; then
usage ;
exit ;
fi

for INPUT in $INPUTFILES ;
do OUTPUT=`echo $INPUT | sed s/.$INPUTEXTENSION/.$OUTPUTEXTENSION/` ;
echo "Converting \"$INPUT\" to \"$OUTPUT\"" ;
$GSTLAUNCH filesrc location=\"$INPUT\" ! decodebin ! \
$ENCODER $ENCODEOPTIONS ! filesink location=\"$OUTPUT\" ;
done

Nessun commento:

Posta un commento