Asterisk call recording macro

Joined: Thu 12 of Oct, 2006

Re: Asterisk call recording macro

Posted:Tue 17 of Feb, 2009 (20:28 UTC)
Heres how I do it... Make sure you have SOX and LAME installed

exten => _1NXXNXXXXXX,1,Set(CALLFILENAME=${EXTEN}_${STRFTIME(,,%C%y%m%d)}_${STRFTIME(,,%H%M%S)}_${CALLERID(num)})
exten => _1NXXNXXXXXX,n,Set(CALLFILEDIR=/tmp/space/)
exten => _1NXXNXXXXXX,n,Dial(SIP/${EXTEN}@fedcom)

exten => h,n,system(lame --preset voice -v -B 64 -a ${CALLFILEDIR}${CALLFILENAME}.wav /recordings/${CALLFILENAME}.mp3)
exten => h,n,system(rm ${CALLFILEDIR}${CALLFILENAME}.wav)
exten => h,n,system(rm ${CALLFILEDIR}${CALLFILENAME}-in.wav)
exten => h,n,system(rm ${CALLFILEDIR}${CALLFILENAME}-out.wav)

this works out great for me and my customers

just make sure that /tmp/space is a ramdrive if you have a lot of calls or else you will have performance issues


contact me off list if you want jayrod422 at
Joined: Mon 05 of Sep, 2005

Asterisk call recording macro

Posted:Wed 04 of Feb, 2009 (14:07 UTC)
I`m trying to create a macro to record (MixMonitor) all incoming calls automatically.

I use the example from

One Touch Recording (applicationmap) with WAV to MP3 Conversion Macro. 

extensions.conf : 

exten => s,1,GotoIf($["${XAD}" = "0" | "${XAD}" = ""]?startrec:stoprec) 
exten => s,n(startrec),Playback(startmonitor) 
exten => s,n,Set(XAD=1) 
exten => s,n,Set(FILENAME=${TIMESTAMP}-OUT${CALLERID(number)}-^-${UNIQUEID}) 
exten => s,n,Set(MONITOR_EXEC_ARGS=&& nice -n 19 /usr/local/bin/lame -b 96 -t -F -m m --bitwidth 16 --quiet "/var/spool/asterisk/monitor/${FILENAME}.wav" "/var/spool/asterisk/monitor/${FILENAME}.mp3" && rm -f "/var/spool/asterisk/monitor/${FILENAME}.wav") 
exten => s,n,Monitor(wav,${FILENAME},m) 
exten => s,n,MacroExit 
exten => s,n(stoprec),StopMonitor 
exten => s,n,Set(XAD=0) 
exten => s,n,Playback(stopmonitor) 
exten => s,n,MacroExit 

features.conf : 

apps => *9,caller,Macro,apprecord 

After hours of playing around, I still cannot figure out how to call that macro directly from a dialplan to start/stop recording and convert wav to mp3:
exten => s,n,Macro(apprecord,1) ; start recording
exten => s,n,Macro(apprecord, 0) ; stop recording

Any ideas how to do it correctly, please?

Thanks a lot,