Centos部署ffmpeg

为了进行小程序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
  • 1
  • 2
  • 3
  • 4
  • 5

  • 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
  • 1
  • 2
  • 3
  • 4
  • 5

  • 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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

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 --prefix=/usr &&
make
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

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 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

  • libdts 
    解码器,可以解DVD DTS Audio 格式的文件 
    包下载地址
./configure  
make  
make install 
  • 1
  • 2
  • 3

  • a52
wget http://liba52.sourceforge.net/files/a52dec-0.7.4.tar.gz

./configure  
make  
make install
  • 1
  • 2
  • 3
  • 4
  • 5
  • faad2
wget  http://downloads.sourceforge.net/faac/faad2-2.7.tar.gz

./configure  
make  
make install
  • 1
  • 2
  • 3
  • 4
  • 5

  • faac
wget  http://downloads.sourceforge.net/faac/faac-1.28.tar.gz

./configure  
make  
make install
  • 1
  • 2
  • 3
  • 4
  • 5

  • amr-nb
wget  http://ftp.penguin.cz/pub/users/utx/amr/amrnb-6.1.0.1.tar.bz2
./configure  
make  
make install
  • 1
  • 2
  • 3
  • 4

  • amr-wb
wget http://ftp.penguin.cz/pub/users/utx/amr/amrwb-6.0.0.1.tar.bz2
./configure  
make  
make install
  • 1
  • 2
  • 3
  • 4

  • 安装ffmpeg
wget  http://www.ffmpeg.org/releases/ffmpeg-3.1.tar.gz

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 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

接下来会一堆报错:

  • 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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
修改后
#ifdef __cplusplus
extern "C++" {
#endif
const char *strcasestr(const char *haystack, const char *needle);
#ifdef __cplusplus
}
#endif
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
 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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 提示: 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 
  • 1
  • 2

这里写图片描述


以上环境变量只会对当前一个shell进行匹配,后面的shell就需要再一次声明。因此如果你需要长期使用可以通过下面这篇文章配置环境变量。Linux配置环境变量的3中方法

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值