Difference between revisions of "VoIP: Asterisk Merekam Suara"

From OnnoWiki
Jump to navigation Jump to search
(New page: Sumber: http://stackoverflow.com/questions/2438396/asterisk-auto-call-recording We are running asterisk with 8 port FXO. FXO connects to our old PBX (Samsung Office Serv 100). Now we ...)
 
 
(One intermediate revision by the same user not shown)
Line 10: Line 10:
 
Here is the diagram
 
Here is the diagram
  
          |------|---------------------------------
+
            |------|---------------------------------
          |      |--------------24 Lines ---------- Other clasic Phones
+
            |      |--------------24 Lines ---------- Other clasic Phones
PRI------  | PBX  |---------------------------------
+
PRI------  | PBX  |---------------------------------
          |      |
+
            |      |
          |      |
+
            |      |
          |      |-----------|---------|
+
            |      |-----------|---------|
          |      |--8 lines--|        |---------         
+
            |      |--8 lines--|        |---------         
          |      |-----------|Asterisk |---------- 50 SIP phone
+
            |      |-----------|Asterisk |---------- 50 SIP phone
          |------|          |        |----------
+
            |------|          |        |----------
                              |---------|----------
+
                              |---------|----------
  
 
Is there a simple way to do this?
 
Is there a simple way to do this?
Line 87: Line 87:
 
Obviously you'd have to make changes to my code, but hopefully that gives you a good idea.
 
Obviously you'd have to make changes to my code, but hopefully that gives you a good idea.
  
 +
 +
 +
 +
Asterisk cmd Monitor
 +
Business PBX Solutions
 +
 +
Provider Solution Details
 +
Bicom VoIP
 +
Become an ITSP Now!
 +
 +
    Become a serious competitor in VoIP Immediately
 +
    FULL Consultancy, Installation, Training & Support
 +
    Sell Hosted IP PBXs, Biz Lines, Call Centre
 +
    Turnkey Provisioning at your data center
 +
 +
Details
 +
Synopsis
 +
Record a telephone conversation to a sound file
 +
 +
Description
 +
 +
    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:
 +
 +
    Monitor Setup Example
 +
 +
 +
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
 +
 +
 +
Related user report Sep 2010: I've already ran into major problems using the Monitor() app due to disk io. The disk writing is done in the same thread as audio bridging, so if you have high disk io contention (which I had), audio bridging suffers while you're recording a call. MixMonitor spawns a new thread and avoids this problem. Ideally Monitor() should also be rewritten to spawn a new thread.
 +
 +
Example 3: Play beeping sound during recording
 +
If you want peep every 15s, you should do
 +
 +
exten => _X.,1,Set(LIMIT_WARNING_FILE=beep)
 +
exten => _X.,2,Dial(Local/mixmoncontext/#{EXTEN}||L(36000000:36000000:15000)\n)
 +
 +
Converting Wav Files
 +
 +
Find all files in monitor directory and convert to mp4 (1/10 size) removing original wav- requires ffmpeg and x264
 +
 +
nice -n 19 find /var/spool/asterisk/monitor/ -iname "*wav" -type f -exec sh -c 'ffmpeg -i {} -y -vn -aq 40 -ac 1 `echo {} | sed "s/.wav/.mp4/g"` && rm {}' \;
 +
 +
(file size approx 6MB per hour)
  
  
Line 96: Line 172:
  
 
* http://stackoverflow.com/questions/2438396/asterisk-auto-call-recording
 
* http://stackoverflow.com/questions/2438396/asterisk-auto-call-recording
 +
* http://www.voip-info.org/wiki/view/Asterisk+cmd+monitor

Latest revision as of 18:22, 30 March 2014

Sumber: http://stackoverflow.com/questions/2438396/asterisk-auto-call-recording



We are running asterisk with 8 port FXO. FXO connects to our old PBX (Samsung Office Serv 100).

Now we want to record all calls routed through FXO (if it was dialed to outside or comming from outside).

Here is the diagram

           |------|---------------------------------
           |      |--------------24 Lines ---------- Other clasic Phones
PRI------  | PBX  |---------------------------------
           |      |
           |      |
           |      |-----------|---------|
           |      |--8 lines--|         |---------         
           |      |-----------|Asterisk |---------- 50 SIP phone
           |------|           |         |----------
                              |---------|----------

Is there a simple way to do this? asterisk share|improve this question

asked Mar 13 '10 at 12:59 Manjoor 1,43141944 add comment 3 Answers active oldest votes up vote 16 down vote accepted


Are you running plain Asterisk? If so you can modify your dial plan to start 'monitoring' the channel, which will record the call.

The monitor command's documentation: http://www.voip-info.org/wiki/view/Asterisk+cmd+monitor

Just for the sake of completion, here's the documentation:

[root@localhost ~]# asterisk -rx 'core show application monitor'

  -= Info about application 'Monitor' =-

[Synopsis]
Monitor a channel

[Description]
  Monitor([file_format[:urlbase],[fname_base],[options]]):
Used to start monitoring a channel. The channel's input and output
voice packets are logged to files until the channel hangs up or
monitoring is stopped by the StopMonitor application.
  file_format           optional, if not set, defaults to "wav"
  fname_base            if set, changes the filename used to the one specified.
  options:
    m   - when the recording ends mix the two leg files into one and
          delete the two leg files.  If the variable MONITOR_EXEC is set, the
          application referenced in it will be executed instead of
          soxmix and the raw leg files will NOT be deleted automatically.
          soxmix or MONITOR_EXEC is handed 3 arguments, the two leg files
          and a target mixed file name which is the same as the leg file names
          only without the in/out designator.
          If MONITOR_EXEC_ARGS is set, the contents will be passed on as
          additional arguments to MONITOR_EXEC
          Both MONITOR_EXEC and the Mix flag can be set from the
          administrator interface 

    b   - Don't begin recording unless a call is bridged to another channel
    i   - Skip recording of input stream (disables m option)
    o   - Skip recording of output stream (disables m option) 

By default, files are stored to /var/spool/asterisk/monitor/.

Returns -1 if monitor files can't be opened or if the channel is already
monitored, otherwise 0.

And here's a sample way you can use it:

; This fake context records all outgoing calls to /var/spool/asterisk/monitor in wav format.
[fake-outgoing-context]
exten => s,1,Answer()
exten => s,n,Monitor(wav,,b)
exten => s,n,Dial(DAHDI/g0/${EXTEN})
exten => s,n,Hangup()

Obviously you'd have to make changes to my code, but hopefully that gives you a good idea.



Asterisk cmd Monitor Business PBX Solutions

Provider Solution Details Bicom VoIP Become an ITSP Now!

   Become a serious competitor in VoIP Immediately
   FULL Consultancy, Installation, Training & Support
   Sell Hosted IP PBXs, Biz Lines, Call Centre
   Turnkey Provisioning at your data center

Details Synopsis Record a telephone conversation to a sound file

Description

   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:

   Monitor Setup Example


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


Related user report Sep 2010: I've already ran into major problems using the Monitor() app due to disk io. The disk writing is done in the same thread as audio bridging, so if you have high disk io contention (which I had), audio bridging suffers while you're recording a call. MixMonitor spawns a new thread and avoids this problem. Ideally Monitor() should also be rewritten to spawn a new thread.

Example 3: Play beeping sound during recording If you want peep every 15s, you should do

exten => _X.,1,Set(LIMIT_WARNING_FILE=beep)
exten => _X.,2,Dial(Local/mixmoncontext/#{EXTEN}||L(36000000:36000000:15000)\n)

Converting Wav Files

Find all files in monitor directory and convert to mp4 (1/10 size) removing original wav- requires ffmpeg and x264

nice -n 19 find /var/spool/asterisk/monitor/ -iname "*wav" -type f -exec sh -c 'ffmpeg -i {} -y -vn -aq 40 -ac 1 `echo {} | sed "s/.wav/.mp4/g"` && rm {}' \;

(file size approx 6MB per hour)




Referensi