Categories
Elastix Support Knowledge Base Support

Converting recordings to MP3 in FreePBX and updating mysql CDR records

In FreePBX users can listen to wav file recordings via the “Call Recordings” tab, This uses a field in the mysql cdr table to say where that recording is and what its called, They are now stored in year/month/day directory structure under /var/spool/asterisk/monitor so if the end user wants the recordings in mp3 format as many do its not just a case of converting them its also a case of updating the database.

Luckily this is fairly straight forward, its just a case of doing a quick query and then converting the file and the updating the database. First you have to install lame, This can be done simply with yum then write a script.

In FreePBX advanced settings, you need to enable “Display” and “Override” readonly settings and then add

/usr/local/sbin/postrecord.sh ^{CDR(linkedid)} to “

The script I use is simple with a bit of basic logging.

#!/bin/bash
. postrecconfig.sh
date >> /var/log/asterisk/mp3.log
pcmwav=$(mysql -u$user -p$secret -s -N -D asteriskcdrdb<<<"select recordingfile from cdr where linkedid LIKE '$1' AND disposition = 'ANSWERED'  ORDER by calldate DESC LIMIT 1");
mp3="$(echo $pcmwav | sed s/".wav"/".mp3"/)"
nice lame -b 16 -m m -q 9-resample  "$path$pcmwav" "$path$mp3" >> /var/log/asterisk/mp3.log
touch -r "$path$pcmwav" "$path$mp3" >> /var/log/asterisk/mp3.log
mysql -u$user -p$secret -s -N -D asteriskcdrdb<<<"UPDATE cdr SET recordingfile='$mp3'  WHERE recordingfile = '$pcmwav'" >> /var/log/asterisk/mp3.log
echo $pcmwav >> /var/log/asterisk/mp3.log
echo "--------||-------" >> /var/log/asterisk/mp3.log
date >> /var/log/asterisk/mp3.log
echo "Done" >> /var/log/asterisk/mp3.log
echo "--------||-------" >> /var/log/asterisk/mp3.log
exit 1

The postrecconfig.sh file looks like

user=freepbxuser
secret=secret
receptemail=info@youremailaddress.com
file_age=35
dy=$(date '+%Y')
dm=$(date '+%m')
dd=$(date '+%d')
path=/var/spool/asterisk/monitor/$dy/$dm/$dd/



As can be seen it steps through entry by entry converting and updating the DB, This example is cron'd to run hourly but does not delete the original wav file, this would be done in a separate script run weekly to remove old files. The reason to keep them is so that a backup of the original is held for a period in case of errors.

Hope this is of help to you and your users

Categories
IPPBXs Products Services

Multi User Hosted PBX

Use the Internet to make calls – it’s simple, cost effective, and perfect for small businesses and call centres.

Voice over Internet telephony reduces telephony bills; connects mobile, remote and office workers; and gives a consolidated impression of your business – same number no matter where employees are located.

From 2 to 10 people wanting to stay in touch, Our feature-rich packages can offer a local or International number from which to operate – or you can bring your old number with you (number porting). There are also a wide range of add-ons that offer inclusive minutes. We can go through setting it up for you or you can do it yourself. To signup follow this link or call us on 01225580025

  • Multi User VoIP £8.00 per month
  • 4000 UK landline minutes £ 20.00 per month Lower amounts available
  • 4000 UK & International landline minutes £25.00 per month
  • 500 UK mobile minutes £30.00 per month

*Prices exclude VAT.

Key features

An online customer control panel allows you to manage your own account, and you can expand the system when ever you need to. All you need to get started is broadband, a router, and an adapter or a VoIP phone.

  • Make immediate savings: Free internal calls. Competitively priced calls and inclusive landline and mobile minutes package add-ons.
  • Quick and easy to set up: No difficult installations.
  • Excellent call quality: With no compromising on functionality.
  • Never be out of touch: Call forwarding available.
  • Keep your old number: Seamless transition with ‘number porting’.
  • Global presence: International numbers available.
  • Stay in control: Online customer administration, call logs and invoicing.
  • Voicemail and voicemail notification
  • Call forwarding to any number including mobiles
  • Online contacts directory, call logs and invoicing
  • Customised CLI (caller line identity)
  • Time of day routing

 

Features

  • Set up £4.99
  • Monthly £8.00
  • Included phone number UK and International*
  • Concurrent calls per number 2
  • Internal extensions 10
  • Call packages FREE VoIP-to-VoIP
  • 999 Emergency Services access YES
  • Minimum contract length 12 months
  • Voicemail YES
  • Voicemail notification SMS or Email
  • Call forwarding YES
  • Codecs supported G729a, G711u, G711a
  • Online call logs and invoicing YES
  • Online contact directory YES
  • Customised CLI (caller line ID) YES
  • Time of day routing YES
  • Audio call conferencing YES
  • IVR/Auto-attendant YES
  • Music on hold YES
  • Hunt call groups YES
  • 4000 UK landline minutes add-on £20.00 per month
  • 4000 UK & Int. min. add-on £25.00 per month
  • 500 UK Mobile minutes add-on £30.00 per month
  • Additional Number^^ £3.00 per month
  • Personal Number** £10 setup, £10 per month

* Surcharges apply for International numbering.

^ Subject to fair use check at 4000 minutes per month.

^^ Can only point at a Gradwell VoIP number on the same account, they can act as a mainline phone number however they must take an existing route. Please note that they cannot be used to increase concurrent calls.

** Can only point directly at an extension number. You cannot direct these numbers towards hunt groups, call queues or any other type of functionality. Does not provide an additional line.

All phone services (inc Unlimited packages) are subject to Terms and Conditions and standard call charges. All prices exclude VAT. Range of hardware and accessories available.