1. 從FFmpeg的Github上下載源碼
git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
2. 安裝
./configure --prefix=/usr/local/ffmpeg --enable-shared --disable-static --disable-doc --enable-ffplay --disable-x86asm
make
sudo make install
3. 環(huán)境變量
sudo vim /etc/profile
添加以下內(nèi)容
export FFMPEG_HOME=/usr/local/ffmpeg
export PATH=$PATH:$FFMPEG_HOME/bin
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
保存退出后,使配置生效
source /etc/profile
在/etc/ld.so.conf.d/下添加以下文件
ffmpeg.conf
內(nèi)容為lib目錄
/usr/local/ffmpeg/lib
使配置生效
sudo ldconfig
4. 配置pkg-config(可選)
mkdir /usr/local/lib/pkgconfig/
cp /usr/local/ffmpeg/lib/pkgconfig/*.pc /usr/local/lib/pkgconfig/
測(cè)試
pkg-config --libs libavcodec libavdevice libavfilter libavformat libavutil libswresample libswscale
編譯方法
g++ main.c -o main.o -I /usr/ffmpeg/include `pkg-config libavcodec libavdevice libavfilter libavformat libavutil libswresample libswscale --cflags --libs`
相當(dāng)于
g++ main.c -o main.o -I /usr/local/ffmpeg/include -L /usr/ffmpeg/lib -lavcodec -lavdevice -lavfilter -lavformat -lavutil -lswresample -lswscale
========================== 2019.7.17 補(bǔ)充 ==========================
添加libx264
git clone http://git.videolan.org/git/x264.git
cd x264/
./configure --enable-shared --disable-asm
make
sudo make install
重新編譯FFmpeg
./configure --prefix=/usr/ffmpeg --enable-shared --disable-static --disable-doc --enable-libx264 --enable-gpl --disable-asm
參考:
https://www.cnblogs.com/boonya/p/8571934.html
https://blog.csdn.net/liangchunjiang/article/details/78774643