CentOS下編譯安裝FFmpeg+libass

1 安裝x264相關(guān)庫

如果x264在編譯安裝時提示錯誤: Minimum version is nasm-2.13,則需要先安裝nasm:

wget "http://www.nasm.us/pub/nasm/releasebuilds/2.13.01/nasm-2.13.01.tar.xz"

tar xvf nasm-2.13.01.tar.xz

cd nasm-2.13.01

./configure

make&make install

安裝 x264

wget "https://download.videolan.org/pub/videolan/x264/snapshots/last_stable_x264.tar.bz2"

tar xvf last_stable_x264.tar.bz2

cd x264-snapshot-20180607-2245-stable/

./configure --prefix=/usr/local/x264 --enable-shared --enable-static

make&make install


2 安裝 libfreetype

如果ffmpeg編譯參數(shù)包含 --enable-libass 則需要先安裝 libfreetype fribidi fontconfig libass

wget "https://download.savannah.gnu.org/releases/freetype/freetype-2.9.1.tar.gz"

tar zxvf freetype-2.9.1.tar.gz

cd freetype-2.9.1/

./configure --prefix=/usr/local --disable-static

make

make install


3 安裝 fribidi

wget "https://github.com/fribidi/fribidi/releases/download/v1.0.4/fribidi-1.0.4.tar.bz2"

tar xf fribidi-1.0.4.tar.bz2

cd fribidi-1.0.4

./configure --prefix=/usr/local/ --enable-shared

make

make install


4 安裝 fontconfig

為防止出現(xiàn)找不到 libfreetype 的錯誤,首先修改 PKG_CONFIG_PATH 環(huán)境變量:

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH

wget "https://www.freedesktop.org/software/fontconfig/release/fontconfig-2.13.0.tar.gz"

tar zxvf fontconfig-2.13.0.tar.gz

cd fontconfig-2.13.0

./configure --prefix=/usr/local/ --enable-shared --enable-libxml2

make

make install


如果報錯 No package 'uuid' found 則按如下步驟解決:

yum -y install libuuid-devel


如果報錯 WARNING: 'gperf' is missing on your system. 則按如下步驟解決:

wget http://mirrors.ustc.edu.cn/gnu/gperf/gperf-3.1.tar.gz

tar zxvf gperf-3.1.tar.gz

cd gperf-3.1

./configure

make

make install


5 安裝 libass

wget https://github.com/libass/libass/releases/download/0.14.0/libass-0.14.0.tar.xz

tar xvf libass-0.14.0.tar.xz

cd libass-0.14.0

./configure --prefix=/usr/local/ --disable-static

make

make install


6 安裝 ffmpeg

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH

wget "http://ffmpeg.org/releases/ffmpeg-3.4.tar.bz2"

tar xvf ffmpeg-3.4.tar.bz2

cd ffmpeg-3.4

./configure --prefix=/usr/local/ffmpeg3.4/ --enable-shared --enable-gpl --enable-libx264 --extra-cflags=-I/usr/local/x264/include --extra-ldflags=-L/usr/local/x264/lib --enable-libass

make

make install

#######重要事項#######

extra-cflags 和 extra-ldflags 兩個參數(shù)不指定對應(yīng)路徑會一直報這個錯誤,花了挺長時間來找解決方法,還是挺郁悶的,希望看到的朋友不要再走彎路了。

libavcodec/libavcodec.so: undefined reference to `x264_encoder_open_152'


7 編譯完成后,在 /etc/profile 文件下增加如下字段:

FFMPEG=/usr/local/ffmpeg3.4

X264=/usr/local/x264

export FFMPEG X264

export PATH=$PATH:$FFMPEG/bin:$X264/bin

export LD_LIBRARY_PATH=$X264/lib:$FFMPEG/lib:$LD_LIBRARY_PATH

這樣ffmpeg就能在linux環(huán)境下使用了。


8 php通過exec調(diào)用ffmpeg如出現(xiàn)權(quán)限問題或以下錯誤:

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

解決方法:

vi /etc/ld.so.conf


文件中添加以下內(nèi)容:

include ld.so.conf.d/*.conf

include /usr/local/lib

/usr/local/ffmpeg3.4/lib

/usr/local/x264/lib


執(zhí)行l(wèi)dconfig命令進行更新路徑:

ldconfig

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容