linux下使用ffmpeg将amr转成mp3

linux下使用ffmpeg将amr转成mp3

实现:

  1. 首先安装系统基础环境
# yum install -y automake autoconf libtool gcc gcc-c++  //RHEL & CentOS 系列
# apt-get install automake autoconf libtool gcc gcc-c++  //Debian & Ubuntu 系列
  1. 编译所需源码包
    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和已安装的扩展,则运行成功。

3.使用方法

# ffmpeg -i 1.mp3 -ac 1 -ar 8000 1.amr             //MP3转换AMR
# ffmpeg -i /root/1568778383624.amr /root/1.mp3    //AMR转换MP3

附录:
附录1. ffmpeg默认安装目录为“/usr/local/lib”,有些64位系统下软件目录则为“/usr/lib64”,编译过程中可能会出现
“ffmpeg: error while loading shared libraries: libmp3lame.so.0: cannot open shared object file: No such file or directory”等类似的错误,解决办法是建立软链接:
# ln -s /usr/local/lib/libmp3lame.so.0.0.0 /usr/lib64/libmp3lame.so.0

附录2. 如果安装amrnb遇到错误:

configure: error: You need patch utility to prepare sources.
执行:

[root@localhost amrnb-11.0.0.0]# yum install patch
附录3. 如果出现以下提示:ffmpeg: error while loading shared libraries: libavdevice.so.58: cannot open shared object file: No such file or directory

可以通过如下方式查看ffmpeg的动态链接库哪些没有找到:

[root@localhost ffmpeg-4.2.1]# ldd `which ffmpeg`
	linux-vdso.so.1 =>  (0x00007ffdf576b000)
	libavdevice.so.58 => not found
	libavfilter.so.7 => not found
	libavformat.so.58 => not found
	libavcodec.so.58 => not found
	libswresample.so.3 => not found
	libswscale.so.5 => not found
	libavutil.so.56 => not found
	libm.so.6 => /lib64/libm.so.6 (0x00007f617c4ad000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f617c291000)
	libc.so.6 => /lib64/libc.so.6 (0x00007f617bec3000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f617c7af000)

如果类似于上面的输出内容,查找以上类库:

[root@localhost ffmpeg-4.2.1]# find /usr/local/lib/ | grep -E "libavdevice.so.58|libavfilter.so.7|libavcodec.so.58"
/usr/local/lib/libavdevice.so.58.8.100
/usr/local/lib/libavdevice.so.58
/usr/local/lib/libavfilter.so.7.57.100
/usr/local/lib/libavfilter.so.7
/usr/local/lib/libavcodec.so.58.54.100
/usr/local/lib/libavcodec.so.58

会发现全部在/usr/local/lib/下
查看链接库配置文件

# more  /etc/ld.so.conf | grep /usr/local/lib

如果不包含的话,需要编辑此文添加:

/usr/local/lib
/usr/local/lib64

运行配置命令
# ldconfig

你可能感兴趣的:(linux下使用ffmpeg将amr转成mp3)