1.第一步安装 yasm
yum install yasm
2.第二步安装x264
cd /usr/local/
git clone https://git.videolan.org/git/x264.git  或者  https://gitee.com/Weydon-Ding/x264.git
cd x264
./configure --prefix=/usr/local/x264 --enable-shared --enable-static --disable-asm
make
make install
3.第三步安装ffmpeg
cd /usr/local/
wget http://ffmpeg.org/releases/ffmpeg-4.3.tar.bz2
tar -xvjf ffmpeg-4.3
cd ffmpeg-4.3
./configure --prefix=/usr/local/ffmpeg --enable-shared --enable-yasm --enable-libx264 --enable-gpl --enable-pthreads --extra-cflags=-I/usr/local/x264/include --extra-ldflags=-L/usr/local/x264/lib
make -j7
make install
4.第四步修改配置
vim /etc/ld.so.conf
在文件末尾加上
include ld.so.conf.d/*.conf  如果有了 就不需要
/usr/local/ffmpeg/lib/
/usr/local/x264/lib
保存 
ldconfig

注意

出现以下错误1
WARNING: The --enable-yasm option is only provided for compatibility and will be
 removed in the future. Use --enable-x86asm / --disable-x86asm instead.
WARNING: using libx264 without pkg-config

解决方法:
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
出现以下错误2

./ffmpeg: error while loading shared libraries: libx264.so.138: cannot open shared object file: No such file or directory
解决方法:
1. 查看ld.so.conf文件
vi /etc/ld.so.conf
添加/usr/local/x264/lib,如下
include ld.so.conf.d/*.conf
/usr/local/x264/lib
wq退出ld.so.conf文件
2. 执行 ldconfig