Asterisk cmd Monitor
Created by: oej,Last modification on Sat 26 of Apr, 2008 [00:38 UTC] by JustRumours
Synopsis
Record a telephone conversation to a sound fileDescription
- Monitor(ext,basename)
- Monitor(ext,basename,flags) — New feature added to CVS 2004-06-03
The Monitor command starts recording a channel. The channel's input and output voice packets are saved to separate sound files. You may change filenames during a recording by using the ChangeMonitor command. Recording continues until either the StopMonitor command is executed or the channel hangs up.
If you don't specify a full path, the file will be stored in the "monitor" subdir of the path specified with astspooldir in asterisk.conf (so default will be /var/spool/asterisk/monitor).
A more detailed description on recording with Asterisk can be found at Asterisk cmd Record.
Command Parameters
- ext: The sound file format to save in, which will be also used as the filename extension. Default: wav
- basename: The base filename to use when saving the sound files. If not supplied, the default basename is constructed on the channel name plus a number, for example, IAX2[foo@bar]-3. The channel's input voice packets will be saved to basename-in.ext and the output voice packets will be saved to basename-out.ext. The default location for saved files is the /var/spool/asterisk/monitor directory.
- flags: If flags contains the letter m, then when recording finishes, Asterisk will execute a unix program to combine the two sound files into a single sound file. By default, Asterisk will execute soxmix and then delete the original two sound files. Note that sox/soxmix may not necessarily understand the sound format (e.g. alaw) and can't therefore mix the in and out files down to one single file. You may specify a different mixing method by setting the MONITOR_EXEC channel variable to the path of the unix program you wish executed, then call Monitor to begin recording. At the completion of recording, the specified unix program will be executed with three command-line parameters: the two sound files and the filename where the program should save the combined sound file. In this situation, earlier versions of Asterisk will not delete the two original sound files; it's up to your program to do that if you need/wish to. The "m" flag is settable through the manager interface. Also see b - Don't begin recording unless a call is bridged to another channel.
Example 1
When a call is sent to extension 2060, recording of the call will begin, and the caller is sent to conference number 1 with the MeetMe command.exten => 2060,1,Answer
exten => 2060,2,Wait(1)
exten => 2060,3,Monitor(wav,myfilename)
exten => 2060,4,Meetme(1,ps)
For an extensive example of using Monitor, see:
Example 2: 512 Simultaneous Calls with Digital Recording
How to use a RAM disk to eliminate the I/O bottleneck associated with digitally recording calls via the Monitor application:- Original posting by Matt Roth
- Follow-Up with more details
Example 3: Play beeping sound during recording
If you want peep every 15s, you should doexten => _X.,1,Set(LIMIT_WARNING_FILE=beep)
exten => _X.,2,Dial(Local/mixmoncontext/#{EXTEN}||L(36000000:36000000:15000)\n)
See also
- Asterisk cmd PauseMonitor: Especially of interest for use in features.conf (section applicationmap)
- Asterisk cmd UnpauseMonitor: Especially of interest for use in features.conf (section applicationmap)
- MixMonitor: Monitoring & recording with native call leg mixing (Asterisk 1.2)
- Recording Calls with Asterisk
- Asterisk cmd Dial with options w or W for in-conversation recording (Asterisk v1.2.x)
- SoX Sound processing software
- AgentMonitorOutgoing: Monitor an agent's outgoing call
- Record: Record a channel
- ControlPlayback: Play a recording to the user
- PlaySip: SIP tool that can be used for recording
- Asterisk cmd Monitor Cleanup: Cleanup those pesky in and out files.
- Monitor stereo-example Example on how to record in stereo using MP3 compression
Asterisk | Applications | Functions | Variables | Expressions | Asterisk FAQ


Comments
333Monitor doesn't save anything
I've a simple agi to test that, here is the code:
use Asterisk::AGI;
my $AGI = new Asterisk::AGI;
$AGI->exec(Monitor,"wav|/etc/asterisk/savedComand");
$AGI->exec(BackgroundDetect,"soundFile|500|100");
$AGI->exec(StopMonitor);
This code create the files, both savedComand-in and savedComand-out, but they are empty.
I've tried to change the extension to gsm, but it's the same.
The most strange thing here is than that code has worked fine many months until last week.
Could anyone help me please?
Thank you
333Only one user in the channel
commands from Asterisk for more than 5 seconds, it won't be monitored. When listening to the recorded file, 5 seconds
could have been 10 minutes during the call.
333Monitor Status?
via the manager API, "Action: Status" shows all channels as "Unmonitored", regardless if they're being recorded or not. (Does that "unmonitored" refer to something completely unrelated?)
333option b may cause audio delay
333MP3 Option