网上常见的在CentOS7 x64中安装x264和libav的方法是:
git clone http://git.videolan.org/git/x264.git ./configure –disable-asm make make install
wget http://download1.rpmfusion.org/free/el/updates/7/x86_64/x/x264-libs-0.148-24.20170521gitaaa9aa8.el7.x86_64.rpm wget http://download1.rpmfusion.org/free/el/updates/7/x86_64/x/x264-devel-0.148-24.20170521gitaaa9aa8.el7.x86_64.rpm rpm -hiv x264-libs-0.148-24.20170521gitaaa9aa8.el7.x86_64.rpm rpm -hiv x264-devel-0.148-24.20170521gitaaa9aa8.el7.x86_64.rpm cd /usr/local/src git clone https://gitee.com/nwaycn/libav.git cd libav ./configure --enable-pic --enable-shared --enable-libx264 --enable-gpl --extra-libs="-ldl" make make install cp /usr/local/lib/pkgconfig/libavcodec.pc /usr/lib64/pkgconfig/ cp /usr/local/lib/pkgconfig/libavdevice.pc /usr/lib64/pkgconfig/ cp /usr/local/lib/pkgconfig/libavfilter.pc /usr/lib64/pkgconfig/ cp /usr/local/lib/pkgconfig/libavformat.pc /usr/lib64/pkgconfig/ cp /usr/local/lib/pkgconfig/libavresample.pc /usr/lib64/pkgconfig/ cp /usr/local/lib/pkgconfig/libavutil.pc /usr/lib64/pkgconfig/ cp /usr/local/lib/pkgconfig/libswscale.pc /usr/lib64/pkgconfig/ ldconfig
但在个人环境中,如此编译过程中,总有报错。系统也是CentOS7 x64 2003版本,后来网上找了一套的x264和libav,编译起来没问题一直在用。
但近日在阿里云服务器上CentOS7.8 x64,用我找的这套编译又报错,主要是libav不能正常编译通过,修改代码要改的地方太多。
首先是:
libavcodec/libx264.c: In function 'X264_frame':libavcodec/libx264.c:246:9: error: 'x264_bit_depth' undeclared (first use in this function)if (x264_bit_depth > 8)^libavcodec/libx264.c:246:9: note: each undeclared identifier is reported only once for each function it appears inlibavcodec/libx264.c: In function 'X264_init_static'
找到该文件,将小写改为大写后,重新编译
undefined reference to x264_encoder_open_160
各种错误,要一点一点去改,太麻烦了。
于是再去尝试上面两种git clone方式,居然通过了,很神奇,先记录一下。