📜 ⬆️ ⬇️

Convert conversations to mp3 - Elastix 2.5 (FreePBX 2.11)


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

In older versions, the record files were stored by default in the same folder, creating problems with a large number of them. In Elastix 2.5, we switched to FreeBPX 2.11, and there, as we know, telephone recordings are arranged in folders for each day.
Accordingly, the variables have been changed (added) for use with the script for converting records after the call.

Moreover, in older versions, it was possible to add the “Run after record” parameter 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 the name - “Post Call Recording Script”), you need to use the FreePBX control panel.
')
So, what's the point: we will convert the file after talking into mp3 format 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, but the size of the stored files will be significantly reduced, in my opinion, by 7-10 times.

The first step is to install the ffpmpeg 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 package ffmpeg, which does not suit us.

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


Taking the script from 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 .

Run the visudo command and add it 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 move on to the FreePBX control panel:
Go to the “Settings -> Advanced Settings” section and enable 2 parameters (Display Readonly Settings, Override Readonly Settings)


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

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

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

 /var/spool/asterisk/monitor/ 


Apply all changes.
Everything, now all the recordings of telephone conversations, after the conversation, will be converted into mp3 format, with the extension of the extension .wav.

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

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


And yet, before you turn it all on, there is no doubt that you will want to convert your phone call records. For this, the script file conv.sh 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 record 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 attendants, leave only:
console => notice, warning, error
/etc/asterisk/cdr.conf and its attendants, leave only an entry in mysql.

That's all!

Good luck in the settings.

UPD : for comments , removed sudo from the script. Add via visudo enough nice, ionice and chown

Source: https://habr.com/ru/post/258583/


All Articles