一、安装依赖
yasm安装
#ffmpeg编译中为了提高编译速度,使用了汇编指令,于是需要使用这个工具。
yum -y install yasm
也可以通过源码包安装
tar -zxf yasm-1.3.0.tar.gz
cd yasm-1.3.0
./configure
make
make install
lame安装
tar -zxf lame-3.99.5.tar.gz
cd lame-3.99.5
./configure
make
make install
opencore-amr安装
tar -zxf opencore-amr-0.1.3.tar.gz
cd opencore-amr-0.1.3
./configure
make
make install
二、安装ffmpeg
cd /usr/local/src
wget http://ffmpeg.org/releases/ffmpeg-3.2.4.tar.bz2
tar -jxf http://ffmpeg.org/releases/ffmpeg-3.2.4.tar.bz2
cd ffmpeg-3.2.4
# 其中–enable-shared表示生成动态链接库,可以供以后编程使用,同时生成的可执行程序也依赖这些动态库。如果不加上–enable-shared选项则使用静态链接的方式编译,此时不会生成动态库,同时生成的ffmpeg等的可执行文件也比较大,但他们不需要动态库就可以直接运行
./configure --enable-version3 --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-shared --prefix=/usr/local/ffmpeg
make
make install
echo "/usr/local/ffmpeg/lib" > /etc/ld.so.conf.d/ffmpeg.conf
ldconfig
ln -sf /usr/local/ffmpeg/bin/ffmpeg /usr/bin/ffmpeg
ffmpeg # 出现下述则表示安装成功
ffmpeg version 3.2.4 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-4)
configuration: --enable-version3 --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-shared --prefix=/usr/local/ffmpeg
libavutil 55. 34.101 / 55. 34.101
libavcodec 57. 64.101 / 57. 64.101
libavformat 57. 56.101 / 57. 56.101
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
Use -h to get full help or, even better, run 'man ffmpeg'
三、为lib64创建软连接
ffmpeg: error while loading shared libraries: libopencore-amrnb.so.0: cannot open shared object file: No such file or directory
ffmpeg安装后如果出现如上错误提示
则建立对应的软链接即可,先查找文件位置,如:find / -name libavdevice.so.56
ln -s /usr/local/lib/libavdevice.so.56 /usr/lib64/libavdevice.so.56
ln -s /usr/local/lib/libavfilter.so.5 /usr/lib64/libavfilter.so.5
ln -s /usr/local/lib/libavformat.so.56 /usr/lib64/libavformat.so.56
ln -s /usr/local/lib/libavcodec.so.56 /usr/lib64/libavcodec.so.56
ln -s /usr/local/lib/libswresample.so.1 /usr/lib64/libswresample.so.1
ln -s /usr/local/lib/libswscale.so.3 /usr/lib64/libswscale.so.3
ln -s /usr/local/lib/libavutil.so.54 /usr/lib64/libavutil.so.54
ln -s /usr/local/lib/libopencore-amrwb.so.0 /usr/lib64/libopencore-amrwb.so.0
ln -s /usr/local/lib/libopencore-amrnb.so.0 /usr/lib64/libopencore-amrnb.so.0
ln -s /usr/local/lib/libmp3lame.so.0 /usr/lib64/libmp3lame.so.0