Discussion: Monitor setup sample

Comments Filter

This was helpful.

I've been trying to figure out a way to accomplish this. Appreciate the help.

by vsod, Tuesday 17 of June, 2014 (16:14:58 UTC)
Re: Working example of recording outbound sip calls.

In Asterisk@home, you might need to "yum install gcc-c++" before compiling lame

by lhgomes, Wednesday 05 of April, 2006 (14:53:19 UTC)
Re: does this work with channel sip ?

Did you read the comments?

by Tommy13v, Tuesday 30 of August, 2005 (19:41:45 UTC)
Working example of recording SIP inbound calls (and convert to MP3!)

First off, Monitor() should work with any technology, not just SIP.
Requires: soxmix (from sox distribution) and L.A.M.E.

exten => 2,1,Answer
exten => 2,2,Wait,1
exten => 2,3,SetVar(MONITOR_EXEC=/pbx/bin/soxmixmp3.sh)
exten => 2,4,SetVar(CALLFILENAME=pbx/recordings/${TIMESTAMP})
exten => 2,5,Monitor(wav|${CALLFILENAME}|mb)
exten => 2,6,Dial(SIP/100)
exten => 2,7,Hangup

/pbx/bin/soxmixmp3.sh :

  1. ! /bin/bash
outputfile=`echo $3 | sed s/\.wav$/\.mp3/`
/usr/local/bin/soxmix $1 $2 $outputfile
rm $1 $2


Make sure that your sox/soxmix has MP3 encoding support, by executing "soxmix -h". If you have mp3 support, you will see it listed in the supported filetypes. If soxmix says mp3 (readonly), your version of sox was compiled without lame mp3 encoder support.

On my debian system I had to download the lame mp3 encoder source, compile and install, then download sox source, compile and install. The "apt-get install sox" version of sox doesn't include lame mp3 encoding support.

1. Download L.A.M.E. from:

2. Download sox form:

3. Extract lame, then ./configure ; make ; make install

4. Same for sox.

note: on current debian unstable, you might need to "apt-get install g++" before compiling lame or sox, I had c pre-processor (cpplus1) problems after upgrading some debian packages to current, including gcc, installing g++ resolved it.

by mh720, Friday 04 of February, 2005 (23:55:11 UTC)
Working example of recording outbound sip calls.

This is currently running on my asterisk box, and works very well.
Any abound call with the prefix of 8 is recorded.

;Setup variable for the directory
exten => _8.,1,SetVar(DIREC=/var/spool/asterisk/monitor)

;Setup the variable for the filename

;Start recording
exten => _8.,3,Monitor(gsm,${CALLFILENAME})

;Dial the number via sip provider
exten => _8.,4,Dial(SIP/${EXTEN:1}@sipproxy.pipecall.com,60,t)

;Clean up after outbound calls which have been recorded.
; Combines the two files from asterisk and makes into one audio file.
exten => h,1,System(/usr/bin/soxmix ${DIREC}/${CALLFILENAME}-in.gsm ${DIREC}/${CALLFILENAME}-out.gsm ${DIREC}/${CALLFILENAME}.gsm)

;Remove the two files which we have converted to one.
exten => h,2,System(rm ${DIREC}/${CALLFILENAME}-in.gsm ${DIREC}/${CALLFILENAME}-out.gsm)

You will need soxmix compiled to do the combine of the two audio files.

After you have hung up, you will land up with one audio file of the conversation which has a file name that has the number dialed in it, the extension making the call and the time date stamp.

Bare in mind that the timestamp is different than the one in cdr log as the timestamp on the file is the time at the begining of the call and not the end, as it is in cdr. If you minus duration of the call from the timestamp in cdr you will get the timestamp on the audio file.

by , Friday 05 of November, 2004 (12:12:08 UTC)
soxmix. not somix

Obviously a typo.
It is soxmix not somix as originally stated.

by , Wednesday 27 of October, 2004 (20:12:10 UTC)
Yes, soxmix

From man sox:

sox infile outfile
soxmix infile1 infile2 outfile
soxmix is functionally the same as the command line program sox
expect [sic] that it takes two files as input and mixes the
audio together to produce a single file as output. It has a
restriction that both input files must be of the same data
type and sample rates.

This is simply another way to call sox. If you do not see this
option in your distribution, try upgrading sox.

by , Friday 15 of June, 2012 (06:50:06 UTC)

I have no idea what "somix" is. I know what, and have used "sox" for ages. The page above points to "sox", not "somix", and a search on the main "sox" page does not show anything called "somix".

If people are referring to sox, a common application, then please call it what it's page, and the application are called. "Sox", not "somix". If people are referring to "somix", which I can't find, then please point it to the somix page, or to the part of the Sox page that talks about somix...


by , Wednesday 29 of September, 2004 (01:04:24 UTC)
Doesn't seem to work if called from an AGI Script

I set up the example as shown and it works for a phone dialing 8 then the number, but when called by a dial command from an agi script it stops working.
The only difference I see is that there is an extra answer on the console.
Any ideas?

by , Sunday 12 of September, 2004 (19:45:29 UTC)
does this work with channel sip ?

Does this work with voip protocols, liike SIP ?

by usear, Monday 30 of August, 2004 (21:52:06 UTC)