Convert call recordings to mp3 - Elastix 2.5 (FreePBX 2.11)

  • Tutorial

In this article I will give a small description of how to save recordings of conversations in mp3 format but with the extension .wav, thereby reducing the size of files and retaining the ability to listen to files from the control panel (file names will not change). And also I will give a couple of tips on how to reduce the load on the disk subsystem, getting rid of unnecessary logs (with a loaded system, the load reduction is quite noticeable).

In older versions, recording files were stored by default in one folder, thereby creating problems with a large number of them. In Elastix 2.5, they switched to FreeBPX 2.11, and there, as you know, telephone recordings are laid out in folders for every day.
Accordingly, the variables (added) for use with the script for converting records after the call have changed (added).

Moreover, in older versions, the “Run after record” parameter could be added directly through the Elastix control panel, in the “General Settings” section. In the new version, in order to add this parameter (by the way, the parameter also changed its name - “Post Call Recording Script”), you need to use the FreePBX control panel.

So, the bottom line: we will convert the file after the conversation to mp3 using lame, then, using ffmpeg we will add the header to the recording file and change the extension back to .wav. As a result, everything will remain unchanged for the system itself, however, the size of the stored files will significantly decrease, in my estimation, by 7-10 times.

First of all, you need to install ffрmpeg and lame packages on the system:
# rpm -Uhv http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el5.rf.x86_64.rpm
# yum --disablerepo=commercial-addons install ffmpeg lame


The parameter --disablerepo = commercial-addons is necessary because, in the commercial-addons repository, there is a ffmpeg package that does not suit us.

Create a folder for our script:
# mkdir -p /etc/asterisk/scripts; chown asterisk. /etc/asterisk/scripts


We take the script with github:
# wget https://raw.githubusercontent.com/andrey0001/fpbx-elastix/master/mixmon-mp3-2.sh -O /etc/asterisk/scripts/mixmon-mp3-2.sh


Set file permissions
# chown asterisk. /etc/asterisk/scripts/mixmon-mp3-2.sh
# chmod a+x /etc/asterisk/scripts/mixmon-mp3-2.sh


The repository itself on github .

We execute the visudo command and add to the end of the file:
asterisk ALL = NOPASSWD: /bin/nice
asterisk ALL = NOPASSWD: /usr/bin/ionice
asterisk ALL = NOPASSWD: /bin/chown

asterisk ALL = NOPASSWD: / bin / chmod
asterisk ALL = NOPASSWD: / bin / rm
asterisk ALL = NOPASSWD: / bin / touch


Now, we have completed all the necessary actions in the console, and we can safely proceed to the FreePBX control panel:
Go to the section “Settings -> Advanced Settings” and turn on 2 parameters (Display Readonly Settings, Override Readonly Settings)


Apply the changes. We now have the opportunity to edit additional parameters.
In the “Post Call Recording Script” parameter, insert the value:

/etc/asterisk/scripts/mixmon-mp3-2.sh ^{YEAR} ^{MONTH} ^{DAY} ^{CALLFILENAME} ^{MIXMON_FORMAT} ^{MIXMON_DIR}

In the “Override Call Recording Location” parameter, insert the value:

/var/spool/asterisk/monitor/


We apply all the changes.
That's it, now all the records of telephone conversations, after the conversation, will be converted to mp3 format, with the extension .wav saved.

For older versions, the script file is mixmon-mp3.sh , and the parameter is “Run after record”:

/etc/asterisk/scripts/mixmon-mp3.sh ^{MIXMON_DIR} ^{CALLFILENAME} ^{MIXMON_FORMAT}


And yet, before you turn it all on, you will undoubtedly want to convert your existing telephone conversations. To do this, conv.sh script file and run the command from the console:
find /var/spool/asterisk/monitor/ -name '*.wav' -exec ./conv.sh {} \;

The process is not fast.

Now, when you listen to the recording files, the format will be mp3 - pay attention to the picture:


As for the logs:
By default, Elastix writes full logs, and puts the CDR in three places (mysql, sqlite and csv file):
/ etc / asterisk /logger.conf and its attendant, leave only:
console => notice, warning, error
/etc/asterisk/cdr.conf and its attendant, leave only an entry in mysql.

That's all!

Good luck with the settings.

UPD : according to the comment , removed sudo from the script. Add via visudo nice enough, ionice and chown

Also popular now: