Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

Hi all, i am totaly new to this and i need a little help with a script i found over the net.

I have setup an Asterisk PBX that records calls and stores the files in a directory with the folowing names:

Outgoing calls: PBX-OUT-called_number-date-time-unique id.wav

eg: PBX-OUT-92610999999-20121212-145901-1355317141.98146.wav

The above outgoing call when tranfered to int 119: PBX-INTERNAL-called_number-int-date-time-unique id.wav

eg: PBX-INTERNAL-92610999999-119-20121212-145930-1355317141.98146.wav

Notice that both files have the same unique id

Incoming calls: PBX-IN-caller_id-date-time-unique id.wav

eg: PBX-IN-2610999999-20121212-150012-1355317212.9848.wav

The above incomming call when tranfered to int 119: PBX-INTERNAL-caller_id-int-date-time-unique id.wav

eg: PBX-INTERNAL-2610999999-119-20121212-150134-1355317212.9848.wav

Notice that both files have the same unique id

Internal calls: PBX-INTERNAL-from int-to int-date-time-unique id.wav

PBX-INTERNAL-206-120-20121212-160547-1355317520.9958.wav

I need the script to do the folowing:

1. Delete all internal files with filename PBX-INTERNAL-XXX-XXX.*

2. Mix incoming or outgoing call file with internal (tranfered) recording based on the unique id using sox.

eg: PBX-IN-2610999999-20121212-150012-1355317212.9848.wav + PBX-INTERNAL-2610999999-119-20121212-150134-1355317212.9848.wav should make a new file with name PBX-IN-2610999999-20121212-150012-1355317212.9848.wav

3. convert .wav to .mp3 (it is works already)

4. delete converted .wav files (it is works already)

5. move .mp3 files to another server (it is works already)

here is the script

#!/usr/bin/perl $path='/var/spool/asterisk/monitor'; $mount='/mnt/nas/'; @Files = glob($path.'/*.wav'); foreach $File (@Files) { if((-M $File)>0.0002) { if(($FileName)=($File=~/(.+)\-out.wav/)) { system("/usr/bin/sox -m $FileName-in.wav $File +Name-out.wav $FileName.wav"); unlink "$FileName-in.wav"; unlink "$FileName-out.wav"; } elsif(($FileName)=($File=~/(.+)\-in.wav/)) { system("/usr/bin/sox -m $FileName-in.wav $File +Name-out.wav $FileName.wav"); unlink "$FileName-in.wav"; unlink "$FileName-out.wav"; } else { ($FileName) = ($File=~/(.+)\.wav/); } print "Creating $FileName.mp3\n"; system("/usr/bin/lame --cbr -b 32 --noreplaygain -q 2 \"$FileName.wav\ +" \"$FileName.mp3\" --quiet"); if(-e "$FileName.mp3") { print "Moving $FileName.mp3 to $mount\n"; system("mv ".$FileName.".mp3 ".$mount); print "Deleting $FileName.wav\n"; unlink "$FileName.wav"; } } }

Can someone please help


In reply to Need help modifing a script by tgeo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others browsing the Monastery: (4)
    As of 2014-07-31 00:37 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite superfluous repetitious redundant duplicative phrase is:









      Results (242 votes), past polls