Recording wav files is very good in terms of CPU usage, but those files end up being huge
Transcoding to GSM files still takes up substantial disk space and is much heavier on the CPU
The ideal would be saving those files in some very-compressed MP3 format, but this is not a very good idea as the hit on the CPU is quite dramatic.
Still, most systems do not operate on a 24/7 basis; if your call center gets a lot of traffic during office hours, it's just as well likely that it will be sitting idle all night.
Therefore, it would be nice if we could:
Record all calls using the cheapest recording format
Transform all calls to some very compressed format at night, when the CPU is sitting idle
his way, if you listen to a call that's just been recorded, you will download a large wav file; if you listen to a call that has been recorded two days ago, you will download a highly-compressed MP3 file.
For example, take the standard agent-101 recording file that is distribuited with Asterisk; its size is:
The mp3 file is compressed as 16kbps/mono and sounds pretty good, likely better that the gsm file. The mp3 compressed at 8kbps/mono sounds a bit compressed, but it stays intellegible.
Enconding wav files into MP3
To encode wav files into mp3, we create a make file. Make is the right tool for the job, as it is built to transform one file into a different file, by name.
So we edit a file called Makefile (yes, with the capital M) into our main storage directory, usually /var/spool/asterisk/monitor:
(You can omit the clean section we used for testing).
Leave a few blank lines after each target.
Make sure you have sox and lame installed on your machine.
Then at night you run a job like:
At night, this makefile will search all wav (or gsm) files and convert them into mp3, deleting the original files.
Choosing 16k, 12k or 8k compression
In order to fine-tune the mp3 encoding to your preferred size, you can change the parameter after --preset to:
--preset phone -> 16kbps/mono, high quality
--preset 12 -> 12kbps/mono, normal quality
--preset 8 -> 8 kbps/mono, low quality
If your system is not over-loaded, you may also want to pass the '-h' parameter to turn on high-quality (but slower) mp3 encoding.