安装环境:centos6.5, ffmpeg4.2
ffmpeg没有libx264库,需要在configure的时候链接x264库的头文件路径和库文件路径
安装x264
[root@localhost zyl]# wget ftp://ftp.videolan.org/pub/videolan/x264/snapshots/last_stable_x264.tar.bz2
[root@localhost zyl]# tar -xvf last_stable_x264.tar.bz2
[root@localhost zyl]# cd x264-snapshot-20190911-2245-stable
[root@localhost x264-snapshot-20190911-2245-stable]# mkdir build
[root@localhost x264-snapshot-20190911-2245-stable]# ./configure --prefix=/home/zyl/x264-snapshot-20190911-2245-stable/build --enable-shared --enable-pic --disable-asm
[root@localhost x264-snapshot-20190911-2245-stable]# make
[root@localhost x264-snapshot-20190911-2245-stable]# make install
x264头文件和动态库生成在build目录下
[root@localhost x264-snapshot-20190911-2245-stable]# export PKG_CONFIG_PATH=/home/zyl/x264-snapshot-20190911-2245-stable/build/lib/pkgconfig:$PKG_CONFIG_PATH
[root@localhost zyl]# cd ffmpeg-4.2
[root@localhost ffmpeg-4.2]# mkdir build
[root@localhost ffmpeg-4.2]# ./configure --prefix=/home/zyl/ffmpeg-4.2/build --enable-gpl --enable-libx264 --extra-cflags=-I/home/zyl/x264-snapshot-20190911-2245-stable/build/include --extra-ldflags=-L/home/zyl/x264-snapshot-20190911-2245-stable/build/lib --disable-x86asm
[root@localhost ffmpeg-4.2]# make clean;make;make install
注:ffmpeg引用x264库需要指明其头文件和库目录
注:重新配置ffmpeg的时候可能会出现这个警告:
WARNING: using libx264 without pkg-config
在这篇链接:http://www.ffmpeg-archive.org/Using-without-pkg-config-td4675568.html
提到可以忽略该警告。