feat: Add mpp and ffmpeg compilation script for arm64

This commit is contained in:
Andrii Podanenko 2023-03-24 15:09:02 +02:00
parent 8bd5f0268a
commit e1c0d4c5ee
3 changed files with 111 additions and 0 deletions

View File

@ -178,6 +178,11 @@ ENV NVIDIA_DRIVER_CAPABILITIES="compute,video,utility"
ENV PATH="/usr/lib/btbn-ffmpeg/bin:/usr/local/go2rtc/bin:/usr/local/nginx/sbin:${PATH}"
# Install mpp empowerred ffmpeg for arm64
RUN --mount=type=tmpfs,target=/tmp --mount=type=tmpfs,target=/var/cache/apt \
--mount=type=bind,source=docker/mpp.sh,target=/deps/mpp.sh \
/deps/mpp.sh
# Install dependencies
RUN --mount=type=bind,source=docker/install_deps.sh,target=/deps/install_deps.sh \
/deps/install_deps.sh

View File

@ -47,6 +47,13 @@ if [[ "${TARGETARCH}" == "arm" ]]; then
fi
# ffmpeg -> arm64
if command -v ffmpeg >/dev/null 2>&1; then
HAS_FFMPEG=1
else
HAS_FFMPEG=0
fi
if [[ "${HAS_FFMPEG}" == 0 ]]; then
if [[ "${TARGETARCH}" == "arm64" ]]; then
# add raspberry pi repo
gpg --no-default-keyring --keyring /usr/share/keyrings/raspbian.gpg --keyserver keyserver.ubuntu.com --recv-keys 82B129927FA3303E
@ -54,6 +61,8 @@ if [[ "${TARGETARCH}" == "arm64" ]]; then
apt-get -qq update
apt-get -qq install --no-install-recommends --no-install-suggests -y ffmpeg
fi
fi
# arch specific packages
if [[ "${TARGETARCH}" == "amd64" ]]; then

97
docker/mpp.sh Executable file
View File

@ -0,0 +1,97 @@
#!/bin/bash
set -euxo pipefail
apt-get -qq update
apt install -y pkg-config
if [ -e /usr/local/include/mpp/mpp.h ] || [ -e /usr/include/mpp/mpp.h ] || pkg-config --exists rockchip-mpp; then
HAS_MPP=1
else
# Install mpp from sources
apt-get -qq update
apt-get install -y git build-essential yasm pkg-config \
libtool coreutils 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 libaom-dev libdav1d-dev \
libmp3lame-dev
cd /tmp
git clone https://github.com/rockchip-linux/mpp.git
cd mpp
mkdir build || true && cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr/local ../
make -j$(nproc)
make install
ldconfig
fi
# TODO: consider moving ffmpeg compillation to a dedicated ffmpeg.sh script
if command -v ffmpeg >/dev/null 2>&1; then
HAS_FFMPEG=1
else
HAS_FFMPEG=0
fi
if [[ "${HAS_FFMPEG}" == 1 ]]; then
# To avoid possible race condition.
apt -y remove ffmpeg
fi
# Compile ffmpeg
cd /tmp
git clone https://github.com/FFmpeg/FFmpeg.git
cd FFmpeg
PKG_CONFIG_PATH="/usr/local/lib/pkgconfig" ./configure \
--enable-rkmpp \
--extra-cflags="-I/usr/local/include" \
--extra-ldflags="-L/usr/local/lib" \
--extra-libs="-lpthread -lm -latomic" \
--arch=arm64 \
--enable-gmp \
--enable-gpl \
--enable-libaom \
--enable-libass \
--enable-libdav1d \
--enable-libdrm \
--enable-libfreetype \
--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-nonfree \
--enable-version3 \
--target-os=linux \
--enable-pthreads \
--enable-openssl \
--enable-hardcoded-tables
make -j$(nproc)
make install
ldconfig
cd /tmp
rm -rf mpp
rm -rf FFmpeg