Kyros
Kyros

Reputation: 53

Android NDK Build FFMPEG in 2021

I'm working on an android app, and I have to convert webm files to mp3. I really want to make a custom ffmpeg build, because it reduces the ffmpeg executable size to only 2MB.

My library works absolutely fine when running on my PC, but i'm struggling to build it for android... It seems like NDK architecture has changed and tutorials are outdated, and I can't find a proper and recent guide for android compiling...

I also would like to target all architectures (aarch64, armv7, i686, and x86_64)...

I've been on this for hours, fixed many errors, but still nothing has worked ><. Please help me ! :\

PS. I'm compiling on Linux, here is my configuration script:

#!/bin/bash

API=31 # target android api

OUTPUT=/home/romain/dev/android/ffmpeg_build

NDK=/home/romain/android-sdk/ndk/23.0.7599858
TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/linux-x86_64
SYSROOT=$TOOLCHAIN/sysroot

TOOL_PREFIX="$TOOLCHAIN/bin/aarch64-linux-android"

CC="$TOOL_PREFIX$API-clang"
CXX="$TOOL_PREFIX$API-clang++"

./configure \
    --prefix=$OUTPUT \
    --target-os=android \
    --arch=$ARCH \
    --cpu=$CPU \
    --disable-everything \
    --disable-everything \
    --disable-network \
    --disable-autodetect \
    --enable-small \
    --enable-decoder=opus,vorbis \
    --enable-demuxer=matroska \
    --enable-muxer=mp3 \
    --enable-protocol=file \
    --enable-filter=aresample \
    --enable-libshine \
    --enable-encoder=libshine \
    --cc=$CC \
    --cxx=$CXX \
    --sysroot=$SYSROOT \
    --extra-cflags="-0s -fpic"

make
make install

Upvotes: 3

Views: 2002

Answers (2)

RAYNARD DODZI
RAYNARD DODZI

Reputation: 9

The repository pointed to by the previous answer is no longer being maintained. Here is an updated one.

This is the android branch: https://github.com/arthenica/ffmpeg-kit/tree/main/android

Upvotes: 0

Foxie Flakey
Foxie Flakey

Reputation: 420

The prefix should point to $SYSROOT/usr/ and you misunderstood what --prefix mean. Its not output directory. Other than that i think nothing problematic than that (if it still happen please provide ffbuild/config.log)

Upvotes: 1

Related Questions