Monday 19 September 2011

MP3 to SLN format Conversion


Nowadays, huge resources of sound file on mp3 format can be easily downloaded from internet.  The objective of these simple guide is to convert an mp3 file format to an Asterisk sound file format which consumes lesser amount of CPU resources.

There are two essential tools that converts MP3 file to an SLN file format which asterisk can play with without consuming huge CPU resources.  Following are the packages/tools tested on Centos linux with a brief description. 

1.       mpg123
mpg123 is a real time MPEG 1.0/2.0/2.5 audio player/decoder for layers 1,2 and 3 (MPEG 1.0 layer 3 aka MP3 most commonly tested)    

2.       sox
SoX is a cross-platform (Windows, Linux, MacOS X, etc.) command line utility that can convert various formats of computer audio files in to other formats. It can also apply various effects to these sound files, and, as an added bonus, SoX can play and record audio files on most platforms.

Download Links:

For Linux mpg123

http://sourceforge.net/projects/mpg123/files/mpg123/1.13.4/mpg123-1.13.4.tar.bz2/download

Download the source from the above link and copy to your linux machine.  Unzip and extract the file using linux bzip2 and tar utility.  Next, perform the following;

./configure, make, make install, make clean

Check for any error while installing mpg123 perhaps any dependencies needs to be installed prior on installing mpg123


Download sox for Linux:

http://sox.sourceforge.net/

Alternatively, installing sox using yum repository is pretty much simpler without worrying for dependencies package.  Don’t shake your head and give it a try using yum.

File conversion procedures:
On Centos:

First convert the MP3 file to a WAV file:
# mpg123 –w ABC.wav ABC.mp3

 Then, down sample the resulting WAV file to a sampling rate that Asterisk understand
# sox ABC.wav –t raw –r 8000 –s  –c 1 ABC.sln

Then, copy the SLN file to the desired directory
#cp *.sln /var/lib/asterisk/moh folder

As an option, SLN file can be place on different path other than /var/lib/asterisk/moh folder however bear in mind that it needs to be correctly define on asterisk dialplan.


In addition on the above guide,  mp3 files can be downloaded freely on these link http://www.jamendo.com

Jamendo is the world's #1 platform for free and legal music downloads. Available in seven languages, it offers the largest catalog of music under Creative Commons licenses. For artists, it's an easy and efficient way to publish, share and promote their music, and also to make money, through ad revenue sharing and commercial partnerships

No comments:

Post a Comment