一、环境准备
yasm源码包下载: wget https://download.lixian.fun/Linux_LNMP_packers/yasm-1.3.0.tar.gz x264源码包下载: wget https://download.lixian.fun/Linux_LNMP_packers/x264.tar.gz ffmpeg源码包下载: wget https://download.lixian.fun/Linux_LNMP_packers/ffmpeg-snapshot.tar.bz2 nasm源码包下载: wget https://download.lixian.fun/Linux_LNMP_packers/nasm-2.13.03.tar.gz
上面是本博客系统内的安装包,直接在终端 wget 下载即可,如果链接失效
执行官方的地址(下载较慢)
ffmpeg(官方的目前是4.1的压缩包)wget https://ffmpeg.org/releases/ffmpeg-4.1.tar.bz2 x264(官方的)git clone https://git.videolan.org/git/x264.git nasm(官方的)wget https://www.nasm.us/pub/nasm/releasebuilds/2.14.02/nasm-2.14.02.tar.bz2 yasm(官方的)http://yasm.tortall.net/Download.html
依赖包安装
yum install -y autoconf automake cmake freetype-devel gcc gcc-c++ git libtool make mercurial nasm pkgconfig zlib-devel bzip2
二、编译安装yasm
#下载或者上传后解压 [root@ecs-7f06-10 ~]# tar xf yasm-1.3.0.tar.gz [root@ecs-7f06-10 ~]# cd yasm-1.3.0/ [root@ecs-7f06-10 yasm-1.3.0]# ./configure --prefix=/usr/local/yasm [root@ecs-7f06-10 yasm-1.3.0]# make && make install
三、编译安装nasm
编译x264库之前必须安装nasm组件,不然编译x264会失败
[root@ecs-7f06-10 ~]# tar xf nasm-2.13.03.tar.gz [root@ecs-7f06-10 ~]# cd nasm-2.13.03 [root@ecs-7f06-10 ~/nasm-2.13.03]# ./configure [root@ecs-7f06-10 ~/nasm-2.13.03]# make && make install
四、编译安装x264
[root@ecs-7f06-10 ~]# tar xf x264.tar.gz [root@ecs-7f06-10 ~]# cd x264/ [root@ecs-7f06-10 x264]# ./configure --prefix=/usr/local/x264 --enable-shared --enable-static --enable-yasm [root@ecs-7f06-10 x264]# make && make install
五、编译安装ffmpeg
[root@ecs-7f06-10 ~]# tar xf ffmpeg-snapshot.tar.bz2 [root@ecs-7f06-10 ~]# cd ffmpeg [root@ecs-7f06-10 ~/ffmpeg]# ./configure --prefix=/usr/local/ffmpeg --enable-libx264 --enable-gpl --enable-shared --extra-cflags=-I/usr/local/x264/include --extra-ldflags=-L/usr/local/x264/lib --enable-pic [root@ecs-7f06-10 ~/ffmpeg]# make && make install
六、配置环境变量
[root@ecs-7f06-10 ~]# vim /etc/profile export PATH=$PATH:/usr/local/ffmpeg/bin:/usr/local/yasm/bin:/usr/local/x264/bin [root@ecs-7f06-10 ~]# source /etc/profile
配置库路径
#编辑ld.so.conf文件,并且在最下面插入两行路径 [root@ecs-7f06-10 ~]# vim /etc/ld.so.conf /usr/local/ffmpeg/lib /usr/local/x264/lib [root@ecs-7f06-10 ~]# ldconfig
七、运行FFmpeg
[root@ecs-7f06-10 ~]# ffmpeg -encoders | grep libx264 ffmpeg version N-99192-g161495a Copyright (c) 2000-2020 the FFmpeg developers built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-39) configuration: --enable-libx264 --enable-gpl --enable-shared --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib --enable-pic libavutil 56. 59.100 / 56. 59.100 libavcodec 58.106.100 / 58.106.100 libavformat 58. 56.100 / 58. 56.100 libavdevice 58. 11.102 / 58. 11.102 libavfilter 7. 87.100 / 7. 87.100 libswscale 5. 8.100 / 5. 8.100 libswresample 3. 8.100 / 3. 8.100 libpostproc 55. 8.100 / 55. 8.100 V..... libx264 libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (codec h264) V..... libx264rgb libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 RGB (codec h264)