Konwertowanie z mpc do mp3
From Nasza Pasja - Programowanie
Prostsza wersja bez zabawy mpc->wav->mp3. Konwersja z mpc od razu do mp3 przy użyciu potoków.
#!/bin/bash mppdec "$*" - | lame -p --vbr-new -V 1 -h -m s - "$*".mp3
#!/bin/sh
lame=/usr/bin/lame
mppdec=/usr/bin/mppdec
bitrate=192
echo -e "\033[1mmpc2mp3 0.3 (C) Frank Lazzarini\033[0m"
#check if mppdec is on the right place
if [ -f $mppdec ] && [ -f $lame ]
then
echo -e "mppdec found at $mppdec."
echo
echo
#running through the mpc files and convert them to wav
for mpcfile in *.mpc
do
#initialize variables
wavfile=${mpcfile%mpc}wav #replace mpc extension with wav
mp3file=${mpcfile%mpc}mp3 #replace mpc extension with mp3
echo -e "----- \033[1mProcessing $mpcfile\033[0m -----"
echo -n "Decoding mpc...";
#decode mpc file and give output to null universe
mppdec --wav --silent "$mpcfile" "$wavfile" &>/dev/null
if [ -f "$wavfile" ]
then
echo -e "\E[32;40mOk\E[37;40m"; tput sgr0
else
echo -e "\E[31;40mError\E[37;40m"; tput sgr0
exit 0;
fi
echo -n "Compressing to mp3...";
#compressing wav to mp3
lame -h "$wavfile" "$mp3file" &> /dev/null
if [ -f "$mp3file" ]
then
echo -e "\E[32;40mOK\E[37;40m"; tput sgr0
else
echo -e "\E[31;40mError\E[37;40m"; tput sgr0
exit 0;
fi
echo -n "Deleting wav file...";
if [ -f "$wavfile" ]
then
rm -f "$wavfile"
echo -e "\E[32;40mOK\E[37;40m"; tput sgr0
fi
echo -n "Deleting mpc file...";
if [ -f "$mpcfile" ]
then
rm -f "$mpcfile"
echo -e "\E[32;40mOK\E[37;40m"; tput sgr0
fi
echo -e "\033[1m---- done ----\033[0m"
done
else
if [ ! -f $mppdec ]
then
echo "Error : $mppdec not found!"
echo "Change the value mppdec to the right place of mppdec."
fi
if [ ! -f $lame ]
then
echo "Error : $lame not found!"
echo "Change the value lame to the right place of lame."
fi

