MixMonitor - How to use lame to convert and then remove the source file?

5.4k Views Asked by At

How can I remove the source wav file after the call is finished? If I have to use AGI can I have an example script?

This is how I'm using MixMonitor exten => s,n,MixMonitor(${source_file}.wav,W(1),lame -V3 ${source_file}.wav ${mp3_from_source}.mp3)

Fails because it is deleted before the conversion. exten => h,n,System(rm ${source_file}.wav)

2

There are 2 best solutions below

3
On

How about:

exten => s,n,MixMonitor(${source_file}.wav,W(1),lame -V3 ${source_file}.wav ${mp3_from_source}.mp3 && rm ${source_file}.wav)

and skip the call in h?

0
On

Honestly, you need to stop being creative. Just exec the system level calls as separate dial plan lines. One line for mixmonitor, one line for lame, verify the return value of lame, then delete. This is what I do in my applications, and it works perfect. You don't need to combine every step of the conversion process into a single dialplan line.

I use this command line:

 /usr/local/bin/lame -b16 --noshort "/var/spool/asterisk/monitor/$1.wav" "/var/www/html/asterisk/calls/$1.mp3"