说明:
目前并没有找到合适的支持AMR转MP3的java的开发包,服务器环境为CentOS 6.2,所以我们采用了ffmpeg。
实现: # yum install -y automake autoconf libtool gcc gcc-c++ //RHEL & CentOS 系列 # apt-get install automake autoconf libtool gcc gcc-c++ //Debian & Ubuntu 系列
yasm:http://yasm.tortall.net/Download.html(汇编器,新版本的ffmpeg增加了汇编代码) lame:http://lame.sourceforge.net/download.php(Mp3音频解码) OpenCore AMR:http://sourceforge.net/projects/opencore-amr AmrNB:http://www.penguin.cz/~utx/amr AmrWB:http://www.penguin.cz/~utx/amr FFMpeg:http://ffmpeg.org/download.html 分别解压缩并编译上述源码包 # tar xzvf *.tar.gz # tar xjvf *.tar.bz2 解压后直接使用 # ./configure # make # make install 命令进行编译安装。 编译FFMpef的时候稍微特殊一点: # ./configure --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-version3 --enable-shared # make # make install # ldconfig 最后写入config后,终端运行ffmpeg命令,出现success和已安装的扩展,则运行成功。
# ffmpeg -i 1.mp3 -ac 1 -ar 8000 1.amr //MP3转换AMR # ffmpeg -i 1.amr 1.mp3 //AMR转换MP3
附录2. 如果出现以下提示:ffmpeg: error while loading shared libraries: libavdevice.so.54: cannot open shared object file: No such file or directory # ldd `which ffmpeg` libavdevice.so.54 => not found libavfilter.so.3 => not found libavformat.so.54 => not found libavcodec.so.54 => not found libswresample.so.0 => not found libswscale.so.2 => not found libavutil.so.51 => not found libm.so.6 => /lib64/libm.so.6 (0x00002ab7c0eb6000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00002ab7c100b000) libc.so.6 => /lib64/libc.so.6 (0x00002ab7c1125000) /lib64/ld-linux-x86-64.so.2 (0x00002ab7c0d9a000) 如果类似于上面的输出内容,查找以上类库: # find /usr/local/lib/ | grep -E "libavdevice.so.54|libavfilter.so.3|libavcodec.so.54" /usr/local/lib/libavfilter.so.3.17.100 /usr/local/lib/libavcodec.so.54.59.100 /usr/local/lib/libavdevice.so.54 /usr/local/lib/libavcodec.so.54 /usr/local/lib/libavfilter.so.3 /usr/local/lib/libavdevice.so.54.2.101 会发现全部在/usr/local/lib/下 查看链接库配置文件 # more /etc/ld.so.conf | grep /usr/local/lib 如果不包含的话,需要编辑此文添加: /usr/local/lib /usr/local/lib64 运行配置命令 # ldconfig(责任编辑:IT) |