[asterisk-users] recording in mp3

Dave Platt dplatt at radagast.org
Wed Jul 2 12:54:18 CDT 2014


> Problem with this is client needs to listen to the call recordings and my interface will only display .wav or .mp3 so they will moan if they have to wait until the next day for today's recordings

If you're up to writing a bit of shell script, and are running
on Linux, you could automate the conversion process so that it
happens as soon as the recording is completed.

Look at the "inotify" system service (man section 7) and the
"inotifywatch" program.  You can tell inotifywatch to monitor
files being written into a specific directory (or set of
directories) and output a series of events when files in this
directory are open or closed.

What you'd probably want to do, is catch the "close_write"
events (a file has been closed, and it had been opened in
a mode which allows it to be written).  When you see a
close_write event for a recording file of the sort that
Asterisk writes, you'd check to see if it's been converted
to your desired format yet.  If not, fire off a separate
task (e.g. via "batch") to convert it.

Here's a very simple script I did to do something like this...
run a periodic-processing script a few seconds after files
with a specific name pattern have been touched in any way.
It's not sophisticated enough to look only for close or
close_wait events, but it should give you the idea.

#!/bin/bash

function processevents () {
 action=0
 while true ; do
   if [ $action == 0 ] ; then
       timeout=300
   else
       timeout=5
   fi
   read -t $timeout event
   if [ $? != 0 ] ; then
      action=0
      /data/soundchaser/periodic
   else
      if [[ $event =~ ".wav" || $event =~ ".gotit" ]] ; then
	  action=1
      fi
   fi
 done
}

cd /data/soundchaser

inotifywait -m /data/soundchaser/public_html/done | processevents




More information about the asterisk-users mailing list