Last active
September 28, 2023 15:19
-
-
Save KivApple/a29bf5d49cbbbedef1aacb3e14b850f2 to your computer and use it in GitHub Desktop.
Script to build OpenH264 library for Android NDK under Linux (requires Android NDK, curl, unzip)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
export NDK=~/Apps/AndroidSDK/ndk-bundle # Change me | |
export JNILIBS_DIR=../../app/src/main/jniLibs # Change me | |
export INCLUDE_DIR=../../app/src/main/cpp/libopenh264 # Change me | |
export DOWNLOAD_URL=https://github.com/cisco/openh264/archive/master.zip | |
mkdir -p tmp | |
ln -sf $NDK/prebuilt/linux-x86_64/bin/yasm tmp/nasm | |
export PATH=$(pwd)/tmp:$PATH | |
if [ ! -f src.zip ]; then | |
curl -L $DOWNLOAD_URL --output src.zip || exit 1 | |
fi | |
declare -A arch_abis=( | |
["arm"]="armeabi-v7a" | |
["arm64"]="arm64-v8a" | |
["x86"]="x86" | |
["x86_64"]="x86_64" | |
) | |
declare -A ndk_levels=( | |
["arm"]="16" | |
["arm64"]="21" | |
["x86"]="16" | |
["x86_64"]="21" | |
) | |
for arch in arm arm64 x86 x86_64; do | |
echo "Building for $arch (${arch_abis[$arch]})" | |
unzip src.zip || exit 1 | |
rm -rf src | |
mv openh264-master src | |
if [ "$arch" == "x86" ]; then | |
export ASMFLAGS=-DX86_32_PICASM | |
else | |
export ASMFLAGS= | |
fi | |
make OS=android NDKROOT=$NDK TARGET=android-${ndk_levels[$arch]} NDKLEVEL=${ndk_levels[$arch]} ARCH=$arch -C src NDK_TOOLCHAIN_VERSION=clang libraries || exit 1 | |
mkdir -p "$JNILIBS_DIR/${arch_abis[$arch]}" | |
cp -v src/libopenh264.{so,a} "$JNILIBS_DIR/${arch_abis[$arch]}" | |
done | |
mkdir -p "$INCLUDE_DIR/wels" | |
cp -v src/codec/api/svc/*.h "$INCLUDE_DIR/wels" | |
rm -rf tmp src |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment