centos下编译ffmpeg增加x264模块

1,编译x264库

cd x264

./configure –enable-shared –disable-yasm –enable-libx264 –enable-gpl

make

make install

2,编译ffmpeg

./configure –enable-static –disable-shared –disable-yasm –enable-gpl –disable-libx264 –disable-librtmp –enable-shared –disable-yasm –enable-libx264 –enable-gpl –extra-cflags=-I/usr/local/include –extra-ldflags=-L/usr/local/lib –prefix=/usr/local

make

make install

默认情况下安装到/usr/local,如需改变路径,修改–prefix参数。

3,排错和环境变量

安装完成后运行ffmpeg会有下列错误,不能运行

ffmpeg: error while loading shared libraries: libavdevice.so.58: cannot open shared object file: No such file or directory


查看ffmpeg所需要的库,有些so文件找不到

ldd /usr/local/bin/ffmpeg


查到ffmpeg所需要的的so文件在/usr/local/lib,增加环境变量配置

export LD_LIBRARY_PATH=/usr/local/lib/

再看ldd,so文件已经能够找到


可看到模块信息,已有libx264

 

lib-x264.zip
ffmpeg-4.2.3.zip

本文链接地址: https://danteng.org/centos-recompiling-ffmpeg-to-install-x264-module/