为了进行小程序silk语音的转码,需要在服务器上配置ffmpeg的环境。接下来我以centos的linux系统作为基础进行介绍配置的操作。
配置
lame
wget https://nchc
.dl.sourceforge.net/project/lame/lame/
3.99/lame-
3.99.tar.gz
tar -zxvf lame-
3.99.tar.gz
cd lame-
3.99
./configure --enable-shared && make &&make install
12345
libogg
wget http://downloads
.xiph.org/releases/ogg/libogg-
1.3.2.tar.gz
tar -zxvf libogg-
1.3.2.tar.gz
cd libogg-
1.3.2
./configure && make &&make install
12345
libvorbis
wget http://downloads
.xiph.org/releases/vorbis/libvorbis-
1.3.3.tar.gz
# 注意(libvorbis依赖于libogg, 所以libogg必须先于libvorbis安装)
tar -zxvf libvorbis-
1.3.3.tar.gz
cd libvorbis-
1.3.3
./configure && make &&make install
1234567
xvid 官网地址
wget
http://downloads.xvid.org/downloads/xvidcore-
1.3.3.tar.gz
cd xvidcore
cd build/generic &&
sed -i
's/^LN_S=@LN_S@/& -f -v/' platform.inc.
in &&
./configure
make
123456
x264 索引地址
wget ftp://ftp
.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-
20050824-
2219.tar
.bz2
tar -jxvf last_x264
.tar.bz2
./configure
make
make install
123456
libdts 解码器,可以解DVD DTS Audio 格式的文件 包下载地址
./configure
make
make install
123
a52
wget http://liba52
.sourceforge.net/files/a52dec-
0.7.4.tar.gz
./configure
make
make install
12345
faad2
wget http://downloads
.sourceforge.net/faac/faad2-
2.7.tar.gz
./configure
make
make install
12345
faac
wget http://downloads
.sourceforge.net/faac/faac-
1.28.tar.gz
./configure
make
make install
12345
amr-nb
wget http://ftp
.penguin.cz/pub/users/utx/amr/amrnb-
6.1.0.1.tar.bz2
./configure
make
make install
1234
amr-wb
wget http://ftp
.penguin.cz/pub/users/utx/amr/amrwb-
6.0.0.1.tar.bz2
./configure
make
make install
1234
安装ffmpeg
wget http:
tar
-zxvf ffmpeg
-3.1.tar
.gz
cd ffmpeg
-3.1
./configure
--prefix
=/usr/
local/ffmpeg3
--enable
-libmp3lame --enable
-libvorbis --enable
-gpl --enable
-version3 --enable
-nonfree --enable
-pthreads --enable
-libfaac --enable
-libopencore-amrnb --enable
-libopencore-amrwb --enable
-libx264 --enable
-libxvid --enable
-postproc --enable
-ffserver --enable
-ffplay
make
make install
12345678
接下来会一堆报错:
mpeg4ip.h:126: error: new declaration ‘char* strcasestr(const char*, const char*)’ 解决方法:
根据报错的Error信息进入对应的文件目录下修改mpeg4ip.h
修改前
#ifdef __cplusplus
extern
"C" {
#endif
char *strcasestr(
const char *haystack,
const char *needle);
#ifdef __cplusplus
}
#endif
1234567
修改后
#ifdef __cplusplus
extern
"C++" {
#endif
const char *strcasestr(
const char *haystack,
const char *needle);
#ifdef __cplusplus
}
#endif
1234567
编译时候出现ERROR的错误对应的提示修复操作方法
yasm错误需要安装yasm
wget http://www
.tortall.net/projects/yasm/releases/yasm-
1.2.0.tar.gz
tar xzvf yasm-
0.7.1.tar.gz
cd yasm-
0.7.1
./configure --prefix=/usr/local/yasm
make && make install
12345
提示: ERROR: libx264 must be installed and version must be >= 0.118. 需要去掉–enable-libx264我官网安装最新版,依然提示这个错误,暂时不知道解决办法。
/usr/local/ffmpeg3/bin/ffmpeg: error while loading shared libraries: libxvidcore.so.4: cannot open shared object file: No such file or directory
我们需要修改/etc/ld.so.conf内容增加/usr/local/lib/
保存退出后,需要执行ldconfig进行刷新缓存。
刷新成功进行/usr/local/ffmpeg3/bin/ffmpeg -version将看到上图内容。
配置环境变量
export PATH=/usr/local/ffmpeg3/bin/:
$PATH
env
12
以上环境变量只会对当前一个shell进行匹配,后面的shell就需要再一次声明。因此如果你需要长期使用可以通过下面这篇文章配置环境变量。Linux配置环境变量的3中方法