Building FFMPEG for Android on x86

FFMPEG is a popular cross platform open source multimedia framework used in open source media applications such as Handbrake.  The default builds for FFMPEG are Linux, Windows, and OSX.  This blog shows a method for building the FFMPEG shared libraries for Android x86.  

The setup used for this build was a VirtualBox Virtual Machine running Ubuntu Linux 12.04 64-bit.

To build FFMPEG for Android x86:
1.  Download the latest Android NDK from

2.  Download the latest FFMPEG source code from

3.  Open a Terminal and cd into the FFMPEG directory

4.  Configure ANDROID_NDK environment variable
    ANDROID_NDK=<your ndk path>

5.  Setup the toolchain
    $ANDROID_NDK/build/tools/ --toolchain=x86-4.8 --arch=x86 --system=linux-x86_64 --platform=android-14 --install-dir=/tmp/vplayer

    export PATH=$TOOLCHAIN/bin:$PATH
    export CC="ccache i686-linux-android-gcc-4.8"
    export LD=i686-linux-android-ld
    export AR=i686-linux-android-ar

6.  Configure FFMPEG
./configure --target-os=linux --arch=x86 --cpu=i686 --cross-prefix=i686-linux-android- --enable-cross-compile --enable-shared --disable-static --disable-symver --disable-doc --disable-ffplay --disable-ffmpeg --disable-ffprobe --disable-ffserver --disable-avdevice --disable-postproc --disable-encoders --disable-muxers --disable-devices --disable-demuxer=sbg --disable-demuxer=dts --disable-parser=dca --disable-decoder=dca --disable-decoder=svq3 --enable-network --enable-version3 --disable-amd3dnow --disable-amd3dnowext --enable-asm --enable-yasm --enable-pic --prefix=$PREFIX --extra-cflags='-std=c99 -O3 -Wall -fpic -pipe   -DANDROID -DNDEBUG  -march=atom -msse3 -ffast-math -mfpmath=sse' --extra-ldflags='-lm -lz -Wl,--no-undefined -Wl,-z,noexecstack'

7.  Build FFMPEG for Android x86.  The include and shared library files will be in the build/android/x86 folder
make clean
make install

8.  Generate shared library file in the build/android/x86 folder

rm libavcodec/log2_tab.o libavformat/log2_tab.o libswresample/log2_tab.o

$CC -o $PREFIX/ -shared libavutil/*.o libavutil/x86/*.o libavcodec/*.o libavcodec/x86/*.o libavformat/*.o libavfilter/*.o libavfilter/x86/*.o libswresample/*.o libswresample/x86/*.o libswscale/*.o libswscale/x86/*.o compat/*.o


To learn more about FFMPEG, please visit the link below:    

To learn more about VirtualBox, please visit the link below:

To learn more about Ubuntu Linux, please visit the link below:

To learn more about Handbrake, please visit the link below:


++This sample source code is released under the Open Source Initiative OSI - The BSD License.

Para obtener información más completa sobre las optimizaciones del compilador, consulte nuestro Aviso de optimización.