Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( [id://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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2024-04-18 05:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found