- Products
- Purchase
Order Online Maintenance Renewal Resellers - Support
Helpdesk Online Documentation Web Forum - Our Clients
- About
About us Services Contact
From AfterLogic Wiki
Contents |
Introduction
Starting from version 6.1, WebMail Pro (PHP) provides support for voice messages playback. It works with files in AMR format which are converted to WAV on the fly. To ensure the conversion, you need to install ffmpeg with AMR support. AMR encoding decoding/capabilities are provided by opencore-amr library. Thus, you'll need ffmpeg with opencore-amr library installed. But first, you might need to know how exactly WebMail Pro detects voice messages and what criteria should be met.
How voice messages are detected
To be treated as a voice message, attached file must have .amr extension:
Content-Disposition: inline; voice=Voice-Message; filename="message.amr"; duration=10000
Also, content-type of the attachment must contain "voice" as a substring:
Content-type: MULTIPART/Voice-Message; Version=2.0; boundary="----------11DFD6D7CDE098"
You can find a complete example of a correct voice message below:
Date: Mon, 25 Apr 2011 14:48:21 +0300 From: support@afterlogic.com Message-ID: <1132341582.20110323154558@afterlogic.com> To: demopro@afterlogic.com Subject: Voice Message MIME-Version: 1.0 Content-type: MULTIPART/Voice-Message; Version=2.0; boundary="----------11DFD6D7CDE098" ------------11DFD6D7CDE098 Content-Type: text/plain; charset=windows-1251 Content-Transfer-Encoding: 8bit voice message ------------11DFD6D7CDE098 Content-Type: audio/AMR Content-Transfer-Encoding: BASE64 Content-Description: Voice Message (1.1) Content-Disposition: inline; voice=Voice-Message; filename="message.amr"; duration=10000 Content-Duration: 10 IyFBTVIKLE0Q/CAecX/jjMeCH4AHP+gghwIALGmzjgH0W+zsGlvmn3zRs9uUcs9WLFt/bBhk vwU27bvNUSnDXqraJZ68LGmWjh4QC8Qo0v74MMM6sf5aA/UmLFuWsh4CHQZVovTDN5wpHoji Mb48LE8mvA9BFb4ZuiT4OSgQPOqlqiDcLEwQtB4C2Pzul1GaIfm2ufOqkqySLGkmvB4AXFJf w5wni6ka9ilrIg5eLHGNmh9BnVTjhM/gFCUPhW6zYAngLE+WvB5BPxiZKgqtaskFvrk21RiW
Out-of-box, only .AMR files are supported while .WAV files are not recognized as voice messages. However, this feature relies on the plugin found at /data/plugins/voice-message/index.php and you can modify it according to your requirements.
Installing dependencies
Some Linux distributions (e.g. Ubuntu) already have the required packages in repository, you should be able to install the libraries using your package manager. If that's not the case, you'll need to compile them from sources. In either case, it's recommended to read through this section as it contains the important information about libraries' versions.
Installing Make
You need "make" tool version 3.81 or above. If your system already has the proper version of "make" tool (which you can find out by issuing make –version), you can skip this step. If you need to install, you can follow these steps:
tar -zxvf make-3.81.tar.gz cd make-3.81 ./configure make make install
Also, please make sure make-3.81 is used from now on - for example, by specifying the full path to "make" tool when performing the next steps.
Installing Opencore-amr
You need opencore-amr version 0.1.2 or above.
Please, specify folder where are you going to install all the software, with --prefix option
For example, from now on we assume we install all the software into /opt/apache2/htdocs/webmail/data/convert/ location.
tar -zxvf opencore-amr-0.1.2.tar.gz ./configure --prefix=/opt/apache2/htdocs/webmail/data/convert/ make make install
Now you have opencore lib installed in /opt/apache2/htdocs/webmail/data/convert/ directory.
Installing FFmpeg
The next step is to build ffmeg with amr support. You may want to modify --prefix, --extra-cflags and –extra-ldflags options in order to point to the target folder where you are going to have the converter installed to.
tar -jxvf ffmpeg-0.6.1.tar.bz2 ./configure --prefix=/opt/apache2/htdocs/webmail/data/convert/ --extra-cflags=-I/opt/apache2/htdocs/webmail/data/convert/include/ --extra-ldflags=-L/opt/apache2/htdocs/webmail/data/convert/lib/ --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb make make install
Now that you have all the software built and installed, you may want to modify amr2wav_convert.sh script which is actually called in order to convert audio files. This script must reside in /data/convert/ directory, so in case you've installed ffmpeg and opencore-amr to any other location you still need to create /data/convert/ folder, put amr2wav_convert.sh there and modify it appropriately. Make sure the script does have execute permissions.
#!/bin/sh
# specify the full path to converter folder, where ffmpeg and all the libs reside
BASE=/opt/apache2/htdocs/webmail/data/convert
# specify the full path to ffmpeg executable
CONVERTER=$BASE/bin/ffmpeg
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$BASE/lib
# first arg is mandatory
echo "source $1 target $2"
if [ -f "$1" ] ; then
# ok
else
echo "can't find source $1";
exit 1;
fi
if [ -f "$2" ] ; then
# if result file already exists - do nothing
exit 0;
fi
# convert
$CONVERTER -i $1 $2
exit 0You can test functionality of this script by performing the conversion of any AMR file by calling:
amr2wav_convert.sh source.amr target.wav
You should get target.wav file which can be played in any audio player.
Enabling voice messages support
Once you have all the libraries available in your system, you need to enable voice messaging support in WebMail Pro itself. Open data/settings/config.php file, by default it only contains an empty array:
return array();
You need to add a line which enables the voice-message plugin:
return array( 'plugins.voice-message' => true );
The plugin itself resides at:
/data/plugins/voice-message/index.php
Last edit: 2011/4/26