FFmpeg 编译 (For 树莓派 arm)
树莓派
参考 - Compiling FFmpeg on the Raspberry Pi
安装编译 依赖库
sudo apt -y install autoconf automake build-essential cmake doxygen git graphviz imagemagick libasound2-dev libass-dev libavcodec-dev libavdevice-dev libavfilter-dev libavformat-dev libavutil-dev libfreetype6-dev libgmp-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libopus-dev librtmp-dev libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-net-dev libsdl2-ttf-dev libsnappy-dev libsoxr-dev libssh-dev libssl-dev libtool libv4l-dev libva-dev libvdpau-dev libvo-amrwbenc-dev libvorbis-dev libwebp-dev libx264-dev libx265-dev libxcb-shape0-dev libxcb-shm0-dev libxcb-xfixes0-dev libxcb1-dev libxml2-dev lzma-dev meson nasm pkg-config python3-dev python3-pip texinfo wget yasm zlib1g-dev libdrm-dev
附加功能库
Before we get started, let’s create a directory where we will store the code for each of these libraries.
mkdir ~/ffmpeg-libraries
Fraunhofer FDK AAC library.
Compiling this library will allow FFmpeg to have support for the AAC sound format.
git clone --depth 1 https://github.com/mstorsjo/fdk-aac.git ~/ffmpeg-libraries/fdk-aac \
&& cd ~/ffmpeg-libraries/fdk-aac \
&& autoreconf -fiv \
&& ./configure \
&& make -j$(nproc) \
&& sudo make installcompile is the “dav1d” library.
Run the following command to compile and install the “dav1d” library to your Raspberry Pi.
git clone --depth 1 https://code.videolan.org/videolan/dav1d.git ~/ffmpeg-libraries/dav1d \
&& mkdir ~/ffmpeg-libraries/dav1d/build \
&& cd ~/ffmpeg-libraries/dav1d/build \
&& meson .. \
&& ninja \
&& sudo ninja installHEVC encoder called “kvazaar”.
git clone --depth 1 https://github.com/ultravideo/kvazaar.git ~/ffmpeg-libraries/kvazaar \
&& cd ~/ffmpeg-libraries/kvazaar \
&& ./autogen.sh \
&& ./configure \
&& make -j$(nproc) \
&& sudo make installVP8 and VP9 video codecs
FFmpeg to be able to support the VP8 and VP9 video codecs on our Raspberry Pi.
git clone --depth 1 https://chromium.googlesource.com/webm/libvpx ~/ffmpeg-libraries/libvpx \
&& cd ~/ffmpeg-libraries/libvpx \
&& ./configure --enable-pic--disable-examples --disable-tools --disable-unit_tests --disable-docs \ # --enable-shared
&& make -j$(nproc) \
&& sudo make installcompile the library called “AOM”
git clone --depth 1 https://aomedia.googlesource.com/aom ~/ffmpeg-libraries/aom \
&& mkdir ~/ffmpeg-libraries/aom/aom_build \
&& cd ~/ffmpeg-libraries/aom/aom_build \
&& cmake -G "Unix Makefiles" AOM_SRC -DENABLE_NASM=on -DPYTHON_EXECUTABLE="$(which python3)" -DCMAKE_C_FLAGS="-mfpu=vfp -mfloat-abi=hard" .. \
&& sed -i 's/ENABLE_NEON:BOOL=ON/ENABLE_NEON:BOOL=OFF/' CMakeCache.txt \
&& make -j$(nproc) \
&& sudo make installcompile is the “zimg” library.
git clone -b release-2.9.3 https://github.com/sekrit-twc/zimg.git ~/ffmpeg-libraries/zimg \
&& cd ~/ffmpeg-libraries/zimg \
&& sh autogen.sh \
&& ./configure \
&& make \
&& sudo make install
finally compile FFmpeg (.a)
Now, run the command below to update the link cache.
This command ensures we won’t run into linking issues because the compiler can’t find a library.
sudo ldconfig
cd ffmpeg
mkdir build
cd build
../configure \
--extra-cflags="-I/usr/local/include" \
--extra-ldflags="-L/usr/local/lib" \
--extra-libs="-lpthread -lm -latomic" \
# --enable-shared \ 编译动态库
--arch=armel \
--enable-gmp \
--enable-gpl \
--enable-libaom \
--enable-libass \
--enable-libdrm \
--enable-libfdk-aac \
--enable-libfreetype \
--enable-libkvazaar \
--enable-libmp3lame \
--enable-libopencore-amrnb \
--enable-libopencore-amrwb \
--enable-libopus \
--enable-librtmp \
--enable-libsnappy \
--enable-libsoxr \
--enable-libssh \
--enable-libvorbis \
--enable-libvpx \
--enable-libzimg \
--enable-libwebp \
--enable-libx264 \
--enable-libx265 \
--enable-libxml2 \
--enable-mmal \
--enable-nonfree \
--enable-omx \
--enable-omx-rpi \
--enable-version3 \
--target-os=linux \
--enable-pthreads \
--enable-openssl \
--enable-hardcoded-tables \
&& make -j$(nproc) \
&& sudo make installmake //编译
make install // 会把so 复制到 /usr/lib/?, 头文件复制到 /usr/local/include/
注意一些选项
FFserver has been dropped by the FFMpeg team so we won’t be covering that here.
编译 so
libxxx.a 本质上是object文件的归档! 可能对其他的库有依赖(又依赖其他静态库的情况);
编译命令添加.. --enable-shared 编译为动态库
错误
-ERROR: OMX_Core.h not found
sudo apt-get install libomxil-bellagio-dev
- /usr/local/lib/libvpx.a(onyx_if.c.o) 错误
…
/usr/bin/ld: /usr/local/lib/libvpx.a(onyx_if.c.o): in function vp8_reverse_trans': (.text+0x1cc8): dangerous relocation: unsupported relocation /usr/bin/ld: /usr/local/lib/libvpx.a(onyx_if.c.o): in function vp8_change_config’:
…
/usr/bin/ld: final link failed: symbol needs debug section which does not exist
collect2: error: ld returned 1 exit status
make:*** [/home/pi/project/cp/FFmpeg-n4.1.6/ffbuild/library.mak:103: libavcodec/libavcodec.so.58] Error 1
-
感觉是libvpx 库错误, 可能是需要
--enable-shared参数编译libvpx?f -
但是enable-shared 编译又有一堆问题!
-
干脆
--disable-libvpx编译, 又不需要..