Context for recording - setting a filename and converting to MP3

Ok, so I’m working off old data from like Asterisk 1.3, but I’m trying to set a recording filename, then ring the extension (This is a context from a DB I have setup of numbers to record) and record the call, then have lame convert the file to MP3 once it’s done, however I don’t want it to record if nobody answers… Here is what I have, and I know I could be way off here…

exten => s,1,Set(FILENAME=${TIMESTAMP}-${CALLERID(number)})
exten => s,2,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,3,MixMonitor(${FILENAME}.wav,b)
exten => s,4,Dial(PJSIP/302,24)
exten => s,5,Playback(number-not-answering)
exten => s,6,Playback(goodbye)
exten => s,7,Hangup()

Right now timestamp isn’t working and it’s throwing everything off I believe.

WORKING (Except for the ,b option)! USE THIS:

exten => s,1,Set(FILENAME=${STRFTIME(${EPOCH},,%m%d%Y-%H%M%S)}-${CALLERID(number)})
exten => s,2,Set(MONOPT=nice -n 19 /usr/local/bin/lame -b 16 --silent /var/spool/asterisk/monitor/${FILENAME}.wav /var/spool/asterisk/monitor/${FILENAME}.mp3 && rm -f /var/spool/asterisk/monitor/${FILENAME}.wav)
exten => s,3,MixMonitor(${FILENAME}.wav,b,${MONOPT})
exten => s,4,Dial(PJSIP/302,24)
exten => s,5,Playback(number-not-answering)
exten => s,6,Playback(goodbye)
exten => s,7,Hangup()

Asterisk 1.3 doesn’t support PJSIP and there are other details that would be invalid in 1.3; did you mean 13?

TIMESTAMP: (Deprecated; use ${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)})

MIXMONITOR_EXEC_ARGS is not documented and seems unlikely to exist as MixMonitor provides a direct argument for this, and there is no need for a mixing command, as that is done on the fly.

If this were Monitor and MONITOR_EXEC_ARGS, it would be an out of specification use of the variable, as shell meta characters are not part of the arguments to the command being run.

I’m concerned about the use of “rm -f”. I suspect this is a bad habit (like kill -9) rather than needed.

and there is no need for a mixing command, as that is done on the fly.

So MixMonitor supports MP3 encoding? How would I do this? What about something like this?

exten => s,1,Set(FILENAME=${STRFTIME(${EPOCH},,%m%d%Y-%H%M%S)}-${CALLERID(number)})
exten => s,2,Set(MONOPT=nice -n 19 /usr/local/bin/lame -b 16 --silent /var/spool/asterisk/monitor/${FILENAME}.wav /var/spool/asterisk/monitor/${FILENAME}.mp3 && rm -f /var/spool/asterisk/monitor/${FILENAME}.wav)
exten => s,3,MixMonitor(${FILENAME}.wav,b,${MONOPT})
exten => s,4,Dial(PJSIP/302,24)
exten => s,5,Playback(number-not-answering)
exten => s,6,Playback(goodbye)
exten => s,7,Hangup()

EDIT: YEP! This works. Thanks for the help with the date stamp!

Now for some reason my ,b option isn’t working and it records everything, even the “The number is not answering, goodbye”, though. :frowning: I wish there were a way to make it not record if the phone isn’t picked up.

Sounds like your service provider, or the callee’s, is answering the call. Asterisk cannot tell that apart from a genuine answer.

Well since I know it’s not the callee, that is somewhat disconcerting from my provider…

The callee’s network, not the callee.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.