文章目录
- 前言
- 依赖安装
- 1. libarchive-3.5.2
- 2. libuv-v.1.42.0
- 3. CMake-3.21.3
- 4. NASM-2.15.05
- 5. yasm-1.3.0
- 6. fdk-aac-2.0.2
- 7. x265-3.4
- 8. x264-20210814
- 9. Opus-1.3.1
- 10. libvpx-1.11.0
- 11. libogg-1.3.5
- 12. libvorbis-1.3.7
- 13. libtheora-1.1.1
- 14. LAME-3.100
- 15. libwebp-1.2.1
- 16. libpng-1.6.37
- 17. OpenJPEG-2.4.0
- 18. Speex-1.2.0
- 19. Speexdsp-1.2.0
- 20. FriBidi-1.0.9
- 21. FreeType-2.11.0
- 22. Fontconfig-2.13.1
- 23. HarfBuzz-2.9.0
- 24. 安装完harfbuzz 重装 FreeType-2.11.0
- 25. libass-0.14.0
- 26. nv-codec-headers-9.1.23.3
- ffmpeg-4.4
前言
ffmpeg4.4 源码安装依赖的版本问题很多,以下命令在CentOS7.x,nv-codec-headers-9.23.3上实验通过。
依赖安装
1. libarchive-3.5.2
> wget https://github.com/libarchive/libarchive/releases/download/v3.5.2/libarchive-3.5.2.tar.xz
> tar -xvf libarchive-3.5.2.tar.xz
> cd libarchive-3.5.2
> sh autogen.sh &&
./configure --prefix=/usr --disable-static &&
make
> make install
2. libuv-v.1.42.0
> yum install -y libtool
> wget https://dist.libuv.org/dist/v1.42.0/libuv-v1.42.0.tar.gz
> tar -xvf libuv-v1.42.0.tar.gz
> cd libuv-v1.42.0
> sh autogen.sh &&
./configure --prefix=/usr --disable-static &&
make
> make install
3. CMake-3.21.3
> wget https://cmake.org/files/v3.21/cmake-3.21.3.tar.gz
> tar -xvf cmake-3.21.3.tar.gz
> cd cmake-3.21.3
> sed -i '/"lib64"/s/64//' Modules/GNUInstallDirs.cmake &&
./bootstrap --prefix=/usr \
--system-libs \
--mandir=/share/man \
--no-system-jsoncpp \
--no-system-librhash \
--docdir=/share/doc/cmake-3.21.3 &&
make
> make install
4. NASM-2.15.05
> wget https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/nasm-2.15.05.tar.xz
> tar -xvf nasm-2.15.05.tar.xz
> cd nasm-2.15.05
> ./configure --prefix=/usr &&
make
> make install
5. yasm-1.3.0
> wget https://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
> tar -xvf yasm-1.3.0.tar.gz
> cd yasm-1.3.0
> sed -i 's#) ytasm.*#)#' Makefile.in &&
./configure --prefix=/usr &&
make
> make install
6. fdk-aac-2.0.2
> wget https://downloads.sourceforge.net/opencore-amr/fdk-aac-2.0.2.tar.gz
> tar -xvf fdk-aac-2.0.2.tar.gz
> cd fdk-aac-2.0.2
> ./configure --prefix=/usr --disable-static &&
make
> make install
7. x265-3.4
> wget https://anduin.linuxfromscratch.org/BLFS/x265/x265_3.4.tar.gz
> tar -xvf x265_3.4.tar.gz
> cd x265_3.4
> mkdir bld &&
cd bld &&
cmake -DCMAKE_INSTALL_PREFIX=/usr ../source &&
make
> make install &&
rm -vf /usr/lib/libx265.a
8. x264-20210814
> wget https://anduin.linuxfromscratch.org/BLFS/x264/x264-20210814.tar.xz
> tar -xvf x264-20210814.tar.xz
> cd x264-20210814
> ./configure --prefix=/usr \
--enable-shared \
--disable-cli &&
make
> make install
9. Opus-1.3.1
> wget https://archive.mozilla.org/pub/opus/opus-1.3.1.tar.gz
> tar -xvf opus-1.3.1.tar.gz
> cd opus-1.3.1
> ./configure --prefix=/usr \
--disable-static \
--docdir=/usr/share/doc/opus-1.3.1 &&
make
> make install
10. libvpx-1.11.0
> wget https://github.com/webmproject/libvpx/archive/v1.11.0/libvpx-1.11.0.tar.gz
> tar -xvf libvpx-1.11.0.tar.gz
> cd libvpx-1.11.0
> sed -i 's/cp -p/cp/' build/make/Makefile &&
mkdir libvpx-build &&
cd libvpx-build &&
../configure --prefix=/usr \
--enable-shared \
--disable-static &&
make
> make install
11. libogg-1.3.5
> wget https://downloads.xiph.org/releases/ogg/libogg-1.3.5.tar.xz
> tar -xvf libogg-1.3.5.tar.xz
> cd libogg-1.3.5
> ./configure --prefix=/usr \
--disable-static \
--docdir=/usr/share/doc/libogg-1.3.5 &&
make
> make install
12. libvorbis-1.3.7
> wget https://downloads.xiph.org/releases/vorbis/libvorbis-1.3.7.tar.xz
> tar -xvf libogg-1.3.5.tar.xz
> cd libogg-1.3.5
> ./configure --prefix=/usr --disable-static &&
make
> make install &&
install -v -m644 doc/Vorbis* /usr/share/doc/libvorbis-1.3.7
13. libtheora-1.1.1
> wget https://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.xz
> tar -xvf libtheora-1.1.1.tar.xz
> cd libtheora-1.1.1
> sed -i 's/png_\(sizeof\)/\1/g' examples/png2theora.c &&
./configure --prefix=/usr --disable-static &&
make
> make install
14. LAME-3.100
> wget https://downloads.sourceforge.net/lame/lame-3.100.tar.gz
> tar -xvf lame-3.100.tar.gz
> cd lame-3.100
> ./configure --prefix=/usr --enable-mp3rtp --disable-static &&
make
> make pkghtmldir=/usr/share/doc/lame-3.100 install
15. libwebp-1.2.1
> wget http://downloads.webmproject.org/releases/webp/libwebp-1.2.1.tar.gz
> tar -xvf libwebp-1.2.1.tar.gz
> cd libwebp-1.2.1
> ./configure --prefix=/usr \
--enable-libwebpmux \
--enable-libwebpdemux \
--enable-libwebpdecoder \
--enable-libwebpextras \
--enable-swap-16bit-csp \
--disable-static &&
make
> make pkghtmldir=/usr/share/doc/lame-3.100 install
16. libpng-1.6.37
> yum install -y patch # 1)
> wget https://downloads.sourceforge.net/libpng/libpng-1.6.37.tar.xz
> wget https://downloads.sourceforge.net/sourceforge/libpng-apng/libpng-1.6.37-apng.patch.gz # 2)
> tar -xvf libpng-1.6.37.tar.xz
> cd libpng-1.6.37
> gzip -cd ../libpng-1.6.37-apng.patch.gz | patch -p1 # 3)
> ./configure --prefix=/usr --disable-static &&
make
> make install &&
mkdir -v /usr/share/doc/libpng-1.6.37 &&
cp -v README libpng-manual.txt /usr/share/doc/libpng-1.6.37
1)、2)、3)都是为了支持apng,如果不需要,可以不用打这个patch,就可以省略这个步骤
17. OpenJPEG-2.4.0
> wget https://github.com/uclouvain/openjpeg/archive/v2.4.0/openjpeg-2.4.0.tar.gz
> tar -xvf openjpeg-2.4.0.tar.gz
> cd openjpeg-2.4.0
> mkdir -v build &&
cd build &&
cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
-DBUILD_STATIC_LIBS=OFF .. &&
make
> make install &&
pushd ../doc &&
for man in man/man?/* ; do
install -v -D -m 644 $man /usr/share/$man
done
popd
18. Speex-1.2.0
> wget https://downloads.xiph.org/releases/speex/speex-1.2.0.tar.gz
> tar -xvf speex-1.2.0.tar.gz
> cd speex-1.2.0
> ./configure --prefix=/usr \
--disable-static \
--docdir=/usr/share/doc/speex-1.2.0 &&
make
> make install
19. Speexdsp-1.2.0
> wget https://downloads.xiph.org/releases/speex/speexdsp-1.2.0.tar.gz
> tar -xvf speexdsp-1.2.0.tar.gz
> cd speexdsp-1.2.0
> ./configure --prefix=/usr \
--disable-static \
--docdir=/usr/share/doc/speexdsp-1.2.0 &&
make
> make install
20. FriBidi-1.0.9
> wget https://github.com/fribidi/fribidi/releases/download/v1.0.9/fribidi-1.0.9.tar.xz
> tar -xvf fribidi-1.0.9.tar.xz
> cd fribidi-1.0.9
> ./configure --prefix=/usr \
--disable-static &&
make
> make install
21. FreeType-2.11.0
> wget https://downloads.sourceforge.net/freetype/freetype-2.11.0.tar.xz
> tar -xvf freetype-2.11.0.tar.xz
> cd freetype-2.11.0
> sed -ri "s:.*(AUX_MODULES.*valid):\1:" modules.cfg &&
sed -r "s:.*(#.*SUBPIXEL_RENDERING) .*:\1:" \
-i include/freetype/config/ftoption.h &&
./configure --prefix=/usr --enable-freetype-config --disable-static &&
make
> make install
22. Fontconfig-2.13.1
> yum install -y gperf uuid-devel
> wget https://www.freedesktop.org/software/fontconfig/release/fontconfig-2.13.1.tar.bz2
> tar -xvf fontconfig-2.13.1.tar.bz2
> cd fontconfig-2.13.1
> ./configure --prefix=/usr \
--sysconfdir=/etc \
--localstatedir=/var \
--disable-docs \
--docdir=/usr/share/doc/fontconfig-2.13.1 &&
make
> make install
23. HarfBuzz-2.9.0
> yum install -y icu harfbuzz-icu harfbuzz-devel
> wget https://github.com/harfbuzz/harfbuzz/releases/download/2.9.0/harfbuzz-2.9.0.tar.xz
> tar -xvf harfbuzz-2.9.0.tar.xz
> cd harfbuzz-2.9.0
> ./configure --prefix=/usr \
--disable-static &&
make
> make install
24. 安装完harfbuzz 重装 FreeType-2.11.0
> cd freetype-2.11.0
> make uninstall && make clean
> ./configure --prefix=/usr --enable-freetype-config --disable-static &&
make
> make install
25. libass-0.14.0
> 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 --disable-static &&
make
> make install
26. nv-codec-headers-9.1.23.3
> wget https://github.com/FFmpeg/nv-codec-headers/releases/download/n9.1.23.3/nv-codec-headers-9.1.23.3.tar.gz
> tar -xvf nv-codec-headers-9.1.23.3.tar.gz
> cd nv-codec-headers-9.1.23.3
> make && make install
显卡的驱动版本要和nv-codec-headers版本对应
FFmpeg version of headers required to interface with Nvidias codec APIs.
Corresponds to Video Codec SDK version 9.1.23.
Minimum required driver versions:
Linux: 435.21 or newer
Windows: 436.15 or newer
ffmpeg-4.4
> yum install -y openssl-devel
> export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH
> sed -i 's/-lflite"/-lflite -lasound"/' configure &&
./configure --prefix=/usr \
--enable-gpl \
--enable-version3 \
--enable-nonfree \
--enable-pic \
--disable-static \
--enable-shared \
--disable-debug \
--enable-avresample \
--enable-libass \
--enable-libfdk-aac \
--enable-libfreetype \
--enable-libmp3lame \
--enable-libopus \
--enable-libtheora \
--enable-libvorbis \
--enable-libvpx \
--enable-libx264 \
--enable-libx265 \
--enable-openssl \
--enable-libwebp \
--enable-libspeex \
--enable-libfribidi \
--enable-fontconfig \
--enable-libopenjpeg \
--enable-libnpp \
--enable-cuda \
--enable-cuvid \
--enable-nvdec \
--enable-nvenc \
--enable-ffnvcodec \
--extra-cflags=-I/usr/local/cuda/include \
--extra-ldflags=-L/usr/local/cuda/lib64 \
--docdir=/usr/share/doc/ffmpeg-4.4 &&
make
> make install
如果编译ffmpeg发现报 -fPIC
错误,检查一下是不是没有加上--enable-pic
。
或者
> sed -i 's/-lflite"/-lflite -lasound"/' configure &&
./configure --prefix=/usr \
--enable-gpl \
--enable-version3 \
--enable-nonfree \
--enable-pic \
--disable-static \
--enable-shared \
--disable-debug \
--enable-avresample \
--enable-libass \
--enable-libfdk-aac \
--enable-libfreetype \
--enable-libmp3lame \
--enable-libopus \
--enable-libtheora \
--enable-libvorbis \
--enable-libvpx \
--enable-libx264 \
--enable-libx265 \
--enable-openssl \
--docdir=/usr/share/doc/ffmpeg-4.4 &&
make &&
gcc tools/qt-faststart.c -o tools/qt-faststart
> make install
依赖:
- libass-0.15.2
- fdk-aac-2.0.2
- FreeType-2.11.0
- LAME-3.100
- libtheora-1.1.1
- libvorbis-1.3.7
- libvpx-1.10.0
- Opus-1.3.1
- x264-20210814
- x265-3.4
- NASM-2.15.05
- yasm-1.3.0
参考文档