Converting recordings to MP3 before sending to Bitrix24

If you don't want to go into details, contact us. We will quickly help you and answer all questions! Contact us in any convenient way.

We recommend converting call recording files to MP3 format before sending to Bitrix24. This will allow you to:

  • Save space on Bitrix24 drive;

  • Listen to recordings using the built-in Bitrix24 player.

To configure customization, you should enable it in the Connector settings.

You have to implement the following customization to convert recordings (this code is already written in customization file, you should just remove the commenting symbols */ )

Edit file /opt/itgrix_bx/customizer/actions/process_record_file_path.php.

$callId = $params['call_id']; $from = $params['from']; $to = $params['to']; $path = $params['path'];

/* Пример конвертации записей разговоров в mp3 */ extract(pathinfo($path));

if ($extension === 'wav' && file_exists($path)) {

$newPath = "{$dirname}/{$filename}.mp3";

$command = "lame -h -b 192 '{$path}' '{$newPath}'";

exec($command, $_, $exitCode);

if ($exitCode === 0) {

$newBasename = basename($newPath);

mysqli_query(getDB(), "UPDATE `cdr` SET `recordingfile` = '{$newBasename}' WHERE `recordingfile` = '{$basename}'");

unlink($path);

$path = $newPath;

} else {

return array(

'state' => 'error',

'data' => "Ошибка конвертации: {$exitCode}",

);

}

}

/**/

return array(

'state' => 'success',

'data' => array(

'path' => $path,

),

);

This code assumes that you have the lame in the system installed. If you don't have it, you need to install it with any available package manager:

yum install lame

IMPORTANT: The code updates the data about the path to recording in the recordingfile field of the CDR table. Please note that any changes must be carried out by an experienced developer and take into account the specifics of your system.

If you need to save the original file and not update the data in the CDR table, you can search for the converted file when requesting for a record, and convert the recording only if it is not created:

$callId = $params['call_id'];

$from = $params['from'];

$to = $params['to'];

$path = $params['path'];

/* Пример конвертации записей разговоров в mp3 */

extract(pathinfo($path));

$newPath = "{$dirname}/{$filename}.mp3";

if (file_exists($newPath)) {

$path = $newPath;

} else if ($extension === 'wav' && file_exists($path)) {

$command = "lame -h -b 192 '{$path}' '{$newPath}'";

exec($command, $_, $exitCode);

if ($exitCode === 0) {

$path = $newPath;

} else {

return array(

'state' => 'error',

'data' => "Ошибка конвертации: {$exitCode}",

);

}

}

/**/

return array(

'state' => 'success',

'data' => array(

'path' => $path,

),

);

With this approach, additional MP3 recordings will be created, which will take up additional space on the Asterisk server. Input / output parameters are described in detail in this article.

Last updated