安装依赖库:
apt -y install autoconf automake build-essential libtool libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev pkg-config texinfo zlib1g-dev
apt -y install libass-dev libfreetype6-dev libmp3lame-dev libtheora-dev libvorbis-dev libopus-dev libx264-dev yasm
apt -y install libva-dev libvdpau-dev libsdl2-dev
实际编译时,建议自行下载编译。原因是:这样目录中会包含自己编译的所有库,到别的机器上也能跑。
aac
wget http://downloads.sourceforge.net/opencore-amr/fdk-aac-0.1.5.tar.gz tar xf fdk-aac-0.1.5.tar.gz ./configure --prefix="$HOME/ffmpeg_build" --disable-shared make make install # make distclean
libvpx
wget http://storage.googleapis.com/downloads.webmproject.org/releases/webm/libvpx-1.6.1.tar.bz2 tar xf libvpx-1.6.1.tar.bz2 cd libvpx-1.6.1 PATH="$HOME/bin:$PATH" ./configure --prefix="$HOME/ffmpeg_build" --disable-examples --disable-unit-tests PATH="$HOME/bin:$PATH" make make install # make distclean
x265
sudo apt-get install cmake mercurial wget https://bitbucket.org/multicoreware/x265/downloads/x265_2.4.tar.gz tar xf x265_2.4.tar.gz cd x265_2.4/build/linux PATH="$HOME/bin:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg_build" -DENABLE_SHARED:bool=off ../../source make make install # make clean
x264
wget https://download.videolan.org/x264/snapshots/x264-snapshot-20170822-2245-stable.tar.bz2 tar xf x264-snapshot-20170822-2245-stable.tar.bz2 cd x264-snapshot-20170822-2245-stable ./configure --prefix="$HOME/ffmpeg_build" --enable-shared --enable-pic make make install # make distclean
FFmpeg
PATH="$HOME/bin:$PATH" PATH=/usr/bin:${PATH} export PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure --prefix="$HOME/ffmpeg_build" --pkg-config-flags="--static" --extra-cflags="-I$HOME/ffmpeg_build/include" --extra-ldflags="-L$HOME/ffmpeg_build/lib" --bindir="$HOME/bin" --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree # --enable-libx265 PATH="$HOME/bin:$PATH" make make install # make distclean
编译过程中发现x265自己编译和安装,都提示有问题。
如果发现缺少什么,参考: