Tuesday, August 21, 2012

Asterisk Call Recording Monitor() vs MixMonitor()

I'm rewriting some call recording code today.

Previously I used Monitor() Now I'm using MixMonitor()

My old code looked something like this:


exten => _nxxxxxx,1,Set(CALLFILENAME=/var/spool/asterisk/monitor/${CDR(accountcode)}-${EXTEN}-${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)})
exten => _nxxxxxx,n,Set(MONITOR_EXEC_ARGS=${peeremail} ${EXTEN} ${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)})
exten => _nxxxxxx,n,Set(MONITOR_EXEC=mymix)
exten => _nxxxxxx,n,Monitor(wav,${CALLFILENAME},m)

New code looks like:

exten => _nxxxxxx,1,Set(CALLFILENAME=/var/spool/asterisk/monitor/${CDR(accountcode)}-${EXTEN}-${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}.wav)
exten => _nxxxxxx,n,MixMonitor(${CALLFILENAME}|b|/usr/sbin/wav2mp3 ${CALLFILENAME} ${peeremail} ${EXTEN} ${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)} email)

Switching to MixMonitor saves me from having to manually mix the two call legs together with SOX before converting to MP3.

I was also having a problem with calls that were Parked, With Montior() the two call legs would be different lengths causing the final mp3 file I emailed to be a confusing as you would hear one party responding to the other parties yet unasked questions and then you would hear the question get asked by the second party.