How to Build ffmpeg with NDK r9

This is a updated post for a previous post, where we built ffmpeg 0.8 with Android NDK r5 and r6. This post will give instructions of how to build ffmpeg 2.0.1 with Android NDK r9.

0. Download Android NDK

The latest version of Android NDK can be downloaded at Android NDK website. At the time of writing, the newest version is NDK r9. Note that the website provides both current and legacy toolchains. We only need the current toolchain to compile ffmpeg.

After download NDK, simply decompress the archive. Note that we’ll use $NDK to represent the root path of the decompressed NDK.

1. Download ffmpeg source code

FFMPEG source code can be downloaded from the ffmpeg website. The latest stable release is 2.0.1. Download the source code and decompress it to $NDK/sources folder. We’ll discuss about the reason for doing this later.

2. Update configure file

Open ffmpeg-2.0.1/configure file with a text editor, and locate the following lines.

SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'

LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'

SLIB_INSTALL_NAME='$(SLIBNAME_WITH_VERSION)'

SLIB_INSTALL_LINKS='$(SLIBNAME_WITH_MAJOR) $(SLIBNAME)'

This cause ffmpeg shared libraries to be compiled to libavcodec.so.<version> (e.g. libavcodec.so.55), which is not compatible with Android build system. Therefore we’ll need to replace the above lines with the following lines.

SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'

LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'

SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'

SLIB_INSTALL_LINKS='$(SLIBNAME)'

3. Build ffmpeg

Copy the following text to a text editor and save it as build_android.sh.

#!/bin/bash

NDK=$HOME/Desktop/adt/android-ndk-r9

SYSROOT=$NDK/platforms/android-9/arch-arm/

TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64

function build_one

{

./configure 

    --prefix=$PREFIX 

    --enable-shared 

    --disable-static 

    --disable-doc 

    --disable-ffmpeg 

    --disable-ffplay 

    --disable-ffprobe 

    --disable-ffserver 

    --disable-avdevice 

    --disable-doc 

    --disable-symver 

    --cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- 

    --target-os=linux 

    --arch=arm 

    --enable-cross-compile 

    --sysroot=$SYSROOT 

    --extra-cflags="-Os -fpic $ADDI_CFLAGS" 

    --extra-ldflags="$ADDI_LDFLAGS" 

    $ADDITIONAL_CONFIGURE_FLAG

make clean

make

make install

}

CPU=arm

PREFIX=$(pwd)/android/$CPU 

ADDI_CFLAGS="-marm"

build_one

We disabled static library and enabled shared library. Note that the build script is not optimized for a particular CPU. One should refer to ffmpeg documentation for detailed information about available configure options.

Once the file is saved, make sure the script is executable by the command below,

sudo chmod +x build_android.sh

Then execute the script by the command,

./build_android.sh

4. Build Output

The build can take a while to finish depending on your computer speed. Once it’s done, you should be able to find a folder $NDK/sources/ffmpeg-2.0.1/android, which contains arm/lib and arm/include folders.

The arm/lib folder contains the shared libraries, while arm/include folder contains the header files for libavcodec, libavformat, libavfilter, libavutil, libswscale etc.

Note that the arm/lib folder contains both the library files (e.g.: libavcodec-55.so) and symbolic links (e.g.: libavcodec.so) to them. We can remove the symbolic links to avoid confusion.

5. Make ffmpeg Libraries available for Your Projects

Now we’ve compiled the ffmpeg libraries and ready to use them. Android NDK allows us to reuse a compiled module through the import-module build command.

The reason we built our ffmpeg source code under $NDK/sources folder is that NDK build system will search for directories under this path for external modules automatically. To declare the ffmpeg libraries as reusable modules, we’ll need to add a file named $NDK/sources/ffmpeg-2.0.1/android/arm/Android.mk with the following content,

LOCAL_PATH:= $(call my-dir)

 

include $(CLEAR_VARS)

LOCAL_MODULE:= libavcodec

LOCAL_SRC_FILES:= lib/libavcodec-55.so

LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include

include $(PREBUILT_SHARED_LIBRARY)

 

include $(CLEAR_VARS)

LOCAL_MODULE:= libavformat

LOCAL_SRC_FILES:= lib/libavformat-55.so

LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include

include $(PREBUILT_SHARED_LIBRARY)

 

include $(CLEAR_VARS)

LOCAL_MODULE:= libswscale

LOCAL_SRC_FILES:= lib/libswscale-2.so

LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include

include $(PREBUILT_SHARED_LIBRARY)

 

include $(CLEAR_VARS)

LOCAL_MODULE:= libavutil

LOCAL_SRC_FILES:= lib/libavutil-52.so

LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include

include $(PREBUILT_SHARED_LIBRARY)

 

include $(CLEAR_VARS)

LOCAL_MODULE:= libavfilter

LOCAL_SRC_FILES:= lib/libavfilter-3.so

LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include

include $(PREBUILT_SHARED_LIBRARY)

 

include $(CLEAR_VARS)

LOCAL_MODULE:= libwsresample

LOCAL_SRC_FILES:= lib/libswresample-0.so

LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include

include $(PREBUILT_SHARED_LIBRARY)

Below is an example of how we can use the libraries in a Android project’s jni/Android.mk file,

LOCAL_PATH := $(call my-dir)

 

include $(CLEAR_VARS)

 

LOCAL_MODULE    := tutorial03

LOCAL_SRC_FILES := tutorial03.c

LOCAL_LDLIBS := -llog -ljnigraphics -lz -landroid

LOCAL_SHARED_LIBRARIES := libavformat libavcodec libswscale libavutil

 

include $(BUILD_SHARED_LIBRARY)

$(call import-module,ffmpeg-2.0.1/android/arm)

Note that we called import-module with the relative path to $NDK/sources for the build system to locate the reusable ffmpeg libraries.

For real examples to how to use the ffmpeg libraries in Android app, please refer to my github repo of android-ffmpeg-tutorial.

0 thoughts on “How to Build ffmpeg with NDK r9”

  1. I followed your steps 1-3 on a Linux machine and when I ran your script here /android-ndk-r9/sources/ffmpeg-2.0.1/build_android.sh I got the following output at the end and no android/ folder was made:

    License: LGPL version 2.1 or later
    Creating config.mak, config.h, and doc/config.texi…

    WARNING: /prj/qct/coredev/camera_ss/builds2/matthewf/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-pkg-config not found, library detection may fail.
    common.mak:18: *** unterminated call to function `foreach’: missing `)’. Stop.
    common.mak:18: *** unterminated call to function `foreach’: missing `)’. Stop.
    common.mak:18: *** unterminated call to function `foreach’: missing `)’. Stop.

    1. This should not happen, as the prefix is set in the script. Please ensure that a folder $(pwd)/android/arm can be created without permission problems.

      1. I created one myself.. and I still get this line:

        ./build_android.sh: line 16: –prefix=/home/ronyt/Desktop/android-ndk-r9/sources/ffmpeg-2.0.1/android/arm: No such file or directory

    2. this is the beginning of the output:
      install prefix /usr/local
      source path .
      C compiler gcc
      ARCH x86 (generic)
      big-endian no
      runtime cpu detection yes
      yasm yes
      MMX enabled yes

      and I have many warnings too. and many lines like these:
      CC libavfilter/fifo.o
      CC libavfilter/formats.o

  2. is this output (partiel) ok?

    ./build_android.sh: line 18: –enable-shared: command not found
    ./build_android.sh: line 20: –disable-static: command not found
    ./build_android.sh: line 22: –disable-doc: command not found
    ./build_android.sh: line 24: –disable-ffmpeg: command not found
    ./build_android.sh: line 26: –disable-ffplay: command not found
    ./build_android.sh: line 28: –disable-ffprobe: command not found
    ./build_android.sh: line 30: –disable-ffserver: command not found
    ./build_android.sh: line 32: –disable-avdevice: command not found
    ./build_android.sh: line 34: –disable-doc: command not found
    ./build_android.sh: line 36: –disable-symver: command not found
    ./build_android.sh: line 38: –cross-prefix=/home/ronyt/Desktop/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-: No such file or directory
    ./build_android.sh: line 40: –target-os=linux: command not found
    ./build_android.sh: line 42: –arch=arm: command not found
    ./build_android.sh: line 44: –enable-cross-compile: command not found
    ./build_android.sh: line 46: –sysroot=/home/ronyt/Desktop/android-ndk-r9/platforms/android-9/arch-arm/: No such file or directory
    ./build_android.sh: line 48: –extra-cflags=-Os -fpic -marm: command not found
    ./build_android.sh: line 50: –extra-ldflags=: command not found

        1. remove all the “” in the build_one function in the build_android.sh file. just put all the “–prefix=… –enable-…” in the same line.

  3. Thanks for the instructions – everything works fine.
    It would be great if you could add a description of how to build ffmpeg with the ability to call ffmpeg::main()
    Many people use the main() call as on the command line to not realize their own different algorithms that are already implemented in ffmpeg.c

  4. hello ,
    i follow your tutorial and i compiled ffmpeg with some little modification in .sh file like enable mux and demuc and encoder and decoder
    i download you sample from git and link with my compiled ffmpeg lib.
    but i got this error
    ” error: undefined reference to ‘av_register_all’ ”
    error: undefined reference to ‘avformat_open_input’
    error: undefined reference to ‘av_dump_format’
    error: undefined reference to ‘avcodec_open2’
    can you help me
    thank you

    1. Actually, i am experiencing the same issue. Something must be wrong with the Android.mk file i guess?

      Also, shouldn’t this part:

      include $(BUILD_SHARED_LIBRARY)

      $(call import-module,ffmpeg-2.0.1/android/arm)

      lie above the “tutorial03” module part?

  5. Hello,
    i compile under cygwin64 and Win8. I modified the lines in the configure.
    The last step abort with the message:
    ….
    CC libswscale/rgb2rgb.o
    CC libswscale/swscale.o
    CC libswscale/swscale_unscaled.o
    CC libswscale/utils.o
    CC libswscale/yuv2rgb.o
    LD libswscale/libswscale-2.so
    LD libavfilter/libavfilter-3.so
    INSTALL libavfilter/libavfilter.so
    install: Aufruf von stat für „libavfilter/libavfilter.so“ nicht möglich: No such file or directory
    library.mak:106: recipe for target `install-libavfilter-shared’ failed
    make: *** [install-libavfilter-shared] Error 1

    Has anybody a idea?
    thanks and regards

    1. after modifying this “remove all the “” in the build_one function in the build_android.sh file. just put all the “–prefix=… –enable-…” in the same line.”, i am getting the following:
      ./configure: line 2232: $’r’: command not found
      ./configure: line 2234: $’r’: command not found
      ./configure: line 2236: $’r’: command not found
      Unknown option “-prefix=/opt/android-ndk-r9/sources/ffmpeg-HEAD-b4eb06d.android/android/arm”.
      See ./configure –help for available options.
      Makefile:2: config.mak: No such file or directory
      Makefile:49: /common.mak: No such file or directory
      Makefile:92: /libavutil/Makefile: No such file or directory
      Makefile:92: /library.mak: No such file or directory
      Makefile:169: /doc/Makefile: No such file or directory
      Makefile:170: /tests/Makefile: No such file or directory
      make: *** No rule to make target `/tests/Makefile’. Stop.
      Makefile:2: config.mak: No such file or directory
      Makefile:49: /common.mak: No such file or directory
      Makefile:92: /libavutil/Makefile: No such file or directory
      Makefile:92: /library.mak: No such file or directory
      Makefile:169: /doc/Makefile: No such file or directory
      Makefile:170: /tests/Makefile: No such file or directory
      make: *** No rule to make target `/tests/Makefile’. Stop.
      Makefile:2: config.mak: No such file or directory
      Makefile:49: /common.mak: No such file or directory
      Makefile:92: /libavutil/Makefile: No such file or directory
      Makefile:92: /library.mak: No such file or directory
      Makefile:169: /doc/Makefile: No such file or directory
      Makefile:170: /tests/Makefile: No such file or directory
      make: *** No rule to make target `/tests/Makefile’. Stop.

  6. when i tried to run ./build_android.sh
    I got the following :
    ./configure: line 2232: $’r’: command not found
    ./configure: line 2234: $’r’: command not found
    ./configure: line 2236: $’r’: command not found
    yasm not found, use –disable-yasm for a crippled build

    If you think configure made a mistake, make sure you are using the latest
    version from Git. If the latest version fails, report the problem to the
    ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
    Include the log file “config.log” produced by configure as this will help
    solving the problem.
    ./build_android.sh: line 15: -prefix=/opt/android-ndk-r9/sources/ffmpeg-HEAD-b4eb06d.android/android/arm: No such file or directory
    ./build_android.sh: line 17: -enable-shared: command not found
    ./build_android.sh: line 19: -disable-static: command not found
    ./build_android.sh: line 21: -disable-doc: command not found
    ./build_android.sh: line 23: -disable-ffmpeg: command not found
    ./build_android.sh: line 25: -disable-ffplay: command not found
    ./build_android.sh: line 27: -disable-ffprobe: command not found
    ./build_android.sh: line 29: -disable-ffserver: command not found
    ./build_android.sh: line 31: -disable-avdevice: command not found
    ./build_android.sh: line 33: -disable-doc: command not found
    ./build_android.sh: line 35: -disable-symver: command not found
    ./build_android.sh: line 37: -cross-prefix=/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi: No such file or directory
    ./build_android.sh: line 39: -target-os=linux: command not found
    ./build_android.sh: line 41: -arch=arm: command not found
    ./build_android.sh: line 43: -enable-cross-compile: command not found
    ./build_android.sh: line 45: -sysroot=/android-ndk-r9/platforms/android-18/arch-arm/: No such file or directory
    ./build_android.sh: line 47: -extra-cflags=-Os -fpic -marm: command not found
    ./build_android.sh: line 49: -extra-ldflags=: command not found
    Makefile:2: config.mak: No such file or directory
    Makefile:49: /common.mak: No such file or directory
    Makefile:92: /libavutil/Makefile: No such file or directory
    Makefile:92: /library.mak: No such file or directory
    Makefile:169: /doc/Makefile: No such file or directory
    Makefile:170: /tests/Makefile: No such file or directory
    make: *** No rule to make target `/tests/Makefile’. Stop.
    Makefile:2: config.mak: No such file or directory
    Makefile:49: /common.mak: No such file or directory
    Makefile:92: /libavutil/Makefile: No such file or directory
    Makefile:92: /library.mak: No such file or directory
    Makefile:169: /doc/Makefile: No such file or directory
    Makefile:170: /tests/Makefile: No such file or directory
    make: *** No rule to make target `/tests/Makefile’. Stop.
    Makefile:2: config.mak: No such file or directory
    Makefile:49: /common.mak: No such file or directory
    Makefile:92: /libavutil/Makefile: No such file or directory
    Makefile:92: /library.mak: No such file or directory
    Makefile:169: /doc/Makefile: No such file or directory
    Makefile:170: /tests/Makefile: No such file or directory
    make: *** No rule to make target `/tests/Makefile’. Stop.

  7. Hi,
    I was able to build ffmpeg fine. However, when I tried building jni file in the tutorial project it throws error. Need some help in getting past this hurdle.
    Error message:
    Android NDK: jni/Android.mk: Cannot find module with tag ‘ffmpeg-2.0.1/android/arm’ in import path
    Android NDK: Are you sure your NDK_MODULE_PATH variable is properly defined ?
    Android NDK: The following directories were searched:
    Android NDK:
    jni/Android.mk:11: *** Android NDK: Aborting. . Stop.

    Thanks,
    Vinay

  8. I was able to compile ffmpeg by following the steps here but may I ask, is it expected that there is no libffmpeg.so? I made a 2 build, one with –disable-ffmpeg and the other without that line but there is no libffmpeg.so produced. Is this okay?

  9. Hi i am not able to generate .exe files after running build_android.sh & got errors.
    “/android-ndk-r9-windows-x86_64/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/arm-linux-androideabi-gcc is unable to create an executable file”

    C compiler test failed.

  10. Hi!
    I’m trying to build ffmpeq in NDK r9, but when i executable script by comand: ./build_android.sh, terminal show: invalid file (bad magic number): Exec format error.
    So, how i can fix my problem. Thanks alot.

  11. Hi!
    I download your tutorial but when i import appear some error:
    “Unresolved inclusion: ”
    That mean i cant include library of ffmpeg.
    Can u hepl me?

  12. I’ve tried to do ‘make’ on cygwin(or cygwin64) but failed.

    I don’t know what is the problem.

    ———————————————————————————–
    $ make
    LD libavcodec/libavcodec-55.so
    c:/users/home/development/cygwin/tmp/ffmpeg/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: error: libavutil/libavutil.so:1:1: syntax error, unexpected ‘!’, expecting $end
    c:/users/home/development/cygwin/tmp/ffmpeg/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: error: libavutil/libavutil.so: not an object or archive
    collect2: ld returned 1 exit status
    library.mak:106: recipe for target `libavcodec/libavcodec-55.so’ failed
    make: *** [libavcodec/libavcodec-55.so] Error 1

    1. ok.. I found out this is a symbolic link problem. Maybe NDK still dosen’t support cygwin fully.

      *Solution.
      1) backup these original symbolic links or remove
      libavutil/libavutil.so
      libavcodec/libavcodec.so

      2) copy these symbolic links to files
      libavutil/libavutil-52.so -> libavutil.so
      libavcodec/libavcodec-55.so -> libavcodec.so

      1. But the ./build_android.sh execution was interrupted, and after the symlinks files are handled, I have to restart whole build again and the “corrupted” symlinks will appear again. What should I do? Please give me some clue

  13. Hello!

    I follow the steps
    i execute ./build_android.sh
    it takes a while but end up successfully
    the strange thing is no files arm/lib and arm/include created inside
    /home/usama/Desktop/android-ndk-r9/sources/ffmpeg-2.0.1/android
    plz suggest what could i done wrong

    Thanks

  14. Hello,
    I’ve tried to do ‘./build_android.sh’ on cygwin(or cygwin64) but failed.
    ======================================================
    D:/android-ndk-r9b/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/arm-linux-androideabi-gcc is unable to create an executable file.
    C compiler test failed.

    If you think configure made a mistake, make sure you are using the latest
    version from Git. If the latest version fails, report the problem to the
    ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
    Include the log file “config.log” produced by configure as this will help
    solving the problem.
    Makefile:2: config.mak: No such file or directory
    Makefile:48: /common.mak: No such file or directory
    Makefile:91: /libavutil/Makefile: No such file or directory
    Makefile:91: /library.mak: No such file or directory
    Makefile:168: /doc/Makefile: No such file or directory
    Makefile:169: /tests/Makefile: No such file or directory
    make: *** No rule to make target ‘/tests/Makefile’. Stop.
    Makefile:2: config.mak: No such file or directory
    Makefile:48: /common.mak: No such file or directory
    Makefile:91: /libavutil/Makefile: No such file or directory
    Makefile:91: /library.mak: No such file or directory
    Makefile:168: /doc/Makefile: No such file or directory
    Makefile:169: /tests/Makefile: No such file or directory
    make: *** No rule to make target ‘/tests/Makefile’. Stop.
    Makefile:2: config.mak: No such file or directory
    Makefile:48: /common.mak: No such file or directory
    Makefile:91: /libavutil/Makefile: No such file or directory
    Makefile:91: /library.mak: No such file or directory
    Makefile:168: /doc/Makefile: No such file or directory
    Makefile:169: /tests/Makefile: No such file or directory
    make: *** No rule to make target ‘/tests/Makefile’. Stop.
    ======================================================
    I’ve checked config.log and it show :
    D:/android-ndk-r9b/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/arm-linux-androideabi-gcc –sysroot=D:/android-ndk-r9b/platforms/android-9/arch-arm/ -Os -fpic -marm -mcpu= -c -o /tmp/ffconf.M51zb8z1.o /tmp/ffconf.AxCL2OOS.c
    arm-linux-androideabi-gcc.exe: error: missing argument to ‘-mcpu=’
    arm-linux-androideabi-gcc.exe: error: /tmp/ffconf.AxCL2OOS.c: No such file or directory
    arm-linux-androideabi-gcc.exe: fatal error: no input files
    compilation terminated.
    C compiler test failed.

    1. A little old, but I managed to fix it. If you get to the errors before that one you will probably find something about no input file.

      In my case, it was because Cygwin used /temp as temporal folder, and the Android compiler can’t use /temp (C:cygwintemp instead). You must set the TEMP envvar to the Windows-style path.

  15. it works well on linux.
    but it failed on mac os x86-64.
    the ffmpeg version is 2.1.1.
    the error info:
    libavcodec/arm/dcadsp_vfp.S: Assembler messages:
    libavcodec/arm/dcadsp_vfp.S:415: Error: unknown register alias ‘pout’
    libavcodec/arm/dcadsp_vfp.S:417: Error: unknown register alias ‘pin’
    libavcodec/arm/dcadsp_vfp.S:419: Error: unknown register alias ‘pcoef’
    libavcodec/arm/dcadsp_vfp.S:421: Error: unknown register alias ‘decifactor’
    libavcodec/arm/dcadsp_vfp.S:423: Error: unknown register alias ‘oldfpscr’
    libavcodec/arm/dcadsp_vfp.S:425: Error: unknown register alias ‘counter’
    libavcodec/arm/dcadsp_vfp.S:428: Error: unknown register alias ‘scale32’
    libavcodec/arm/dcadsp_vfp.S:430: Error: unknown register alias ‘scale64’
    libavcodec/arm/dcadsp_vfp.S:432: Error: unknown register alias ‘in0’
    libavcodec/arm/dcadsp_vfp.S:434: Error: unknown register alias ‘in1’
    libavcodec/arm/dcadsp_vfp.S:436: Error: unknown register alias ‘in2’
    libavcodec/arm/dcadsp_vfp.S:438: Error: unknown register alias ‘in3’
    libavcodec/arm/dcadsp_vfp.S:440: Error: unknown register alias ‘in4’
    libavcodec/arm/dcadsp_vfp.S:442: Error: unknown register alias ‘in5’
    libavcodec/arm/dcadsp_vfp.S:444: Error: unknown register alias ‘in6’
    libavcodec/arm/dcadsp_vfp.S:446: Error: unknown register alias ‘in7’
    libavcodec/arm/dcadsp_vfp.S:448: Error: unknown register alias ‘coef0’
    libavcodec/arm/dcadsp_vfp.S:450: Error: unknown register alias ‘coef1’
    libavcodec/arm/dcadsp_vfp.S:452: Error: unknown register alias ‘coef2’
    libavcodec/arm/dcadsp_vfp.S:454: Error: unknown register alias ‘coef3’
    libavcodec/arm/dcadsp_vfp.S:456: Error: unknown register alias ‘coef4’
    libavcodec/arm/dcadsp_vfp.S:458: Error: unknown register alias ‘coef5’
    libavcodec/arm/dcadsp_vfp.S:460: Error: unknown register alias ‘coef6’
    libavcodec/arm/dcadsp_vfp.S:462: Error: unknown register alias ‘coef7’
    libavcodec/arm/dcadsp_vfp.S:464: Error: unknown register alias ‘accum0’
    libavcodec/arm/dcadsp_vfp.S:466: Error: unknown register alias ‘accum4’
    libavcodec/arm/dcadsp_vfp.S:468: Error: unknown register alias ‘post0’
    libavcodec/arm/dcadsp_vfp.S:470: Error: unknown register alias ‘post1’
    libavcodec/arm/dcadsp_vfp.S:472: Error: unknown register alias ‘post2’
    libavcodec/arm/dcadsp_vfp.S:474: Error: unknown register alias ‘post3’
    libavcodec/arm/dcadsp_vfp.S:490: Error: unknown register alias ‘in’
    libavcodec/arm/dcadsp_vfp.S:492: Error: unknown register alias ‘sbact’
    libavcodec/arm/dcadsp_vfp.S:494: Error: unknown register alias ‘oldfpscr’
    libavcodec/arm/dcadsp_vfp.S:496: Error: unknown register alias ‘imdct’
    libavcodec/arm/dcadsp_vfp.S:498: Error: unknown register alias ‘window’
    libavcodec/arm/dcadsp_vfp.S:500: Error: unknown register alias ‘out’
    libavcodec/arm/dcadsp_vfp.S:502: Error: unknown register alias ‘buf’
    libavcodec/arm/dcadsp_vfp.S:504: Error: unknown register alias ‘scaleint’
    libavcodec/arm/dcadsp_vfp.S:506: Error: unknown register alias ‘count’
    libavcodec/arm/dcadsp_vfp.S:509: Error: unknown register alias ‘scale’
    make: *** [libavcodec/arm/dcadsp_vfp.o] Error 1

  16. Hello, I have managed to build FFMPEG,but how should i continue from here , i want to create an application which can compress mp4 videos,

    1) How should i add android/arm folder to my applucation
    2) How to add JNI to implement compress process

  17. I want to have ffmpeg builded with –ffmpeg flag enabled to I could use ffmpeg.c file in my project. So I just removed –disable-ffmpeg flag from the ./configure params line and expected to have according .so file but it didn’t happen. Can you help me with it?

  18. hello! your post is really helpful. thanks!
    but, i have a question.
    I try build on cygwin64(OS:win7 64bit).
    above conditions, other guide and post is take out using NDK toolchain to be told.
    Your post seems to build a Linux environment, but I must be Build in cygwin on Windows environment.
    What should using tool-chain? I nead your response.
    Thanks.

  19. There is a typo in your $NDK/sources/ffmpeg-2.0.1/android/arm/Android.mk file: LOCAL_MODULE:= libwsresample should be LOCAL_MODULE:= libswresample

    Very useful anyway, thanks!

  20. i am unable to build ffmpeg
    it gives me error :
    install: /usr/local/share/doc/ffmpeg/ffmpeg.html: chmod: Operation not permitted
    make: *** [install-html] Error 71

  21. when executing build_android.sh after ndk path set getting error
    Desktop/Android/android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-ld: ,noexecstack: unknown -z option
    please how to handle this type of error

  22. Hi! I follow steps to build ffmpeg on android. But i have error. please tell me know why?
    ./build_android.sh: line 16: –prefix=/home/toai/Downloads/android-ndk-r9c/sources/ffmpeg-2.1.3/android/arm: No such file or directory
    ./build_android.sh: line 18: –enable-shared: command not found
    ./build_android.sh: line 20: –disable-static: command not found
    ./build_android.sh: line 22: –disable-doc: command not found
    ./build_android.sh: line 24: –disable-ffmpeg: command not found
    ./build_android.sh: line 26: –disable-ffplay: command not found
    ./build_android.sh: line 28: –disable-ffprobe: command not found
    ./build_android.sh: line 30: –disable-ffserver: command not found
    ./build_android.sh: line 32: –disable-avdevice: command not found
    ./build_android.sh: line 34: –disable-yasm: command not found
    ./build_android.sh: line 36: –disable-doc: command not found
    ./build_android.sh: line 38: –disable-symver: command not found
    ./build_android.sh: line 40: –cross-prefix=/home/toai/Desktop/adt/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-: No such file or directory
    ./build_android.sh: line 42: –target-os=linux: command not found
    ./build_android.sh: line 44: –arch=arm: command not found
    ./build_android.sh: line 46: –enable-cross-compile: command not found
    ./build_android.sh: line 48: –sysroot=/home/toai/Desktop/adt/android-ndk-r9/platforms/android-9/arch-arm/: No such file or directory
    ./build_android.sh: line 50: –extra-cflags=-Os -fpic -marm: command not found
    ./build_android.sh: line 52: –extra-ldflags=: command not found

  23. Thanks a lot for a good tutorial.
    But this is only for arm. Could you give me the guide to get done with x86 and mips. I tried to build for x86 and mips base on the guide you provide. But I failed.

  24. I presume build_android.sh goes in the ffmpeg-2.0.1 folder, but I get a lot of errors, most of them stemming from a file or directory that cannot be found. Using on Mac OS – is that an issue?

  25. I got this error, could you help me?

    In file included from libavcodec/libx264.c:26:0:
    ../x264/x264.h:42:25: fatal error: x264_config.h: No such file or directory
    compilation terminated.

  26. Thanks for the tutorial. I needed to change TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64 to TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86. And libavfilter-3.so to libavfilter-4.so, to get this working

  27. I got following error when i tried to build “FFmpeg” library on “Ubuntu (32 bit)”. What is wrong with me?
    ——————–
    saurabh@saurabh:~/Desktop/adt/android-ndk-r9c/sources/FFmpeg$ ./build_android.shyasm/nasm not found or too old. Use –disable-yasm for a crippled build.

    If you think configure made a mistake, make sure you are using the latest
    version from Git. If the latest version fails, report the problem to the
    ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
    Include the log file “config.log” produced by configure as this will help
    solving the problem.
    ./build_android.sh: line 16: –prefix=/home/saurabh/Desktop/adt/android-ndk-r9c/sources/FFmpeg/android/arm: No such file or directory
    ./build_android.sh: line 18: –enable-shared: command not found
    ./build_android.sh: line 20: –disable-static: command not found
    ./build_android.sh: line 22: –disable-doc: command not found
    ./build_android.sh: line 24: –disable-ffmpeg: command not found
    ./build_android.sh: line 26: –disable-ffplay: command not found
    ./build_android.sh: line 28: –disable-ffprobe: command not found
    ./build_android.sh: line 30: –disable-ffserver: command not found
    ./build_android.sh: line 32: –disable-avdevice: command not found
    ./build_android.sh: line 34: –disable-doc: command not found
    ./build_android.sh: line 36: –disable-symver: command not found
    ./build_android.sh: line 38: –cross-prefix=/home/saurabh/Desktop/adt/android-ndk-r9c/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-: No such file or directory
    ./build_android.sh: line 40: –target-os=linux: command not found
    ./build_android.sh: line 42: –arch=arm: command not found
    ./build_android.sh: line 44: –enable-cross-compile: command not found
    ./build_android.sh: line 46: –sysroot=/home/saurabh/Desktop/adt/android-ndk-r9c/platforms/android-9/arch-arm/: No such file or directory
    ./build_android.sh: line 48: –extra-cflags=-Os -fpic -marm: command not found
    ./build_android.sh: line 50: –extra-ldflags=: command not found
    Makefile:2: config.mak: No such file or directory
    Makefile:53: /common.mak: No such file or directory
    Makefile:94: /libavutil/Makefile: No such file or directory
    Makefile:94: /library.mak: No such file or directory
    Makefile:96: /doc/Makefile: No such file or directory
    Makefile:179: /tests/Makefile: No such file or directory
    make: *** No rule to make target `/tests/Makefile’. Stop.
    Makefile:2: config.mak: No such file or directory
    Makefile:53: /common.mak: No such file or directory
    Makefile:94: /libavutil/Makefile: No such file or directory
    Makefile:94: /library.mak: No such file or directory
    Makefile:96: /doc/Makefile: No such file or directory
    Makefile:179: /tests/Makefile: No such file or directory
    make: *** No rule to make target `/tests/Makefile’. Stop.
    Makefile:2: config.mak: No such file or directory
    Makefile:53: /common.mak: No such file or directory
    Makefile:94: /libavutil/Makefile: No such file or directory
    Makefile:94: /library.mak: No such file or directory
    Makefile:96: /doc/Makefile: No such file or directory
    Makefile:179: /tests/Makefile: No such file or directory
    make: *** No rule to make target `/tests/Makefile’. Stop.

  28. Hello,

    I built successfully this library for android but when I want to use it in eclipse with one of the testprojects you created I have config issues because of my include directories that are located under the arm-linux-androideabi-4.6 toolchain (instead of 4.8 like you did in your script in point 3).
    So I’m wondering if it is necessary to put this toolchain version and if changing this line to the 4.6 version would create a problem.
    Thanks
    Thanks

  29. I have gone through this tutorial but I never get a libffmpeg.so so I cannot run command line arguments in my app. Any suggestions? Which configure options do I need to set or is it something else?

  30. Hi, thanks for your tutorial.

    I find eclipse can’t link ffmpeg lib if I use “LOCAL_SHARED_LIBRARIES” on Android.mk ,but “LOCAL_SHARED_LIBRARIE” can.

    My ffmpeg version:2.1.3
    Ndk version:r9d

    I don’t change any step except version and ndk path!
    is it new version issues or path error?

  31. /*Dear admin, Please don’t remove this question. i need your help*/
    When i execute the build_android.sh it gives me following error-

    sujith@Vaio:~$ cd /home/sujith/ndk9d/sources/ffmpeg
    sujith@Vaio:~/ndk9d/sources/ffmpeg$ sudo chmod +x build_android.sh
    [sudo] password for sujith:
    sujith@Vaio:~/ndk9d/sources/ffmpeg$ ./build_android.sh
    /home/sujith/sujith/ndk9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux- x86_64/bin/arm-linux-androideabi-gcc is unable to create an executable file.
    C compiler test failed.

    If you think configure made a mistake, make sure you are using the latest
    version from Git. If the latest version fails, report the problem to the
    ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
    Include the log file “config.log” produced by configure as this will help
    solving the problem.
    Makefile:2: config.mak: No such file or directory
    Makefile:53: /common.mak: No such file or directory
    Makefile:93: /libavutil/Makefile: No such file or directory
    Makefile:93: /library.mak: No such file or directory
    Makefile:95: /doc/Makefile: No such file or directory
    Makefile:178: /tests/Makefile: No such file or directory
    make: *** No rule to make target `/tests/Makefile’. Stop.
    Makefile:2: config.mak: No such file or directory
    Makefile:53: /common.mak: No such file or directory
    Makefile:93: /libavutil/Makefile: No such file or directory
    Makefile:93: /library.mak: No such file or directory
    Makefile:95: /doc/Makefile: No such file or directory
    Makefile:178: /tests/Makefile: No such file or directory
    make: *** No rule to make target `/tests/Makefile’. Stop.
    Makefile:2: config.mak: No such file or directory
    Makefile:53: /common.mak: No such file or directory
    Makefile:93: /libavutil/Makefile: No such file or directory
    Makefile:93: /library.mak: No such file or directory
    Makefile:95: /doc/Makefile: No such file or directory
    Makefile:178: /tests/Makefile: No such file or directory
    make: *** No rule to make target `/tests/Makefile’. Stop.

    //same result on 32bit and 64bit ndk versions//
    please anyone help me. my current project needs ffmpeg.

    <a href="http://stackoverflow.com/questions/22433205/ffmpeg-android-compile-error&quot; title="you can comment on Stackoverflow"

  32. I believe there’s a typo in the $NDK/sources/ffmpeg-2.0.1/android/arm/Android.mk file you listed. The line LOCAL_MODULE:= libwsresample should read LOCAL_MODULE:= libswresample (swap the ‘s’ and ‘w’).

    Thanks for writing this up. Everything else worked great!

  33. On Ubuntu 13.10 using android NDK r9 with FFMPEG 2.2 “Muybridge” release, I was finally able to accomplish the third step entitled “Build FFMPEG”. I was getting several errors like this:
    Makefile:2: config.mak: No such file or directory
    Makefile:49: /common.mak: No such file or directory
    Makefile:92: /libavutil/Makefile: No such file or directory

    I finally fixed this by changing the SYSROOT variable in the build_android.sh file to point to “…/android-19/arch-arm” instead of …/android-9/arch-arm”.

    Hope this helps.

  34. on MacOSX 10.9.2,
    at file build_android.sh only change
    TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64
    to
    TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64
    all things work fine.
    Thanks.

  35. I finished compiling build_android.sh, but I can not find new folder, and one can tell me why? I’m using ndk-r9d and new ffmpeg, does that make a difference?

  36. Hi,
    I am developing application on windows. I run your command “sudo chomd +x build_android.sh” by the help of cygwin which is required to run linux command on windows and I am getting error “Command not allowed” when entering passphrase. I also try your seconds command “./build_android.sh”. but it gives following error

    $ sh ./build_android.sh
    ./build_android.sh: line 2: $’r’: command not found
    ./build_android.sh: line 3: Real: command not found
    ./build_android.sh: line 4: $’r’: command not found
    ./build_android.sh: line 6: $’r’: command not found
    ./build_android.sh: line 8: $’r’: command not found
    ./build_android.sh: line 10: syntax error near unexpected token `$'{r”
    ‘/build_android.sh: line 10: `{
    ..

    Now I am stuck and not able to do anything. Please help me.

    1. convert your paths as per cygwin compatible:

      NDK=/cygdrive/c/android-ndk-r9d
      SYSROOT=$NDK/platforms/android-9/arch-arm/
      TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64

      Also convert your script in unix format by using a command.

      dos2unix build_android.sh

  37. i’m trying to execute build_android.sh with windows xp (with cygwin). it fails with:
    ./configure–prefix=/cygdrive/C/Documents and Settings/Noah.BIS/android-sdks/ndk/ffmpeg/android/arm–enable-shared–disable-static–disable-doc–disable-ffmpeg–disable-ffplay–disable-ffprobe–disable-ffserver–disable-avdevice–disable-doc–disable-symver–cross-prefix=/home/noah/android-sdks/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi—target-os=linux–arch=arm–enable-cross-compile–sysroot=/home/noah/android-sdks/android-ndk-r9/platforms/android-9/arch-arm/–extra-cflags=-Os -fpic -marm: No such file or directory

    can you help me?

  38. Hello ROMAN10
    could you please also make a FFMPEG static library tutorial?
    I have built static library(.a) but link show a lot unreferenced defined,thanks.

  39. My issue was after building the build_android.sh it cause an error build_one function : not found i think so in script build_one have not be compiled for that i’d give it directly with the function name buid_one. After building no error but folder(android)not found under (NDK/sources/ffmpeg-2.2.2/android) but actually here i use NDK r9 with ffmpeg 2.2.2. with ubuntu 14.04(64 bit).

  40. use the build_android.sh and build in win8 cygwin64 , get error:

    c:/develop/android-ndk-r9d-windows-x86_64/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld.exe: error: cannot open crtbegin_dynamic.o: No such file or directory

  41. Hi, I am done with compiling. I downloaded the android-ffmpeg-tutorial1 project. Also created the Android.mk file an pasted the code as you suggested.
    Once I compilte, I get the following error. Can you please guide.

    Android NDK: ERROR:/usr/local/android-ndk/sources/ffmpeg/android/arm/Android.mk:avformat: LOCAL_SRC_FILES points to a missing file
    /usr/local/android-ndk/build/core/prebuilt-library.mk:45: *** Android NDK: Aborting . Stop.
    Android NDK: Check that jni/lib/libavformat-55.so exists or that its path is correct ..

    P.S. I didn’t change anything in the code or directories (its the same as I downloaded)

  42. Hi , I am compling this library on Ubuntu 12.0 .
    But after following steps:
    android folder not found .
    $NDK/sources/ffmpeg-2.2.2/android

  43. Thanks for great detailed tutorial. Succeed compiling but have some troubles running tutorial_02. Here is video that is played: http://picpaste.com/exeample-7z5JC5hS.png. It corrupts any video in that way. I’m using 2.0.1 ffmpeg, ndk-9. Testing on samsung google nexus (i suppose it have armv7a). What might be wrong? I try to compile ffmpeg for arm and for armv7a:
    CPU=armv7
    PREFIX=$(pwd)/android/$CPU
    ADDI_CFLAGS=”-marm -march=$CPU”
    Both gave result like on the picture. Please help. Thanks in advance

  44. Hi

    I have trying to build ffmpeg on windows 7 with Cygwin.

    I have to changed two things:
    – One is in “build_android.sh” in this file i.e.:
    From:
    TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64
    TO:
    TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64

    – And second is sudo command not present in Cygwin, so I have gave executable permisstion as:
    chmod +x build_android.sh

    And got following error:

    yasm/nasm not found or too old. Use –disable-yasm for a crippled build.

    If you think configure made a mistake, make sure you are using the latest
    version from Git. If the latest version fails, report the problem to the
    ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
    Include the log file “config.log” produced by configure as this will help
    solving the problem.
    ./build_android.sh: line 23: –prefix=/cygdrive/d/_Android/android-sdk_r16-windows/android-ndk-r9d/sources/ffmpeg-2.2.2/android/arm: No such file or directory
    ./build_android.sh: line 26: –enable-shared: command not found
    ./build_android.sh: line 29: –disable-static: command not found
    ./build_android.sh: line 32: –disable-doc: command not found
    ./build_android.sh: line 35: –disable-ffmpeg: command not found
    ./build_android.sh: line 38: –disable-ffplay: command not found
    ./build_android.sh: line 41: –disable-ffprobe: command not found
    ./build_android.sh: line 44: –disable-ffserver: command not found
    ./build_android.sh: line 47: –disable-avdevice: command not found
    ./build_android.sh: line 50: –disable-doc: command not found
    ./build_android.sh: line 53: –disable-symver: command not found
    ./build_android.sh: line 56: –cross-prefix=D:/_Android/android-sdk_r16-windows/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-: No such file or directory
    ./build_android.sh: line 59: –target-os=linux: command not found
    ./build_android.sh: line 62: –arch=arm: command not found
    ./build_android.sh: line 65: –enable-cross-compile: command not found
    ./build_android.sh: line 68: –sysroot=D:/_Android/android-sdk_r16-windows/android-ndk-r9d/platforms/android-9/arch-arm/: No such file or directory
    ./build_android.sh: line 71: –extra-cflags=-Os -fpic -marm: command not found
    ./build_android.sh: line 74: –extra-ldflags=: command not found
    Makefile:2: config.mak: No such file or directory
    Makefile:53: /common.mak: No such file or directory
    Makefile:94: /libavutil/Makefile: No such file or directory
    Makefile:94: /library.mak: No such file or directory
    Makefile:96: /doc/Makefile: No such file or directory
    Makefile:179: /tests/Makefile: No such file or directory
    make: *** No rule to make target ‘/tests/Makefile’. Stop.
    Makefile:2: config.mak: No such file or directory
    Makefile:53: /common.mak: No such file or directory
    Makefile:94: /libavutil/Makefile: No such file or directory
    Makefile:94: /library.mak: No such file or directory
    Makefile:96: /doc/Makefile: No such file or directory
    Makefile:179: /tests/Makefile: No such file or directory
    make: *** No rule to make target ‘/tests/Makefile’. Stop.
    Makefile:2: config.mak: No such file or directory
    Makefile:53: /common.mak: No such file or directory
    Makefile:94: /libavutil/Makefile: No such file or directory
    Makefile:94: /library.mak: No such file or directory
    Makefile:96: /doc/Makefile: No such file or directory
    Makefile:179: /tests/Makefile: No such file or directory
    make: *** No rule to make target ‘/tests/Makefile’. Stop.

    Please help me to build ffmpeg on windows.

    Thanks

  45. I got “./configure: No such file or directory” message at line “–prefix=$PREFIX ” when I run build_android.sh file.

    I put ffmpeg-2.0.1 and build_android.sh in ndk r9 folder

    *I noticed, there is “PREFIX=$(pwd)/android/$CPU” command in build_android.sh but no android folder in NDK folder.

    Help me please, sorry for bad english.

  46. I got
    “./build_android.sh: line 9: ./configure: No such file or directory
    ./build_android.sh: line 28: make: command not found
    ./build_android.sh: line 29: make: command not found
    ./build_android.sh: line 30: make: command not found”

    when run build_android.sh. I put build_android.sh and ffmpeg-2.0.1 in NDK r9 folder.

    Note I work on mac

  47. I got
    “./build_android.sh: line 9: ./configure: No such file or directory
    ./build_android.sh: line 28: make: command not found
    ./build_android.sh: line 29: make: command not found
    ./build_android.sh: line 30: make: command not found” message at line “–prefix=$PREFIX ” when I run build_android.sh file.

    I put ffmpeg-2.0.1 and build_android.sh in ndk r9 folder

    ***Note
    – I noticed, there is “PREFIX=$(pwd)/android/$CPU” command in build_android.sh but no android folder in NDK folder.
    – I work on mac

    Help me please, sorry for bad english.

  48. The above process is not working. (ubuntu 14.04 64 bit)
    i was trying to install ffmpeg in android ndk r9d.

  49. Hi,
    I’m getting this error while building on ubuntu 12.

    yasm not found, use –disable-yasm for a crippled build

    If you think configure made a mistake, make sure you are using the latest
    version from Git. If the latest version fails, report the problem to the
    ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
    Include the log file “config.log” produced by configure as this will help
    solving the problem.
    ./build_android.sh: line 16: –prefix=/home/david/android-ndk-r9d/sources/ffmpeg-2.0.1/android/arm: No such file or directory
    ./build_android.sh: line 18: –enable-shared: command not found
    ./build_android.sh: line 20: –disable-static: command not found
    ./build_android.sh: line 22: –disable-doc: command not found
    ./build_android.sh: line 24: –disable-ffmpeg: command not found
    ./build_android.sh: line 26: –disable-ffplay: command not found
    ./build_android.sh: line 28: –disable-ffprobe: command not found
    ./build_android.sh: line 30: –disable-ffserver: command not found
    ./build_android.sh: line 32: –disable-avdevice: command not found
    ./build_android.sh: line 34: –disable-doc: command not found
    ./build_android.sh: line 36: –disable-symver: command not found
    ./build_android.sh: line 38: –cross-prefix=/home/david/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc: No such file or directory
    ./build_android.sh: line 40: –target-os=linux: command not found
    ./build_android.sh: line 42: –arch=arm: command not found
    ./build_android.sh: line 44: –enable-cross-compile: command not found
    ./build_android.sh: line 46: –sysroot=/home/david/android-ndk-r9d/platforms/android-9/arch-arm/: No such file or directory
    ./build_android.sh: line 48: –extra-cflags=-Os -fpic -marm: command not found
    ./build_android.sh: line 50: –extra-ldflags=: command not found
    Makefile:2: config.mak: No such file or directory
    Makefile:48: /common.mak: No such file or directory
    Makefile:91: /libavutil/Makefile: No such file or directory
    Makefile:91: /library.mak: No such file or directory
    Makefile:168: /doc/Makefile: No such file or directory
    Makefile:169: /tests/Makefile: No such file or directory
    make: *** No rule to make target `/tests/Makefile’. Stop.
    Makefile:2: config.mak: No such file or directory
    Makefile:48: /common.mak: No such file or directory
    Makefile:91: /libavutil/Makefile: No such file or directory
    Makefile:91: /library.mak: No such file or directory
    Makefile:168: /doc/Makefile: No such file or directory
    Makefile:169: /tests/Makefile: No such file or directory
    make: *** No rule to make target `/tests/Makefile’. Stop.
    Makefile:2: config.mak: No such file or directory
    Makefile:48: /common.mak: No such file or directory
    Makefile:91: /libavutil/Makefile: No such file or directory
    Makefile:91: /library.mak: No such file or directory
    Makefile:168: /doc/Makefile: No such file or directory
    Makefile:169: /tests/Makefile: No such file or directory
    make: *** No rule to make target `/tests/Makefile’. Stop.

  50. Hey,

    first, I want to thank you for your nice tutorial.
    I was able to build the lib files as .so and could include them into my project.

    However, I have still one question:
    How do I have to modify the build script, such that it allows me to build the libffmpeg.so (including also x264 support) such that I can include it into my application and invoke it as binary using the command line. I do not want to use JNI here. My goal is only to compile it as binary and include the recent FFMPEG binary version into my project. (As it is described here: http://stackoverflow.com/questions/21996070/android-ffmpeg-best-approach )

    Best regards,
    André

  51. Thanks for the tutorial, just a quick heads up, you have a typo in the Android.mk sample file,

    LOCAL_MODULE:= libwsresample should be libswresample

  52. Trying these steps with Win8/Cygwin. Build fails with the following in config.log

    mktemp -u XXXXXX
    SSOfVs
    check_cpp_condition stddef.h defined __ARM_ARCH_4__ || defined __TARGET_ARCH_4
    check_cpp
    BEGIN /tmp/ffconf.SeSHN5R4.c
    1 #include
    2 #if !(defined __ARM_ARCH_4__ || defined __TARGET_ARCH_4)
    3 #error “unsatisfied condition: defined __ARM_ARCH_4__ || defined __TARGET_ARCH_4”
    4 #endif
    END /tmp/ffconf.SeSHN5R4.c
    /Development/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/arm-linux-androideabi-gcc –sysroot=/Development/android-ndk-r9d/platforms/android-9/arch-arm/ -isysroot /Development/android-ndk-r9d/platforms/android-9/arch-arm/ -Os -fpic -marm -E -o /tmp/ffconf.z78fYSN8.o /tmp/ffconf.SeSHN5R4.c
    arm-linux-androideabi-gcc.exe: error: /tmp/ffconf.SeSHN5R4.c: No such file or directory
    arm-linux-androideabi-gcc.exe: fatal error: no input files
    compilation terminated.

    Anyone come across this? Thanks.

  53. Hi, great tutorial! Thanks a lot!

    I just wanted to point out there’s a typo on the Android.mk:

    “LOCAL_MODULE:= libwsresample”

    should be

    “LOCAL_MODULE:= libswresample”

    No big deal but can be frustrating!

    Best regards,
    Ricardo Romao

  54. I followed these instructions and things seem to build properly but I get a Runtime error about a missing function “atof”. From what I gather this function is now inlined to call strod() in the stdlib.h and can’t be referenced directly anymore. What is a possible solution?

  55. i need help please.

    kishan@ubuntu:~/Desktop/FFmpegTest/jni/ffmpeg-2.3.3$ ./build_android.sh/home/kishan/Desktop/adt/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc is unable to create an executable file.
    C compiler test failed.

    If you think configure made a mistake, make sure you are using the latest
    version from Git. If the latest version fails, report the problem to the
    ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
    Include the log file “config.log” produced by configure as this will help
    solve the problem.
    Makefile:2: config.mak: No such file or directory
    Makefile:58: /common.mak: No such file or directory
    Makefile:98: /libavutil/Makefile: No such file or directory
    Makefile:98: /library.mak: No such file or directory
    Makefile:100: /doc/Makefile: No such file or directory
    Makefile:183: /tests/Makefile: No such file or directory
    make: *** No rule to make target `/tests/Makefile’. Stop.
    Makefile:2: config.mak: No such file or directory
    Makefile:58: /common.mak: No such file or directory
    Makefile:98: /libavutil/Makefile: No such file or directory
    Makefile:98: /library.mak: No such file or directory
    Makefile:100: /doc/Makefile: No such file or directory
    Makefile:183: /tests/Makefile: No such file or directory
    make: *** No rule to make target `/tests/Makefile’. Stop.
    Makefile:2: config.mak: No such file or directory
    Makefile:58: /common.mak: No such file or directory
    Makefile:98: /libavutil/Makefile: No such file or directory
    Makefile:98: /library.mak: No such file or directory
    Makefile:100: /doc/Makefile: No such file or directory
    Makefile:183: /tests/Makefile: No such file or directory
    make: *** No rule to make target `/tests/Makefile’. Stop.

  56. Could you please do a tutorial on ‘NDK r10b’ and ‘ffmpeg 2.3.3’

    It’s not working following this tutorial..

    –prefix=/home/me/android-ndk-r10b/sources/ffmpeg-2.3.3/android/arm: No such file or directory

    and more errors

    Thanks

  57. Great tutorial, but a little outdated with files format. My tools: Ubuntu 13.10 x64, NDK r10b x64, ffmpeg 2.4.1.
    Spent 2.5 days, finally found out that my shell script doesn’t support multiline params format – params for ./configure should not contain line wraps and “”. Also, $SYSROOT should not end with “/” – otherwise system will look for “” directory inside $NDK/platforms/android-L/arch-arm. Last thing – it is better to run “sudo ./build-android.sh”. Non-root users may have troubles with make and mkdir utils.

  58. your Android.mk in $NDK/sources/… has little mistyping.
    the LOCAL_MODULE:= lib(ws)resample for actual libswresample. i spend 4 hours for that mistyped module name, after just copy-and paste your Android.mk. but however, good tutorial. thanks roman10.

  59. Hi,
    Thank you for the build script. I was able to build the script and use it in my project but while testing on AVD running Google API 10 and armeabi architecture SIGILL signal is thrown.
    I tried to find the instruction at the fault address f1010200 using arm-linux-androideabi-objdump tool and the instruction is “setend be”. I then checked on the arm site and it lists it as available on arm-v6 and above,

    Extract from the site:

    –Begin
    This ARM instruction is available in ARMv6 and above.
    This 16-bit Thumb instruction is available in T variants of ARMv6 and above, except the ARMv6-M and ARMv7-M architectures.
    There is no 32-bit version of this instruction in Thumb.
    –End

    I might be looking at wrong arm documentation, Do you know what is causing this error?

  60. I am getting this error while compiling ffmpeg on mac os
    but i am follow all above instruction so please anybody will help me

    Kumars-MacBook-Pro:ffmpeg-2.0.1 kumarmanaswi$ ./build_android.sh
    ./build_android.sh: line 8: ./configure: Permission denied
    Makefile:2: config.mak: No such file or directory
    Makefile:48: /common.mak: No such file or directory
    Makefile:91: /libavutil/Makefile: No such file or directory
    Makefile:91: /library.mak: No such file or directory
    Makefile:168: /doc/Makefile: No such file or directory
    Makefile:169: /tests/Makefile: No such file or directory
    make: *** No rule to make target `/tests/Makefile’. Stop.
    Makefile:2: config.mak: No such file or directory
    Makefile:48: /common.mak: No such file or directory
    Makefile:91: /libavutil/Makefile: No such file or directory
    Makefile:91: /library.mak: No such file or directory
    Makefile:168: /doc/Makefile: No such file or directory
    Makefile:169: /tests/Makefile: No such file or directory
    make: *** No rule to make target `/tests/Makefile’. Stop.
    Makefile:2: config.mak: No such file or directory
    Makefile:48: /common.mak: No such file or directory
    Makefile:91: /libavutil/Makefile: No such file or directory
    Makefile:91: /library.mak: No such file or directory
    Makefile:168: /doc/Makefile: No such file or directory
    Makefile:169: /tests/Makefile: No such file or directory
    make: *** No rule to make target `/tests/Makefile’. Stop.
    Kumars-MacBook-Pro:ffmpeg-2.0.1 kumarmanaswi$

    Thanks

  61. hi
    I got a error , what is wrong ?

    localhost hello-jni # ndk-build
    [arm64-v8a] Gdbserver : [aarch64-linux-android-4.9] libs/arm64-v8a/gdbserver
    [arm64-v8a] Gdbsetup : libs/arm64-v8a/gdb.setup
    [x86_64] Gdbserver : [x86_64-4.9] libs/x86_64/gdbserver
    [x86_64] Gdbsetup : libs/x86_64/gdb.setup
    [mips64] Gdbserver : [mips64el-linux-android-4.9] libs/mips64/gdbserver
    [mips64] Gdbsetup : libs/mips64/gdb.setup
    [armeabi-v7a] Gdbserver : [arm-linux-androideabi-4.8] libs/armeabi-v7a/gdbserver
    [armeabi-v7a] Gdbsetup : libs/armeabi-v7a/gdb.setup
    [armeabi] Gdbserver : [arm-linux-androideabi-4.8] libs/armeabi/gdbserver
    [armeabi] Gdbsetup : libs/armeabi/gdb.setup
    [x86] Gdbserver : [x86-4.8] libs/x86/gdbserver
    [x86] Gdbsetup : libs/x86/gdb.setup
    [mips] Gdbserver : [mipsel-linux-android-4.8] libs/mips/gdbserver
    [mips] Gdbsetup : libs/mips/gdb.setup
    [arm64-v8a] Compile : hello-jni <= hello-jni.c
    [arm64-v8a] Prebuilt : libavformat-56.so <= /sources/ffmpeg-2.5.1/android/arm/lib/
    [arm64-v8a] Prebuilt : libavcodec-56.so <= /sources/ffmpeg-2.5.1/android/arm/lib/
    [arm64-v8a] Prebuilt : libswscale-3.so <= /sources/ffmpeg-2.5.1/android/arm/lib/
    [arm64-v8a] Prebuilt : libavutil-54.so <= /sources/ffmpeg-2.5.1/android/arm/lib/
    [arm64-v8a] SharedLibrary : libhello-jni.so
    ./obj/local/arm64-v8a/libavformat-56.so: error adding symbols: File in wrong format
    collect2: error: ld returned 1 exit status
    make: *** [obj/local/arm64-v8a/libhello-jni.so] Error 1

  62. Before executing build_android.sh, don’t forget to change the NDK path to the path to the Android NDK on your machine. Like I did

  63. I followed your tutorial, everything compiles and works fine. Now I’ve got 2 questions:

    1) To enable compilation of Drawtext video-filter, I need to configure FFmpeg with –enable-libfreetype, which requires FreeType2. I downloaded and extracted FreeType-2.5.5 to $NDK/sources. How do I have to configure built_android.sh in order to make it work?

    2) All I want from FFMpeg is just burning some text into videofile: drawtext=”fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text=’Test Text'”
    Do I have to compile FFMpeg as a shared library to use drawtext? Or would compiling as a static library and using a command line be enough?

  64. Hi,
    I am able to genrate armeabi folder and its .so file from .build_android.sh but unable to genrate other folder and its .so files like armeabi-v7a and x86.

    Can you please help me.

    Thanks,
    Mohit

  65. Hi.
    The 1st great tutorial.
    I built all as you wrote.
    Unfortunately in /android/arm/lib does not have libffmpeg.so file.
    I am using ndk10

  66. Hey man,

    I am able to run build_android.sh script.. but its not creating that ‘android’ folder in my source/ffmpeg folder !!
    what should I do? Plz help me.

    Another Doubt: The thing ‘arm’ in that .sh file is supposed to be changed according to machine env???? If that is the case, can you guide us for x86???

    I am using Ndk r10, ffmpeg 2.5.4, ubuntu x86

    Thanks for ur time.

    Palak.

  67. Hi I am following your tutorial for build ffmpeg for Android

    I am using Mac osx 10.9.5,NDK r10d,ffmpeg 2.6.1

    while run the ./build_android.sh script it showed the below errors

    Hubs-Mac-mini:ffmpeg-2.6.1 hubmaci7$ ./build_android.sh
    Configured with: –prefix=/Applications/Xcode.app/Contents/Developer/usr –with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/4.2.1
    Configured with: –prefix=/Applications/Xcode.app/Contents/Developer/usr –with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/4.2.1
    /hubmaci7/Pictures/Hubino/Jamal/android-ndk-r10d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc is unable to create an executable file.
    C compiler test failed.

    If you think configure made a mistake, make sure you are using the latest
    version from Git. If the latest version fails, report the problem to the
    ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
    Include the log file “config.log” produced by configure as this will help
    solve the problem.
    Makefile:2: config.mak: No such file or directory
    Makefile:59: /common.mak: No such file or directory
    Makefile:100: /libavutil/Makefile: No such file or directory
    Makefile:100: /library.mak: No such file or directory
    Makefile:102: /doc/Makefile: No such file or directory
    Makefile:185: /tests/Makefile: No such file or directory
    make: *** No rule to make target `/tests/Makefile’. Stop.
    Makefile:2: config.mak: No such file or directory
    Makefile:59: /common.mak: No such file or directory
    Makefile:100: /libavutil/Makefile: No such file or directory
    Makefile:100: /library.mak: No such file or directory
    Makefile:102: /doc/Makefile: No such file or directory
    Makefile:185: /tests/Makefile: No such file or directory
    make: *** No rule to make target `/tests/Makefile’. Stop.
    Makefile:2: config.mak: No such file or directory
    Makefile:59: /common.mak: No such file or directory
    Makefile:100: /libavutil/Makefile: No such file or directory
    Makefile:100: /library.mak: No such file or directory
    Makefile:102: /doc/Makefile: No such file or directory
    Makefile:185: /tests/Makefile: No such file or directory
    make: *** No rule to make target `/tests/Makefile’. Stop.
    Hubs-Mac-mini:ffmpeg-2.6.1 hubmaci7$

  68. I am getting this error while executing command “./build_android.sh” .I am using cygwin on windows 8.1

    /build_android.sh: line 6: syntax error near unexpected token `$'{r”
    ‘/build_android.sh: line 6: `{

Leave a Reply

Your email address will not be published. Required fields are marked *