您的位置:首页 > 运维架构 > Linux

Linux Centos 6.5 安装FFMPEG && 故障排查

2016-08-15 11:46 579 查看
首先在FFMEPG官网下载最新的FFMPEG的版本https://ffmpeg.org/download.html

下载的源码文件:ffmpeg-3.1.2.tar.bz2

上传至服务器之后进行解压操作:tar xvfj ffmpeg-3.1.2.tar.bz2

解压之后进入解压目录:

cd ffmpeg-3.1.2

编译安装:

./configure --enable-shared --prefix=/usr/local/ffmpeg

--enable-shared是允许其编译时产生动态库,在以后的开发过程中会用到这几个动态库

--prefix=/usr/local/ffmpeg  指定安装的路径

但是多数人在执行的时候会报如下错误:

yasm/nasm not found or too old. Use --disable-yasm for a crippled build.

If you think configure made a mistake, make sure you are using the latest
version from Git. If the latest version fails, report the problem to the
ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "config.log" produced by configure as this will help
solve the problem.这个错误说明服务器的yasm或者nasm版本过低过或者没有安装;
要解决这个问题很简单 安装对应的版本!

网站下载一个yasm,上传至服务器

如果yum库里面有yasm的话,直接执行yum install yasm

没有的话下载 http://yasm.tortall.net/Download.html

依次执行

 tar xzvf yasm-1.3.0.tar.gz

cd yasm-1.3.0

./configure

make

make install

时间大约在两分钟左右

安装yasm之后在进行安装ffmpeg就不会报上述错误

依次执行

cd ffmpeg-3.1.2

./configure --enable-shared --prefix=/usr/local/ffmpeg (时间也可能略长 不超过5分钟)

make (时间可能会比较长 五分钟左右)

make install

没有出现错误的话说明ffmpeg正常安装了

/usr/local/ffmpeg/bin/ffmpeg --version

会出现如下错误:

/usr/local/ffmpeg/bin/ffmpeg: error while loading shared libraries: libavdevice.so.56: cannot open shared object file: No such file or directory原因是相应的库文件没有找到

解决办法:
修改文件/etc/ld.so.conf 内容增加/usr/local/ffmpeg/lib/

依次敲:

vi /etc/ld.so.conf 

a (vim编辑器下的插入操作)

/usr/local/ffmpeg/lib/

ZZ
(保存退出)

为使修改生效

ldconfig

然后执行:/usr/local/ffmpeg/bin/ffmpeg -version

结果如下:



如上表示ffmpeg安装成功!

最后配置环境变量,使ffmpeg在如何目录下都可以执行

export PATH=/usr/local/ffmpeg/bin/:$PATH

env

如果想要使配置永久生效 :将配置写在profile中

vi /etc/profile

在尾部添加:export PATH=/usr/local/ffmpeg/bin/:$PATH

重启服务器即可!

运行测试代码:

ffmpeg -i 1.mp4 -b:v 640k output.ts

OK!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: