centos7.x安装FFMPEG
-
安装依赖
[root@content yukw]# # yum install autoconf automake bzip2 bzip2-devel cmake freetype-devel gcc gcc-c++ git libtool make pkgconfig zlib-devel
-
安装编译yasm
[root@content yukw]# mkdir /data/{src,service}
[root@content yukw]# cd /data/src
[root@content yukw]# wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
[root@content yukw]# tar xf yasm-1.3.0.tar.gz
[root@content yukw]# cd yasm-1.3.0/
[root@content yukw]# ./configure --enable-shared --prefix=/data/service/yasm
[root@content yukw]# make
[root@content yukw]# make install
--enable-shared是configure 常用的一个参数,表示启用动态库版本。
如果你要编译一个库的源代码,可以把它编译成静态库,也可以把它编译成动态库。如果你想编译成动态库,就用 --enable-shared参数;如果你想编译成静态库,就用--enable-static参数
-
安装编译ffmpeg
[root@content yukw]# cd ..
[root@content yukw]# wget http://www.ffmpeg.org/releases/ffmpeg-4.4.tar.gz
[root@content yukw]# tar xf ffmpeg-4.4.tar.gz
[root@content yukw]# cd ffmpeg-4.4/
[root@content yukw]# ./configure --enable-shared --disable-x86asm --prefix=/data/service/ffmpeg
[root@content yukw]# make
[root@content yukw]# make install
-
加载库文件
[root@content yukw]# vim /etc/ld.so.conf
include ld.so.conf.d/*.conf
/data/service/yasm/lib/
/data/service/ffmpeg/lib/
[root@content yukw]# ldconfig
[root@content yukw]# /data/service/ffmpeg/bin/ffmpeg -version
ffmpeg version 4.4 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-44)
configuration: --enable-shared --disable-x86asm --prefix=/data/service/ffmpeg
libavutil 56. 70.100 / 56. 70.100
libavcodec 58.134.100 / 58.134.100
libavformat 58. 76.100 / 58. 76.100
libavdevice 58. 13.100 / 58. 13.100
libavfilter 7.110.100 / 7.110.100
libswscale 5. 9.100 / 5. 9.100
libswresample 3. 9.100 / 3. 9.100
-
添加环境变量
[root@content yukw]# vim /etc/profile 添加如下四行
PATH=$PATH:/data/service/ffmpeg/bin
export PATH
PATH=$PATH:/data/service/yasm/bin
export PATH
[root@content yukw]# source /etc/profile
[root@content yukw]# ffmpeg -version
ffmpeg version 4.4 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-44)
configuration: --enable-shared --disable-x86asm --prefix=/data/service/ffmpeg
libavutil 56. 70.100 / 56. 70.100
libavcodec 58.134.100 / 58.134.100
libavformat 58. 76.100 / 58. 76.100
libavdevice 58. 13.100 / 58. 13.100
libavfilter 7.110.100 / 7.110.100
libswscale 5. 9.100 / 5. 9.100
libswresample 3. 9.100 / 3. 9.100
参考官网文档:CompilationGuide/Centos – FFmpeg
好了,这就是centos7.x安装FFMPEG的方法了,如有问题可与博主一起交流讨论!