Converting audio files for use with Asterisk

Asterisk only supports certain formats for playing back audio, which can be a pain. Seems like every time I try to load a new mp3 for my music on hold, I run into the same errors and generally have a devil of a time finding the answer.

First step is to convert the file to a WAV file. I've tried using mpg123 and mplayer for this task, but the results were never consistent. Ffmpeg seems to be the answer. Since ffmpeg supports every format under the sun, the gives you freedom to source from mp3, ogg vorbis, or whatever.

$ ffmpeg -i audiofile.mp3 audiofile.wav

Next, convert the WAV into the specific format that Asterisk likes.

$ sox audiofile.wav -t raw -r 8000 -c 1 audiofile.sln

If you're feeling particularly adventuresome, also generate a file for wideband audio.

$ sox audiofile.wav -t raw -r 16000 -c 1 audiofile.sln16

All that's left is to copy the SLN and SLN16 files to the appropriate location for Asterisk.

1 Comment

avconv

Word on the street is that "ffmpeg -i" is deprecated and has been replaced by "avconv -i".

Subscribe to Comments for "Converting audio files for use with Asterisk" Subscribe to zmonkey.org - All comments