magno_braz
(usa CentOS)
Enviado em 14/10/2016 - 17:51h
Aqui eu coloquei um script para converter para MP3 usando o lame
https://www.vivaolinux.com.br/contribuir/scripts/download.php?arquivo=wav_to_mp3.sh&codigo=6523
#!/bin/bash
######################################################################
#
#convert_wav_mp3.sh - Script para converter arquivos WAV em MP3 #
#
#Autor - Magno Brasil - magno@magnobr.info
#Criação - 11/10/2016 - v.1.0
#
#----------------------------------------------------------------------
#
#Esse programa é utilizado para conversão dos arquivos WAV em MP3,
#utilizando parametros do sistema ou parametros do usuario.
#
#Esse script deve ser executado 00:01 e irá converter todas as ligações realizadas
#no dia anterior
#
#OBS - Para utilizar o script de forma manual comentar as linhas 43,,44,46
#e inserir os dados nas linhas 53 e 56 e descomenta-las.
#
#
#
#Agradeço ao Eduardo Rebelo Lopes pelo script criado em 10/01/2013
#que pode ser acessado no endereço -
#
#https://www.vivaolinux.com.br/artigo/Processamento-Paralelo-em-Shell-Script-Conversao-de-Arquivos-WAV-para-MP3/
#
########################################################################
datainicial=`date +%s`
######### Verificicando se o LAME já está instalado
lame_instalado=`whereis lame`;
if [ "$lame_instalado" != "lame:" ]; then
echo -e "PPSS já instalado !!!\n\n"
else
echo -e "Instalando o PPSS !!!\n\n"
wget wget
https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/ppss/ppss-2.97.tgz
rpm -ivh lame-3.98.4-1.el6.rf.x86_64.rpm
rm -f lame-3.98.4-1.el6.rf.x86_64.rpm
echo -e "LAME instalado com sucesso!!!\n\n"
fi
######### Verificicando se o PPSS já está instalado
ppss_instalado=`whereis ppss`;
if [ "$ppss_instalado" != "ppss:" ]; then
echo -e "PPSS já instalado !!!\n\n"
else
echo -e "Instalando o LAME !!!\n\n"
wget
http://ftp.tu-chemnitz.de/pub/linux/dag/redhat/el6/en/x86_64/rpmforge/RPMS/lame-3.98.4-1.el6.rf.x86_...
tar xvzf ppss-2.50.tgz -C /usr/local/bin
chown root:root /usr/local/bin/ppss && chmod a+rx /usr/local/bin/ppss
echo -e "PPSS instalado com sucesso!!!\n\n"
fi
############################################################
#Conversão em multi-thread ou não -> 0 - sim / 1 - não
CORE=0
############################################################
#diretorio raiz das gravações
diretorio_raiz=/var/spool/asterisk/monitor
#Para executar as conversões de forma manual
#comente as linhas abaixo e coloque a data
#nos campos descritos
############################################################
#Para executar de formar automatica, não comentar
dia_atual=`date +"%d"`;
mes_ano_atual=`date +"%m-%Y"`;
let dia_atual=$dia_atual-1; #comando para a data do dia anterior
##################################################################
##################################################################
#Para executar de forma manual, descomentar e setar as datas abaixo
#Colocar o dia_atual no formato 1-31 sem o zero inicial
#dia_atual=3
#Colocar o mes_ano_atual no formato mm-YYYY, não esquecer o -
#mes_ano_atual=10-2016
##################################################################
data_atual=$dia_atual-$mes_ano_atual
diretorio_final=$diretorio_raiz/$mes_ano_atual/$data_atual
cd $diretorio_final
tamanho_diretorio=`du -hs .`
#Criando lista com os arquivos .wav
ls | grep wav > /tmp/lista_arq.txt
path_arquivo=$mes_ano_atual/$data_atual/
contador=`ls | wc | cut -d " " -f3-7`;
######################################################################################
echo -e "#Total de arquivos a serem convertidos $contador\n\n" >> /tmp/lista_arq.txt
echo -e "############################################################\n"
echo -e "Iniciando Conversão de $contador Arquivos ----- \n\n"
echo -e "############################################################\n"
cd /usr/local/bin
#Comando para realizar a conversão dos arquivos - O LAME deve estar instalado.
#O PPSS também deve estar instalado pra multi processamento
./ppss -d $diretorio_final -c 'BASENAME=`basename "$ITEM" .wav`; lame --quiet --preset insane "$ITEM" "$OUTPUT_DIR/$BASENAME.mp3"' -o $diretorio_final
cd $diretorio_final
echo -e "############################################################\n"
echo -e "Conversões realizadas com sucesso $contador --------- \n\n"
echo -e "############################################################\n"
######################################################################################
echo -e "############################################################\n"
echo -e "Removendo arquivos wav --------- \n\n"
echo -e "############################################################\n"
rm -f *.wav;
######################################################################################
tamanho_diretorio_atual=`du -hs .`;
mv /tmp/lista_arq.txt $diretorio_final/bkp
mv /tmp/atualiza.sql $diretorio_final/bkp
mv /tmp/roolback.sql $diretorio_final/bkp
mv /tmp/script_roolback.sh $diretorio_final/bkp
#######################################################################################
##################
# As linhas abaixo são para pegar os arquivos de log do PPSS e colocar na pasta da conversão
mkdir $diretorio_final/logs
mv /usr/local/bin/ppss_dir/* $diretorio_final/logs
##########################################################################
echo "####################################################################"
echo "####################################################################"
echo "## ##"
echo "## ##"
echo "## TODAS AS CONVERSÕES FORAM REALIZADAS COM SUCESSO!!! ##"
echo "## ##"
echo "## O ESPAÇO UTILIZADO ERA DE $tamanho_diretorio"
echo "## O ESPAÇO DO DIRETORIO ATUAL E DE $tamanho_diretorio_atual"
echo "## FORAM CONVERTIDOS $contador ARQUIVOS ##"
echo "## ##"
echo "## ##"
echo "####################################################################"
datafinal=`date +%s`
soma=`expr $datafinal - $datainicial`
resultado=`expr 10800 + $soma`
tempo=`date -d @$resultado +%H:%M:%S`
echo " Tempo gasto: $tempo "