[Asterisk-Users] Syncronize Monitored Calls
Brian West
brian at bkw.org
Mon Aug 25 15:32:14 MST 2003
True.. thats why I say "usually".. but it does yield more successful
muxing over just throwing the files together by trying to calc the in and
out diff.
bkw
On Mon, 25 Aug 2003, David Carr wrote:
> If I understand the script, your technique first calculates how much longer
> OUT is than IN, then trims that amount off the beginning of OUT, then mixes
> the files. We're using the older technique of mixing OUT and IN in reverse
> (starting from the end). Do you feel this new technique is markedly better
> than the old technique?
>
> The reason I ask is that everyone assumes the start times of OUT and IN are
> always different and the end times are always the same. However, I have
> gotten such mixed sync results from the reverse technique that it leads me
> to believe the end times are not always the same. If that is true then the
> new technique couldn't be much better than the old one.
>
> Thoughts?
>
> -----Original Message-----
> From: asterisk-users-admin at lists.digium.com
> [mailto:asterisk-users-admin at lists.digium.com]On Behalf Of David Harris
> Sent: Monday, August 25, 2003 10:21 AM
> To: asterisk-users at lists.digium.com
> Subject: [Asterisk-Users] Syncronize Monitored Calls
>
>
> I thought I would post this in case it might be of any use to anyone. Not
> anything special but it does work. Keep in mind you need sox and wmix.
>
>
>
> Here is some relevant exerpts of my extensions.conf using John Todds
> macro.
>
>
>
> [globals]
>
> CALLFILENAME=foo
>
> FOO=foo
>
> CALLERIDNUM=foo
>
>
>
> [default]
>
>
>
> exten => 287,1,Macro(dial,SIP/agent20002|20)
>
> exten => 287,2,Voicemail(u287)
>
> exten => h,1,Macro(hangup)
>
>
>
> [macro-dial]
>
>
>
> exten => s,1,AGI(set-timestamp.agi)
>
> exten =>
> s,2,SetVar(CALLFILENAME=${timestamp}-${CALLERIDNUM}-${MACRO_EXTEN})
>
> exten => s,3,Monitor(wav,${CALLFILENAME})
>
> exten => s,4,Dial(${ARG1},${ARG2},${ARG3})
>
>
>
> [macro-hangup]
>
>
>
> exten => s,1,SetVar(MONITORDIR=/var/spool/asterisk/monitor)
>
> exten => s,2,GotoIf($[${CALLFILENAME} = ${FOO}]?6:3)
>
> exten => s,3,System(/usr/local/bin/mix_monitor_files.pl ${MONITORDIR}
> ${CALLFILENAME}-in.wav ${CALLFILENAME}-out.wav ${CALLFILENAME}.wav)
>
> exten => s,6,NoOp
>
>
>
>
>
> Here is mix_monitor_files.pl. sox and wmix must be in the path of your
> perl script
>
>
>
> #!/usr/bin/perl
>
>
>
> $monitordir = shift;
>
> $infile = shift;
>
> $outfile = shift;
>
> $finishfile = shift;
>
>
>
> chdir($monitordir);
>
>
>
>
>
> $infile_output = `sox $infile -e stat 2>&1`;
>
> $outfile_output = `sox $outfile -e stat 2>&1`;
>
>
>
> $infile_output =~ /Samples read:\s+(\d+)/;
>
> $infile_samples = $1;
>
>
>
> $outfile_output =~ /Samples read:\s+(\d+)/;
>
> $outfile_samples = $1;
>
>
>
>
>
> if($outfile_samples > $infile_samples)
>
> {
>
> $diff_samples = $outfile_samples - $infile_samples;
>
> system("sox $outfile temp${outfile} trim ${diff_samples}s");
>
> system("wmix $infile temp${outfile} > $finishfile");
>
> system("rm -f $infile temp${outfile} $outfile");
>
> }
>
> elsif($infile_samples > $outfile_samples)
>
> {
>
> $diff_samples = $infile_samples - $outfile_samples;
>
> system("sox $infile temp${infile} trim ${diff_samples}s");
>
> system("wmix temp${infile} $outfile > $finishfile");
>
> system("rm -f temp${infile} $outfile $infile");
>
> }
>
> else
>
> {
>
> system("wmix $infile $outfile > $finishfile");
>
> system("rm -f $infile $outfile");
>
> }
>
More information about the asterisk-users
mailing list