自动录音的Asterisk电话系统

14

我们正在使用带有8个FXO端口的Asterisk。FXO连接到我们的旧PBX(三星Office Serv 100)。

现在我们想要记录通过FXO路由的所有呼叫(无论是拨打外部电话还是来自外部电话)。

是否有简单的方法可以实现这一点?

3个回答

28

你是否正在使用纯Asterisk呢?如果是的话,你可以修改你的拨号计划来开始“监控”通道,这将记录通话。

monitor命令的文档:http://www.voip-info.org/wiki/view/Asterisk+cmd+monitor

只是为了完整起见,这里是文档:

[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.

这里是一个使用它的示例:

; 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()

显然,您需要对我的代码进行更改,但希望这能给您一个很好的想法。

是的,请查看这个链接:http://www.voip-info.org/wiki/view/Monitor+stereo-example - rdegges

13

一个真实的例子是:

    exten => _87X,1,NoOp()
    exten => _87X,n,MixMonitor(${UNIQUEID}.wav,ab)
    exten => _87X,n,Dial(SIP/${EXTEN},45)
    exten => _87X,n,StopMixMonitor()
    exten => _87X,n,Hangup()

始终使用NoOp - 第一条规则必须以1开始,这样您可以随意交换规则并将n步骤放置在任何位置。

最好使用MixMonitor而不是Monitor - Monitor仅记录入站或出站音频 - MixMonitor同时使用两者。

此外,wav是相当不错的选择作为格式 - 我还使用脚本将wav文件转换为OGG - 这是大小/质量和许可问题之间的最佳折衷方案。

关于参数:

a是附加 b是桥接(适用于生产环境-只有在呼叫获得答复时才会记录-不适用于调试)

关于StopMixMonitor(),我只是很全面,但是例如,有些情况下,您可能希望停止录音,例如:

    ...
    exten => _39[5-9],n,Dial(SIP/${EXTEN},45)
    exten => _39[5-9],n,GotoIf($["${DIALSTATUS}" = "BUSY"]?busy:unavailable)
    exten => _39[5-9],n(busy),NoOp()
    exten => _39[5-9],n,StopMixMonitor()
    exten => _39[5-9],n,Voicemail(${EXTEN},u)
    exten => _39[5-9],n,Hangup()
    exten => _39[5-9],n(unavailble),NoOp()
    exten => _39[5-9],n,StopMixMonitor()
    exten => _39[5-9],n,Hangup()
    ...

在这个例子中,您会停止语音邮件交互的录音。

希望这能为您解决问题。


你如何在脚本中将wav文件转换为OGG格式?谢谢! - Ben
嘿@Ben有许多工具可用,但其中一个可以直接使用的是SOX。制作一个脚本,可以为您获取源文件路径,并确保它们的修改时间在过去2-3分钟内-这样您就不会开始转换未完成的录音。如果SOX转换成功,则可以删除.wav文件。 - nmirceac

7

根据您Asterisk盒子的规格,您可能会发现这个技巧也很有用。创建一个相当大的ramdisk并将/var/spool/asterisk/monitor挂载到它上面。这样Asterisk就记录到内存而不是磁盘上。然后编写一个cron脚本,每15-30分钟移动一次录音到永久存储。


嗯,您有在生产环境中运行RAM磁盘的经验吗?我对这个想法非常感兴趣。 - Radu094
如果没有它,我们将无法同时记录像现在这样多的频道/通话而不会使硬盘崩溃,60多个同时录音毫无问题,但直接录制到磁盘会使服务器崩溃。 - vbcrlfuser
2
@radu094,对于ramdisk(它运行得很好),你只需要在/etc/fstab中添加类似于“tmpfs /var/spool/asterisk/monitor tmpfs defaults,size=1024m 1 1”的内容。您还应该考虑一个cronjob,将录音移动到持久存储,但不要忘记仅移动mtime小于当前时间戳减去2-3分钟的文件(以确保您不会移动正在写入的录音)。希望这可以帮助...五年后...... - nmirceac

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接