8

Struggling to put together a working and generally best practice build of current FFmpeg. There seems to be no up-to-date documents or tutorials. What does exist is full of outdated links or build-scripts that do not work.

Cameron Lowell Palmer
  • 21,528
  • 7
  • 125
  • 126
Timo Schuck
  • 314
  • 3
  • 11
  • 1
    It would help if you posted some information about what you have tried, what errors you are seeing, and what step specifically is confusing. – Francesca Nannizzi May 27 '16 at 12:59

3 Answers3

6

Build the standalone NDK Toolchain

Download the latest NDK and run make_standalone_toolchain.py

Configure FFmpeg

./configure \
--cross-prefix=arm-linux-androideabi- \
--sysroot="${ANDROID_STANDALONE_NDK}/sysroot" \
--target-os=linux \
--arch=arm \
--cpu=cortex-a8 \
--enable-cross-compile \
--enable-pic \
--enable-shared \
--extra-cflags="-fpic"

Then of course

make -j4

You probably don't want to compile a lot of the components, so you'll need to see what to enable/disable in ./configure --help

Cameron Lowell Palmer
  • 21,528
  • 7
  • 125
  • 126
  • 1
    I have android stdio installed, should i follow the same. – Abdul Muheet Jan 26 '18 at 15:48
  • 2
    @AbdulMuheet yes. Android Studio isn't really applicable in this case since FFMPEG has its own build system. You'll want to compile the library and then bring it into your project. – Cameron Lowell Palmer Jan 28 '18 at 11:31
  • Thanks for your reply, i will try. – Abdul Muheet Jan 28 '18 at 12:19
  • 1
    @AbdulMuheet I have to deal with cross-compiled external libraries all the time and they're all a pain and usually involve Autoconf and Make. Just compile a static library for your desired architecture targets and link it and include the headers. – Cameron Lowell Palmer Jan 28 '18 at 18:43
  • What does `make_stanalone_toolchain.py` do? Should i run it right where it is located or i should copyt it to my projects directoty ? – Omid.N Jun 05 '21 at 08:03
  • Good question! It is in the NDK and it "creates a toolchain installation for a given Android target." A toolchain more suitable for use in cross-compiling software using autotools – Cameron Lowell Palmer Jun 06 '21 at 06:38
3

Solution found!

Please check following links:

Timo Schuck
  • 314
  • 3
  • 11
0

After reading so many post, I've managed to find the way to generate the ffmpeg library for an android

Download below mentioned code and having it as ffmpeg.sh and execute the same in your ffmpeg source root folder and do make

#!/bin/bash
BASEDIR=$(pwd)
TOOLCHAIN_PREFIX=/opt/android-ndk-r9b/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64
CFLAGS='-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all'
LDFLAGS='-Wl,-z,relro -Wl,-z,now -pie'

./configure \
--target-os=linux \
--cross-prefix=/opt/android-ndk-r9b/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi- \
--arch=arm \
--cpu=armv7-a \
--enable-runtime-cpudetect \
--sysroot=/opt/android-ndk-r9b/platforms/android-9/arch-arm/ \
--enable-pic \
--enable-pthreads \
--enable-cross-compile \
--disable-debug \
--disable-ffserver \
--enable-version3 \
--enable-hardcoded-tables \
--disable-ffplay \
--disable-ffprobe \
--enable-gpl \
--enable-yasm \
--disable-doc \
--disable-shared \
--enable-static \
--extra-cflags="-I${TOOLCHAIN_PREFIX}/include $CFLAGS" \
--extra-ldflags="-L${TOOLCHAIN_PREFIX}/lib $LDFLAGS"

Fore details, visit https://sites.google.com/site/greateindiaclub/mobil-apps/android/buildffmpegprebuiltlibraryforanandroid

FFmpegEnthusiast
  • 193
  • 1
  • 10
Boobalan
  • 815
  • 11
  • 11
  • 1
    This has a LOT of unnecessary options, but most of all you're compiling with an insanely old NDK and 32-bit code. You will need to update this since, 1) GCC of this era doesn't generate great ARM code, and 2) next year Android will require 64-bit code. – Cameron Lowell Palmer Jan 28 '18 at 11:59