Asterisk. MP3 for Music on hold (moh)

In this article, I will provide an example of setting up MP3 for Music on hold (moh) in Asterisk.

First, let’s install a console mp3 player, for example mpg123 in Ubuntu:

apt update
apt install mpg123

On CentOS like this:

yum install mpg123

Let’s open the configuration file in a text editor:

nano /etc/asterisk/musiconhold.conf

Find the default class and comment out two standard lines, and after them add three new lines:

[default]
;mode=files
;directory=moh
mode=custom
directory=/var/lib/asterisk/mohmp3
application=/usr/bin/mpg123 -q -r 8000 -f 8192 -b 6048 --mono -s

Create a directory and copy mp3 files into it:

mkdir /var/lib/asterisk/mohmp3
cp /home/ixnfo/*.mp3 /var/lib/asterisk/mohmp3/
chown -R asterisk:asterisk /var/lib/asterisk/mohmp3

Open the asterisk console and apply the changes to the musiconhold.conf file:

asterisk -rvvv
moh reload

Done, now you can call any number, put it on hold and check your mp3 music.

See also my article:
Asterisk. Music on hold

Leave a comment

Leave a Reply