• Home
  • Asterisk
    • Asterisk Support
  • FreePBX
    • FreePBX
    • FreeHMS , web based call management package for small Hotels
  • Special Offers
  • Products
    • IPPBXs
      • FreePBX
        • Freepbx 60
        • Freepbx 100
        • Freepbx 300
        • Freepbx 1000
        • Sangoma Phones The Best Phone for FreePBX
        • Building FreePBX CallCenters
      • OpenVox
        • OpenVox IX132
        • OpenVox IX210
    • Handsets
      • Sangoma
      • Yealink
      • Gigaset
        • Gigaset N720 IP PRO
      • Snom
    • Headsets
    • Gateways
      • Vega VoIP digital gateways
      • Digium
    • Peripherals
    • Calls and Lines
      • Call charges and Bundles.
    • Connectivity
      • Fibre
      • EFM
      • FTTC
    • QueueMetrics
      • QueueMetrics
        • QueueMetrics Support
  • Case Studies
  • Knowledge Base
    • Security
    • Knowledge Base
    • Software Releases
    • FIrmware releases
  • Support
    • System Status
    • Submit Ticket
    • My Tickets
    • Support Contracts
    • Number Porting
      • Porting Help
  • System Monitoring
  • Contact

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
  • Connecting to Serial console ports wi... — Many devices and servers still require connection to them...
  • Zoiper Account and Server configurati... — Enter details below to create Zoiper QR code that can be ...
  • Zulu UC – The Ultimate Desktop and So... — Zulu UC Desktop and softphone integration unifies the mos...
  • Vega VoIP digital gateways — The Most Resilient VoIP Digital Gateways in Their Class V...
  • Gigaset N720 IP PRO — The Gigaset N720 IP PRO Base Station is part of the Gigas...
← Multiple Dynamic features with Asterisk Applicationmaps
One way audio with Yealink T23 and Gamma Sip trunks on Freepbx →
Sangoma

Links

  • IT Store
  • Submit Ticket
  • Gradwell Account
  • Asterisk Forum
  • FreePBX Forum
  • Speed Test
  • Blog
  • Paypal Payments
TunnelBear
Remote Access with TeamViewer choose "TeamViewer QuickSupport" when page loads
Yealink Reseller

Top Posts & Pages

  • Fortigate issues such as one way audio on Call Pickup With Hosted Asterisk and other problems.
  • 24x7 Asterisk server monitoring with Nagios.
  • Cyber-cottage provide Support, Design and Installa…
  • FreeHMS , web based call management package for small Hotels
  • Multiple Dynamic features with Asterisk Applicationmaps
  • Voice recognition and Asterisk.
  • Running a Macro on answer for Asterisk queues.
  • IAX2 Peers going unreachable.
  • ISDN alarms and what they mean.
  • Asterisk

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

Back to Top
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 Read More