首页 > 技术文章 > Linux 安装编译 FFMPEG

chinda 2017-11-20 14:08 原文

资源准备:

ffmpeg-3.4.tar.bz2

yasm-1.3.0.tar.gz

编译安装:

本人二进制包存放在 /opt/moudles中, 解压缩在 /opt/softwares

解包 ffmpeg-3.4.tar.bz2

[root@localhost moudles]# tar -jxvf ffmpeg-3.4.tar.bz2 -C ../softwares/

在 /opt/softwares 中生成 文件夹。

解包 yasm-1.3.0.tar.gz

[root@localhost moudles]# tar -zxvf yasm-1.3.0.tar.gz -C ../softwares/

 /opt/softwares 中生成文件夹。

编译 yasm:

[root@localhost moudles]# cd /opt/softwares/yasm-1.3.0/

[root@localhost yasm-1.3.0]# ./configure 

[root@localhost yasm-1.3.0]# make && make install

编译 ffmpeg-3.4:

[root@localhost yasm-1.3.0]# cd /opt/softwares/ffmpeg-3.4/

[root@localhost ffmpeg-3.4]# ./configure --enable-shared --prefix=/usr/local/ffmpeg

[root@localhost ffmpeg-3.4]# make && make install

时间比较长, 耐心等待……

检测ffmpeg是否安装成功:

[root@localhost ffmpeg-3.4]# /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/

[root@localhost ffmpeg-3.4]# vim /etc/ld.so.conf

include ld.so.conf.d/*.conf

/usr/local/ffmpeg/lib/

使修改生效:

[root@localhost ffmpeg-3.4]# ldconfig 

 配置环境变量:

[root@localhost ffmpeg-3.4]# vim /etc/profile

 

 特别注意:若是不安装yasm, 直接编译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.

编译FFMPEG时,出现了 ffmpeg yasm not found, use --disable-yasm for a crippled build,是因为 FFMPEG为了提高编译速度,使用了汇编指令,如果系统中没有yasm指令的话,就会出现上述的问题。

 

附注:查找适合自己系统的yasm

yasm-releases

 

推荐阅读