Build ffmpeg prebuilt library for an android
Post date: Jul 13, 2017 11:03:55 AM
After been a long time to getting into trouble, this time it is ffmpeg. Here the objective is to download the ffmpeg source code from portal http://ffmpeg.org/releases/ and have to build for different arm, arch or cpu for an Android.
Pre-requirements:
Ubuntu 14.04
Android NDK : /opt/android-ndk-r9b
Steps to build ffmpeg for android:-
Download the required source code from http://ffmpeg.org/releases/,
in my case I've chosen for http://ffmpeg.org/releases/ffmpeg-3.0.1.tar.gz
Extract it to ffmpeg-3.0.1/ folder
Install some supporting framework, if it's not exist
sudo apt-get --quiet --yes install build-essential git autoconf libtool pkg-config gperf gettext yasm python-lxml
Copy below mentioned script and make ffmpeg.sh and have it in ffmpeg-3.0.1/,
which gives you ffmpeg for android armv7-a arm version
Open terminal and execute ffmpeg.sh using ./ffmpeg.sh
execute: make
At the end of execution , you will find ffmpeg library which is targeted for armv7-a architecture
ffmpeg.sh
#!/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"
If you want to build for linux then just use
./configure
make clean
make
Please comment here, if you need any support