Timothy Smith
2011-Mar-03 05:20 UTC
[asterisk-users] Converting MP3 files to wav for Asterisk
Hi, I am running a service where I play full songs but MP3 files kept on crashing my server. I resorted to wav but the quality is really poor after converting..or even sometimes not audible at all! Do you guys know of a better way I can convert mp3 to wav and restore quality? Below is the script I am using, I also tried the steps at http://www.voip-info.org/wiki/view/Convert+WAV+audio+files+for+use+in+Asterisk but it wasnt any better. ---------------------------- #!/bin/bash for i in `ls $1/*mp3` do lame -a $i $i.wav mplayer -quiet -vo null -vc dummy -ao pcm:waveheader:file="$i.h.wav" $i.wav sox $i.h.wav -t raw -r 8000 -s -2 -c 1 `echo $i|sed "s/.mp3/.sln/"` done ----------------------------- Any thoughts please? Regards, Tim
Thorsten Göllner
2011-Mar-03 07:45 UTC
[asterisk-users] Converting MP3 files to wav for Asterisk
Try to convert into gsm instead wav. sox test.wav -r 8000 -c1 test.gsm Am 03.03.2011 06:20, schrieb Timothy Smith:> Hi, > > I am running a service where I play full songs but MP3 files kept on > crashing my server. I resorted to wav but the quality is really poor > after converting..or even sometimes not audible at all! Do you guys > know of a better way I can convert mp3 to wav and restore quality? > Below is the script I am using, I also tried the steps at > http://www.voip-info.org/wiki/view/Convert+WAV+audio+files+for+use+in+Asterisk > but it wasnt any better. > > ---------------------------- > #!/bin/bash > for i in `ls $1/*mp3` > do > lame -a $i $i.wav > mplayer -quiet -vo null -vc dummy -ao pcm:waveheader:file="$i.h.wav" $i.wav > sox $i.h.wav -t raw -r 8000 -s -2 -c 1 `echo $i|sed "s/.mp3/.sln/"` > done > ----------------------------- > > Any thoughts please? > > Regards, > Tim > > -- > _____________________________________________________________________ > -- Bandwidth and Colocation Provided by http://www.api-digital.com -- > New to Asterisk? Join us for a live introductory webinar every Thurs: > http://www.asterisk.org/hello > > asterisk-users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users >-- Thorsten G?llner OVM Office Voice Media GmbH Herderstrasse 68 40237 D?sseldorf Tel.: +49(0)211 / 618 57 53 Fax: +49(0)211 / 618 57 54
Steve Edwards
2011-Mar-03 16:19 UTC
[asterisk-users] Converting MP3 files to wav for Asterisk
On Thu, 3 Mar 2011, Timothy Smith wrote:> Do you guys know of a better way I can convert mp3 to wav and restore > quality?You can't restore quality lost by converting to MP3. You shouldn't be 'losing' quality by converting from MP3 to WAV.> ---------------------------- > #!/bin/bash > for i in `ls $1/*mp3`Using "for i in $1/*mp3" will save creating a process.> do > lame -a $i $i.wavLame is an MP3 encoder. Specifying '.wav' doesn't create a WAV encoded file, just a 'single channel' (because of '-a') MP3 encoded file with '.wav' tacked on the end of the file name.> mplayer -quiet -vo null -vc dummy -ao pcm:waveheader:file="$i.h.wav" $i.wav > sox $i.h.wav -t raw -r 8000 -s -2 -c 1 `echo $i|sed "s/.mp3/.sln/"`Using "sox $i.h.wav -t raw -r 8000 -s -2 -c 1 ${i%.mp3}.sln" will save creating a process.> done > -----------------------------I tried your commands converting an old Pink Floyd track and it sounded about as good as I would expect. Try something 'simpler' mpg123 -q -w "${TEMP}" "${INPUT}" sox "${TEMP}" -c 1 -s -w -r 8000 "${OUTPUT}" and see if that helps. Otherwise, how do the 'intermediate' files in your process sound? Can you hear when things fall apart? If you post a link to a sample input file and a 'degraded' output file, this may provide more clues. -- Thanks in advance, ------------------------------------------------------------------------- Steve Edwards sedwards at sedwards.com Voice: +1-760-468-3867 PST Newline Fax: +1-760-731-3000