先创建三个文件夹:ffmpeg_sources ffmpeg_build bin
sudo apt-get update -qq && sudo apt-get -y install \
autoconf \
automake \
build-essential \
cmake \
git-core \
libass-dev \
libfreetype6-dev \
libsdl2-dev \
libtool \
libva-dev \
libvdpau-dev \
libvorbis-dev \
libxcb1-dev \
libxcb-shm0-dev \
libxcb-xfixes0-dev \
pkg-config \
texinfo \
wget \
zlib1g-dev
An assembler used by some libraries.
cd ~/ffmpeg_sources &&\
wget https://www.nasm.us/pub/nasm/releasebuilds/2.13.03/nasm-2.13.03.tar.bz2 &&\
tar xjvf nasm-2.13.03.tar.bz2 &&\
cd nasm-2.13.03 &&\./autogen.sh &&\
PATH="$HOME/bin:$PATH" ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin"&&\
make &&\
make install
cd ~/ffmpeg_sources &&\
wget -O yasm-1.3.0.tar.gz https://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz &&\
tar xzvf yasm-1.3.0.tar.gz &&\cd yasm-1.3.0 &&\./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin"&&\
make &&\
sudo make install
libx264的包通过以下途径在编译的时候可能会出现error,实际的安装过程中,采用的是
http://101.96.10.64/download.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20180604-2245-stable.tar.bz2
sudo apt-get install libx265-dev
cd ~/ffmpeg_sources &&\
git -C x264 pull 2> /dev/null || git clone --depth 1 https://git.videolan.org/git/x264 &&\
cd x264 &&\
PATH="$HOME/bin:$PATH"PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" --enable-static --enable-pic &&\
PATH="$HOME/bin:$PATH" make &&\
sudo make install
sudo apt-get install mercurial libnuma-dev &&\
cd ~/ffmpeg_sources &&\
if cd x265 2> /dev/null; then hg pull && hg update; else hg clone https://bitbucket.org/multicoreware/x265; fi&&\
cd x265/build/linux &&\
PATH="$HOME/bin:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg_build" -DENABLE_SHARED=off ../../source &&\
PATH="$HOME/bin:$PATH" make &&\
make install
sudo apt-get install libx265-dev
git上的包可能会出现下载超时,在实际的安装中,使用的是
http://www.loongnix.org/cgit/libvpx/snapshot/libvpx-1.7.0.tar.bz2
tar xjvf
cd ~/ffmpeg_sources &&\
git -C libvpx pull 2> /dev/null || git clone --depth 1 https://chromium.googlesource.com/webm/libvpx.git &&\
cd libvpx &&\
PATH="$HOME/bin:$PATH" ./configure --prefix="$HOME/ffmpeg_build" --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm &&\
PATH="$HOME/bin:$PATH" make &&\
make install
cd ~/ffmpeg_sources &&\
git -C fdk-aac pull 2> /dev/null || git clone --depth 1 https://github.com/mstorsjo/fdk-aac &&\
cd fdk-aac &&\
autoreconf -fiv &&\
./configure --prefix="$HOME/ffmpeg_build" --disable-shared &&\
make &&\
make install
在安装的过程中安装过该包,但在最后的编译过程中添加该包会导致编译出错,所以在编译的时候未添加选项 --enable-libmp3lame
cd ~/ffmpeg_sources &&\
wget -O lame-3.100.tar.gz https://downloads.sourceforge.net/project/lame/lame/3.100/lame-3.100.tar.gz &&\
tar xzvf lame-3.100.tar.gz &&\
cd lame-3.100 &&\
PATH="$HOME/bin:$PATH" ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" --disable-shared --enable-nasm &&\
PATH="$HOME/bin:$PATH" make &&\
make install
在安装的过程中安装过该包,但在最后的编译过程中添加该包会导致编译出错,所以在编译的时候未添加选项 --enable-libopus
同时,通过git在https://github.com/xiph/opus.git上下载很慢,可以通过迅雷先去改网址上下载
cd ~/ffmpeg_sources &&\
git -C opus pull 2> /dev/null || git clone --depth 1 https://github.com/xiph/opus.git &&\
cd opus &&\
./autogen.sh &&\
./configure --prefix="$HOME/ffmpeg_build" --disable-shared &&\
make &&\
make install
10.最后安装ffmpeg
首先下载3.4.3版本
http://101.96.10.64/ffmpeg.org/releases/ffmpeg-3.4.3.tar.bz2
tar xjvf ffmpeg-3.4.3.tar.bz2
cd ffmpeg-3.4.3
./configure --enable-shared
make
make install
修改文件/etc/ld.so.conf 中增加/usr/local/ffmpeg/lib
使其生效:ldconfig
第八步:加入环境变量:vi /etc/profile
最后一行:export FFMPEG_HOME=/usr/local/ffmpeg
export PATH=$FFMPEG_HOME/bin:$PATH
使环境变量生效:source /etc/profile
inflateValidate@ZLIB_1.2.9
下载更新libpng和zlib解决