2021-10-03 14:36:06 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2024-07-18 22:09:21 +02:00
|
|
|
set -e
|
|
|
|
|
2021-10-03 14:36:06 +02:00
|
|
|
if [ -z ${ANDROID_NDK_HOME+x} ]; then
|
2022-01-20 13:01:56 +01:00
|
|
|
echo "Error: \$ANDROID_NDK_HOME is not defined." >&2
|
|
|
|
exit 1
|
2021-10-03 14:36:06 +02:00
|
|
|
else
|
2024-07-18 22:09:21 +02:00
|
|
|
cd "$(dirname "$0")"
|
|
|
|
FFMPEG_DIR="ffmpeg"
|
2021-10-03 14:36:06 +02:00
|
|
|
compile_for_arch() {
|
2021-10-15 10:02:48 +02:00
|
|
|
echo "Compiling for $1..."
|
2021-10-03 14:36:06 +02:00
|
|
|
case $1 in
|
|
|
|
"x86_64")
|
|
|
|
CFN="x86_64-linux-android21-clang"
|
|
|
|
ARCH="x86_64"
|
|
|
|
;;
|
|
|
|
"x86")
|
|
|
|
CFN="i686-linux-android21-clang"
|
|
|
|
ARCH="i686"
|
2021-10-15 10:02:48 +02:00
|
|
|
EXTRA_FLAGS="--disable-asm"
|
2021-10-03 14:36:06 +02:00
|
|
|
;;
|
|
|
|
"arm64-v8a")
|
|
|
|
CFN="aarch64-linux-android21-clang"
|
|
|
|
ARCH="aarch64"
|
|
|
|
;;
|
|
|
|
"armeabi-v7a")
|
|
|
|
CFN="armv7a-linux-androideabi19-clang"
|
|
|
|
ARCH="arm"
|
|
|
|
;;
|
|
|
|
esac
|
2024-07-18 22:09:21 +02:00
|
|
|
(cd $FFMPEG_DIR
|
|
|
|
make clean || true
|
2021-10-03 14:36:06 +02:00
|
|
|
./configure \
|
|
|
|
--cc="$CFN" \
|
|
|
|
--cxx="$CFN++" \
|
|
|
|
--arch="$ARCH" \
|
2021-10-15 10:02:48 +02:00
|
|
|
$EXTRA_FLAGS \
|
2021-10-03 14:36:06 +02:00
|
|
|
--target-os=android \
|
|
|
|
--enable-cross-compile \
|
|
|
|
--enable-version3 \
|
|
|
|
--disable-programs \
|
2021-10-15 10:02:48 +02:00
|
|
|
--disable-static \
|
|
|
|
--enable-shared \
|
2021-10-03 14:36:06 +02:00
|
|
|
--disable-bsfs \
|
|
|
|
--disable-parsers \
|
|
|
|
--disable-demuxers \
|
2021-10-15 10:02:48 +02:00
|
|
|
--disable-muxers \
|
|
|
|
--enable-muxer="mp4" \
|
2021-10-03 14:36:06 +02:00
|
|
|
--disable-decoders \
|
2021-10-15 10:02:48 +02:00
|
|
|
--disable-encoders \
|
|
|
|
--enable-encoder="aac" \
|
2021-10-03 14:36:06 +02:00
|
|
|
--disable-avdevice \
|
|
|
|
--disable-swresample \
|
|
|
|
--disable-swscale \
|
|
|
|
--disable-postproc \
|
|
|
|
--disable-avfilter \
|
|
|
|
--disable-network \
|
|
|
|
--disable-doc \
|
|
|
|
--disable-htmlpages \
|
|
|
|
--disable-manpages \
|
|
|
|
--disable-podpages \
|
|
|
|
--disable-txtpages \
|
|
|
|
--disable-sndio \
|
|
|
|
--disable-schannel \
|
|
|
|
--disable-securetransport \
|
2022-10-08 11:07:59 +02:00
|
|
|
--disable-vulkan \
|
2021-10-03 14:36:06 +02:00
|
|
|
--disable-xlib \
|
|
|
|
--disable-zlib \
|
|
|
|
--disable-cuvid \
|
|
|
|
--disable-nvenc \
|
|
|
|
--disable-vdpau \
|
|
|
|
--disable-videotoolbox \
|
|
|
|
--disable-audiotoolbox \
|
|
|
|
--disable-appkit \
|
|
|
|
--disable-alsa \
|
2024-07-18 22:09:21 +02:00
|
|
|
--disable-debug
|
|
|
|
make -j "$(nproc --all)" >/dev/null)
|
|
|
|
mkdir -p "build/$1/libavformat" "build/$1/libavcodec" "build/$1/libavutil"
|
|
|
|
cp $FFMPEG_DIR/libavformat/*.h $FFMPEG_DIR/libavformat/libavformat.so "build/$1/libavformat"
|
|
|
|
cp $FFMPEG_DIR/libavcodec/*.h $FFMPEG_DIR/libavcodec/libavcodec.so "build/$1/libavcodec"
|
|
|
|
cp $FFMPEG_DIR/libavutil/*.h $FFMPEG_DIR/libavutil/libavutil.so "build/$1/libavutil"
|
2021-10-03 14:36:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH
|
2024-07-18 22:09:21 +02:00
|
|
|
if [ $# -eq 1 ]; then
|
|
|
|
compile_for_arch "$1"
|
2021-10-03 14:36:06 +02:00
|
|
|
else
|
2024-07-18 22:09:21 +02:00
|
|
|
for abi in "x86_64" "x86" "arm64-v8a" "armeabi-v7a"; do
|
2021-10-03 14:36:06 +02:00
|
|
|
compile_for_arch $abi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
fi
|