Issue
I tried many times with different versions of ffmpeg but failed eventually. I dont know how they wrote .sh file to configure different tools. Here are some .sh files i tried and it all failed. Either it shows only android/share
folder instead of
android/include
android/lib
android/share
OR
i end up in error like no file or folder exist
,etc
I will share build_arm64-v8a
different version of files below
VERSION 1
#!/bin/bash
export NDK=/media/sf_sharing/android-ndk
export HOST_TAG=linux-x86_64 # adjust to your building host
export TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/$HOST_TAG
export CC=$TOOLCHAIN/bin/aarch64-linux-android21-clang
export CXX=$TOOLCHAIN/bin/aarch64-linux-android21-clang++
function build_arm64-v8a
{
./configure \
--prefix=./android/arm64-v8a \
--enable-static \
--enable-pic \
--disable-asm \
--disable-opencl \
--disable-cli \
--host=aarch64-linux \
--cross-prefix=$TOOLCHAIN/bin/aarch64-linux-android- \
--sysroot=$TOOLCHAIN/sysroot \
make clean
make
make install
}
build_arm64-v8a
echo build_arm64-v8a finished
VERSION 2
#!/bin/bash
TOOLCHAIN=/media/sf_sharing/my-android-toolchain64
CROSS_PREFIX=$TOOLCHAIN/bin/aarch64-linux-android-
rm -f $(pwd)/compat/strtod.o
function build_one
{
./configure --prefix=$PREFIX --enable-shared --disable-static --enable-protocol=file --enable-pic --enable-small --disable-programs --disable-doc --disable-symver --target-os=android --enable-cross-compile --cross-prefix=$CROSS_PREFIX --extra-cflags="-Os -fpic $ADDI_CFLAGS" --extra-ldflags="$ADDI_LDFLAGS" --sysroot=$TOOLCHAIN/sysroot $ADDITIONAL_CONFIG_FLAG
make clean
make -j2
make install
}
CPU=arm64-v8a
mkdir -p $(pwd)/android/$CPU
PREFIX=$(pwd)/android/$CPU
ADDI_CFLAGS="-march=armv8-a"
ADDI_LDFLAGS="-L$TOOLCHAIN/sysroot/usr/lib"
ADDITIONAL_CONFIG_FLAG="--arch=aarch64 --enable-yasm"
build_one
VERSION 3
#!/bin/bash
export NDK=/media/sf_sharing/android-ndk
export HOST_TAG=linux-x86_64 # adjust to your building host
export TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/$HOST_TAG
export CC=$TOOLCHAIN/bin/aarch64-linux-android21-clang
export CXX=$TOOLCHAIN/bin/aarch64-linux-android21-clang++
function build_arm64-v8a
{
./configure \
--prefix="$HOME/ffmpeg_build" \
--pkg-config-flags="--static" \
--extra-cflags="-I$HOME/ffmpeg_build/include" \
--extra-ldflags="-L$HOME/ffmpeg_build/lib" \
--extra-libs="-lpthread -lm" \
--bindir="$HOME/bin" \
--enable-gpl \
--enable-gnutls \
--enable-libaom \
--enable-libass \
--enable-libfdk-aac \
--enable-libfreetype \
--enable-libmp3lame \
--enable-libopus \
--enable-libvorbis \
--enable-libvpx \
--enable-libx264 \
--enable-libx265 \
--enable-nonfree \
make clean
make
make install
}
build_arm64-v8a
echo build_arm64-v8a finished
I'm using
ffmpeg-snapshot.tar.bz2
android-ndk-r21d-linux-x86_64
the only thing i know in 'ndk 21` is we need to use default toolchain (android documentation says).
How to create .sh file to build .so file to use in android?
Solution
I recommend building the simplest version using --disable-everything and build up your command from there. I built on mac. I edited your third attempt and built for arm64 with one codec as follows:
#!/bin/bash export ANDROID_NDK_HOME=${HOME}/Library/Android/android-ndk-r21 export HOST_TAG=darwin-x86_64 # adjust to your building host export TOOLCHAIN=${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/$HOST_TAG function build_other { TARGET_ABI=arm64-v8a HOST=aarch64-linux-android ./configure --disable-everything --disable-doc --disable-programs --disable-shared --enable-cross-compile --arch=aarch64 --target-os=linux --enable-pic \ --prefix="$HOME/ffmpeg_build" \ --sysroot=${ANDROID_NDK_HOME}/sysroot \ --enable-encoder=h261 --enable-decoder=h261 \ --extra-ldflags="-L${ANDROID_NDK_HOME}/platforms/android-29/arch-arm64/usr/lib -lc" \ --cc=${TOOLCHAIN}/bin/aarch64-linux-android29-clang --ld=${TOOLCHAIN}/bin/aarch64-linux-android-ld --strip=${TOOLCHAIN}/bin/aarch64-linux-android-strip make clean make make install } mkdir $HOME/ffmpeg_build 2> /dev/null build_other echo build_arm64-v8a finished
NOTE: I built on mac, this should work on linux. Also, do not link pthread! pthread is in libc for android.
Answered By - sorenoid
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.