• Home
  • Sangoma Solutions
    • PBXact IPPBX
    • FreePBX IPPBX
      • The FreePBX Appliance
      • FreeHMS Hotel PMS
    • Sangoma Phones
    • Vega gateways
    • Zulu UC
    • Asterisk
  • Hardware & Phones
    • IPPBXs
      • Sangoma PBXact
      • FreePBX
        • Freepbx 60
        • Freepbx 100
        • Freepbx 300
        • Freepbx 1000
        • Sangoma Phones
      • Building FreePBX CallCenters
    • Voip Handsets
      • Sangoma System Handsets
      • Gigaset Pro
        • Gigaset Maxwell C DECT Desk Phone
        • Gigaset Pro R650H
        • Gigaset A540
        • Gigaset N720 IP PRO
      • Conference Phones
        • CP920 Conference Phone
        • CP960 Conference Phone
    • Headsets
    • Peripherals
    • Vega VoIP digital gateways
  • Lines & Support
    • Connectivity
      • Calls and Lines
        • Call charges and Bundles.
      • Fibre
      • EFM
      • FTTC
    • Support Contracts
      • Maintenance Terms & Conditions
    • System Monitoring
    • Submit Ticket
    • My Tickets
    • Number Porting
      • Porting Help
    • Case Studies
    • Major Fault Reports
  • Knowledge Base
    • Asterisk Support
    • Security
    • Knowledge Base
  • Contact
    • Invoice Payments
    • Your Rights under GDPR
    • Privacy Policy
  • Submit Support Ticket
  • Offers

Converting recordings to MP3 in Elastix and updating mysql CDR records



In Elastix 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, In Elastix 2.5  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.

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

#!/bin/bash
user=USER
password=SECRET
mysql -u$user -p$password -s -N -D asteriskcdrdb<<<"select recordingfile from cdr where recordingfile LIKE '%.wav' AND calldate >= DATE_SUB(NOW(), INTERVAL 70 MINUTE)" > tmp_query
date >> /var/log/asterisk/mp3.log
while read pcmwav
do
mp3="$(echo $pcmwav | sed s/".wav"/".mp3"/)"
nice lame -b 16 -m m -q 9-resample  "$pcmwav" "$mp3"
touch -r "$pcmwav" "$mp3" >> /var/log/asterisk/mp3.log
mysql -u$user -p$password -s -N -D asteriskcdrdb<<<"UPDATE cdr SET recordingfile='$mp3'  WHERE recordingfile = '$pcmwav'"
echo $pcmwav >> /var/log/asterisk/mp3.log
echo "--------||-------" >> /var/log/asterisk/mp3.log
done < tmp_query
date >> /var/log/asterisk/mp3.log
echo "Done" >> /var/log/asterisk/mp3.log
echo "--------||-------" >> /var/log/asterisk/mp3.log
exit 1

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

Share this:

  • Click to share on Twitter (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Facebook (Opens in new window)
  • Click to share on Google+ (Opens in new window)
Elastix Support, Knowledge Base, Support    Asterisk, cdr, centrex, Elastix, freePBX, mysql, smdr, support, Technical
Similar posts
  • Gigaset N870IP DECT — The Gigaset N870 Multicell System is an innovative break...
  • CP920 Conference Phone — Yealink designs its audio conferencing solutions to suit...
  • CP960 Conference Phone — The Yealink CP960 is an enterprise-grade conference phon...
  • Gigaset A540 — A functional phone for those who value good design. T...
  • Gigaset Pro R650H — When working outdoors or in dusty, wet and other harsh l...
← Multiple Dynamic features with Asterisk Applicationmaps
One way audio with Yealink T23 and Gamma Sip trunks on Freepbx →
Sangoma

Links

  • Gradwell Account
  • Asterisk Forum
  • FreePBX Forum
  • FreePBX WIKI
  • IT Store
  • Blog
TunnelBear
Remote Access with TeamViewer choose "TeamViewer QuickSupport" when page loads
Yealink Reseller

Top Posts & Pages

  • Gigaset Maxwell C DECT Desk Phone  The DECT cordle…
  • Fortigate issues such as one way audio on Call Pickup With Hosted Asterisk and other problems.
  • ISDN alarms and what they mean.
  • IAX2 Peers going unreachable.
  • Gigaset N870IP DECT
  • Converting recordings to MP3 in Elastix and updating mysql CDR records
  • Simple Script to import Asterisk Database entries
  • Using Gmail to send Voicemail emails
  • 24x7 Asterisk server monitoring with Nagios.
  • Xorcom Astribank
2018 Cyber-Cottage.co.uk

EvoLve Pro theme by Theme4Press  •  Powered by WordPress
Sangoma, FreePBX and VoIP sales and support

Back to Top
This website uses cookies
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish.Accept Reject Read More