Мой пример.
[internal]
same => _XXX.,Dial(SIP/${EXTEN},60,WwtTrU(sub-mixmonitor,${CALLERID(num)},${EXTEN},${UNIQUEID}))
same => n,HangUp()
[sub-mixmonitor]
exten => s,1,Noop(------------MixMonitor---------------)
; same => n,DumpChan()
; same => n,NoCDR()
same => n,Noop(DIALEDPEERNUMBER ${DIALEDPEERNUMBER} )
same => n,Set(FILE_UNIQUEID=${ARG3})
same => n,Noop(UNIQUEID = ${FILE_UNIQUEID})
same => n,GotoIf($[${DB_EXISTS(RECORD/${ARG1})}]?go-record)
same => n,GotoIf($[${DB_EXISTS(RECORD/${ARG2})}]?go-record)
same => n,Goto(end_sub)
same => n(go-record),Set(WAV=/var/spool/asterisk/monitor/${FILE_UNIQUEID})
same => n,Set(filedate=${STRFTIME(${EPOCH},,%Y%m%d_%H-%M-%S)})
same => n,Set(foldername=${STRFTIME(${EPOCH},,%Y/%m)})
same => n,Set(filename=${filedate}_${ARG1:-10}_${ARG2:-10}_${FILE_UNIQUEID})
same => n,Set(MP3=/var/spool/asterisk/monitor/mp3/${foldername}/${filename})
same => n,System(mkdir -p /var/spool/asterisk/monitor/mp3/${foldername})
same => n,Set(monopt=nice -n 19 /usr/bin/lame -b 32 --silent "${WAV}.wav" "${MP3}.mp3" && rm -rf "${WAV}.wav" && chmod o+r "${MP3}.mp3")
same => n,Noop(${CDR(record)})
same => n,Noop(CHANNEL ${CHANNEL(exten)})
same => n,Set(CDR(realdst)=${ARG2});
same => n,Set(CDR(record)=${FILE_UNIQUEID})
same => n,Set(CDR(recordingfile)=${filename}.mp3)
same => n,MixMonitor(${WAV}.wav,b,${monopt})
same => n(end_sub),return