recorded calls in mp3 format

conceptpub
Posts: 4
Member Since:
2007-02-08

Currently recorded calls are saved in .wav format, these are going to take a lot of room up with the volume of calls that are going to be made.

Are there any tutorials on how to convert these to mp3? is it best to record on the fly to mp3, or convert them at 3am for example? if so.. how? :)

Any ideas guys?



dmitry
Posts: 48
Member Since:
2007-01-25
Re: recorded calls in mp3 format

I'm interested in this also: We record all calls, and rather than leaving them on disk as WAV, I'd rather save them as blobs in a database in a more compact format!



KodaK
Posts: 1885
Member Since:
2006-06-14
Re: recorded calls in mp3 format

I wrote a perl script that does this for any wav file over 7 days. I run it from cron daily.

#! /usr/bin/perl -w
    eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
        if 0; #$running_under_some_shell

# convert all wavs older than 7 days in asterisk directory to mp3s

use strict;
use File::Find ();

use vars qw/*name *dir *prune/;
*name   = *File::Find::name;
*dir    = *File::Find::dir;
*prune  = *File::Find::prune;

sub wanted;
sub doexec ($@);


use Cwd ();
my $cwd = Cwd::cwd();


# Traverse desired filesystems
File::Find::find({wanted => \&wanted}, '/var/spool/asterisk/monitor');
exit;


sub wanted {
    my ($dev,$ino,$mode,$nlink,$uid,$gid);

    /^.*\.wav\z/s &&
    (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) &&
    (int(-M _) == 7) &&
    doexec(0, 'lame','{}');
}


sub doexec ($@) {
    my $ok = shift;
    my @command = @_; # copy so we don't try to s/// aliases to constants
    for my $word (@command)
        { $word =~ s#{}#$name#g }
    if ($ok) {
        my $old = select(STDOUT);
        $| = 1;
        print "@command";
        select($old);
        return 0 unless <STDIN> =~ /^y/;
    }
    chdir $cwd; #sigh
    system @command;
    chdir $File::Find::dir;
    return !$?;
}

exec '/sbin/wavremoveold';

I also remove the mp3s that are older than a month:


#! /usr/bin/perl -w
    eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
        if 0; #$running_under_some_shell

use strict;
use File::Find ();

# remove all mp3s older than 30 days in monitor directory

# Set the variable $File::Find::dont_use_nlink if you're using AFS,
# since AFS cheats.

# for the convenience of &wanted calls, including -eval statements:
use vars qw/*name *dir *prune/;
*name   = *File::Find::name;
*dir    = *File::Find::dir;
*prune  = *File::Find::prune;

sub wanted;



# Traverse desired filesystems
File::Find::find({wanted => \&wanted}, '/var/spool/asterisk/monitor/');
exit;


sub wanted {
    my ($dev,$ino,$mode,$nlink,$uid,$gid);

    /^.*\.mp3\z/s &&
    (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) &&
    (int(-M _) == 30) &&
    (unlink($_) || warn "$name: $!\n");
}

HTH.

(Yes, I just used find2perl to do these.)

--

WARNING: I no longer actively participate in these forums. My thoughts on trixbox in a nutshell: http://www.youtube.com/watch?v=q4xBMkWu1pE Use AsteriskNOW instead.



KodaK
Posts: 1885
Member Since:
2006-06-14
Re: recorded calls in mp3 format

Sorry, here's wavremoveold:

#! /usr/bin/perl -w
    eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
        if 0; #$running_under_some_shell

use strict;
use File::Find ();

# remove all wav files older than 7 days in asterisk monitor directory

# Set the variable $File::Find::dont_use_nlink if you're using AFS,
# since AFS cheats.

# for the convenience of &wanted calls, including -eval statements:
use vars qw/*name *dir *prune/;
*name   = *File::Find::name;
*dir    = *File::Find::dir;
*prune  = *File::Find::prune;

sub wanted;



# Traverse desired filesystems
File::Find::find({wanted => \&wanted}, '/var/spool/asterisk/monitor/');
exit;


sub wanted {
    my ($dev,$ino,$mode,$nlink,$uid,$gid);

    /^.*\.wav\z/s &&
    (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) &&
    (int(-M _) == 7) &&
    (unlink($_) || warn "$name: $!\n");
}
--

WARNING: I no longer actively participate in these forums. My thoughts on trixbox in a nutshell: http://www.youtube.com/watch?v=q4xBMkWu1pE Use AsteriskNOW instead.



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.