How to Build FFmpeg for Android

For how to build ffmpeg 2.0.1 with NDK r9, please refer to: http://www.roman10.net/how-to-build-ffmpeg-with-ndk-r9/

ffmpeg is an open-source platform for recording, converting, playing and streaming video and audio. It includes libavcodec, a popular video/audio codec.

Several popular Android applications are built based on FFmpeg, including RockPlayer, MoboPlayer, acrMedia, vitalPlayer, V-Cut Express etc. If you’re developing multimedia applications that needs a video/audio codec, ffmpeg is a good choice.

This blog covers how to compile ffmpeg for Android, and next blog will cover how to use ffmpeg to build a simple application.

The steps below are done on Ubuntu 10.10, android NDK r5b, and ffmpeg 0.8. It should work on other versions of Android NDK and ffmpeg, but it may require minor changes.

0. Download Android NDK r5b

You can download the NDK here. Once downloaded, simply extract the file, and you’ll have a folder named android-ndk-r5b. You’ll need the folder location for configurations later.

1. Download Source Code for FFmpeg

You can download the source code from here. If you want to get the latest code, you can use git or svn, the link has detailed  instructions. But for this tutorial, the FFmpeg 0.8 “Love” release is downloaded.

After downloaded the source, extract it and you’ll have a folder named ffmpeg-0.8.

2. Build FFmpeg (The script is based on RockPlayer build script)

2.1 Copy and Paste the bash script from here to a text editor, and save it as build_android.sh under ffmpeg-0.8 folder.

Note that NDK location has to be changed according to your android-ndk-r5b folder location. In my machine, it’s at ~/Desktop/android/, so it’s set as

NDK=~/Desktop/android/android-ndk-r5b
PLATFORM=$NDK/platforms/android-8/arch-arm/
PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86

You may also need to adjust the PLATFORM based on which version of SDK you’re using, android-8 corresponds to android SDK 2.2.

The default configuration in the script disables a lot of stuff to speed up the build, you can change the configuration to suit your needs. Besides, you can compile for multiple hardware platforms, but here we only enable arm v7vfpv3 to speed up the build process.

2.2 Make sure the bash script is executable. Go to the ffmpeg-0.8 directory in terminal, then type the following command,

sudo chmod 755 build_android.sh

2.3 Then execute the script, by typing the following command,

./build_android.sh

The compilation will take a while (several minutes or above depends on your machine) to finish.

Update for NDK-r6:

For android NDK-r6, the build_android.sh script might not work. You can try the script here.

Note that you may need to create ./android/armv7-a/ folder in the ffmpeg directory yourself. (Thanks to mgg28831 for this).

If you encounter permission denied error, you can try sudo ./build_android.sh.

3. The Output of the Build

Once the script finishes execution, there’ll be a folder called android under ffmpeg-0.8 directory, which contains all the output of the build.

4. To be Continued

Once the library is compiled successfuly, the next step is to use it to build Android apps. This is covered in next blog, How to Build Android Apps Based on FFmpeg By an Example.

Reference:

RockPlayer open source component: http://rockplayer.freecoder.org/tech.html

0 thoughts on “How to Build FFmpeg for Android”

  1. I’m having an error building the ffmpeg 0.8 :/

    Here is the output:

    arm-linux-androideabi-gcc: Internal error: Killed (program cc1)
    Please submit a full bug report.
    See for instructions.
    make: *** [libavcodec/imgconvert.o] Error 1
    make: *** Waiting for unfinished jobs….

    Have you come across it?

    1. What version of Android NDK do you use? I’m using r5b, the latest version is r6. It might require minor changes to the build_android.sh script, especially the first three lines. Make sure the folder location is correct.
      When I build it on Linux using NDK r5b, it builds successfully.

      1. I also build it using linux and NDK rb5.

        I have changed the $NDK to my NDK path and double checked the result $PLATFORM and $PREBUILT vars.

      2. This problem is solved!

        I think that the disk was running out of space during the build. Cleanup some folders, build again and it completed!

    1. Are you using the sample code in “How to Build Android Applications Based on FFmpeg by An Example”? It doesn’t play out the video, it’s a very simple example to show that you can use ffmpeg API calls in android. If you want to play the video, you’ll need to develop a player. You can refer to ffplay.c in ffmpeg code for reference.

      1. Oh, I thought it was a player! :)

        Btw, I got it working. Needed to place the .so files in the android system folders.

  2. Hello. I’m having an error when building.
    I’m using NDK r6.

    First was an error like:
    arm-linux-androideabi-ld: cannot open output file ./android/armv7-a/libffmpeg.so: No such file or directory

    So I created directory manually. And then got like this.

    libavcodec/libavcodec.a: member libavcodec/libavcodec.a(4xm.o) in archive is not an object

    Feels like I’m doing something wrong. But I don’t know what 😐

    1. I compiled using NDK r5b, but I think r6 should also work. Please double check the android_build.sh script, make sure the path is set correctly (the first 3 lines). You shouldn’t need to create the directory manually if everything goes well.

      1. I’m pretty sure about that path is correct.

        Also, can I use your built ffmpeg library for Android 2.1up1?
        There are no android-7 directory in android NDK r6.

      1. I have not tested the scripts with NDK r6 yet. I’ll update this post if I can figure it out. Can I suggest you to look into the build_android.sh script and try to understand the script? You may get some clue there. :)

    2. I’m also having the same problem with ndk-r6.

      It may be worth noting that the output also has:
      ./build_android.sh: line 58: –prefix=./android/armv7-a: No such file or directory
      ./build_android.sh: line 60: –enable-cross-compile: command not found
      ./build_android.sh: line 62: –extra-libs=-lgcc: command not found
      ./build_android.sh: line 64: –arch=arm: command not found

      there are a bunch of other “command not found”s on the flags. nothing gets output to /android/armv7-a/

        1. Hi, Mike,

          I tried it with ndk-r6, it also produces the same error. I haven’t figured it out how to solve them yet.

          1. hiho!

            i’ve had the same problem, but i think it’s working now.

            in my case the problem were the spaces in the this part of the shell script if you copy/paste them:

            function build_one

            {

            ./configure –target-os=linux

            –prefix=$PREFIX

            –enable-cross-compile

            –extra-libs=”-lgcc”

            –arch=arm

            Now it works with ndk r5b and r6 as well.

            but there is another problem: in my case it’s missing a file ($PREBUILT/bin/arm-linux-androideabi-pkg-config) in the ndk folder (r5b and r6) and i don’t know why.

            i’ve downloaded the ndk’s from the official android developer side and from other developer sides, but none of them includes this file.

  3. Hey, thanks for this tutorial u have really simplified things here.

    I am working on Windows and running the commands through cygwin, I have ndk r5 for windows.

    This is what I changed in the .sh file:

    NDK=/home/android-ndk-r5
    PLATFORM=$NDK/platforms/android-8/arch-arm/
    PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows

    I am getting this error:

    WARNING: /home/android-ndk-r5/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-androideabi-pkg-config not found, library detection may fail.
    mktemp -u XXXXXX
    1nBAec
    check_ld
    check_cc
    BEGIN /tmp/ffconf.0wfBU2oV.c
    1 int main(void){ return 0; }
    END /tmp/ffconf.0wfBU2oV.c
    /home/android-ndk-r5/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-androideabi-gcc –sysroot=/home/android-ndk-r5/platforms/android-8/arch-arm/ -O3 -fpic -DANDROID -DHAVE_SYS_UIO_H=1 -Dipv6mr_interface=ipv6mr_ifindex -fasm -Wno-psabi -fno-short-enums -fno-strict-aliasing -finline-limit=300 -mfloat-abi=softfp -mfpu=vfpv3-d16 -marm -march=armv7-a -c -o /tmp/ffconf.KFnLLdS7.o /tmp/ffconf.0wfBU2oV.c
    arm-linux-androideabi-gcc.exe: /tmp/ffconf.0wfBU2oV.c: No such file or directory
    arm-linux-androideabi-gcc.exe: no input files
    C compiler test failed.

    Do you have any idea how I can fix this, is this a problem with the windows version vs the linux one ?

    Thanks

  4. I tried this too, I gave full permissions for the /tmp directory but with no success..

    I actually could not find this package anywhere in the ndk:
    arm-linux-androideabi-pkg-config

    Might this be the problem it fails to generate that other file??

    Thanks for your help.

        1. Also took everything on Ubunto , however still get the error :

          /home/android-ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-pkg-config not found, library detection may fail.

          Finally it fails with the error:
          libavformat/libavformat.a : Permission denied

          btw, library was created.

          Do you have any idea how I can fix this ???

  5. Hello, I use your method and meet a problem the terminal shows:
    make: *** [ffmpeg_g] Error 1
    libavutil/libavutil.a(intfloat_readwrite.o):In function ‘av_dbl2ext’:
    ../libavutil/intfloat_readwrite.c:86:undefined reference to ‘_fixunsdfdi’
    then I saw the config.h there is ‘#define restrict restrict’ so I think maybe the two restrict thing, Could you give me some advice to fix it, Thx.

  6. I tried to compile with android-ndk-r5 and i get this error
    /home/dani/android/android-ndk-r5b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-ar: creating libavcodec/libavcodec.a
    /home/dani/android/android-ndk-r5b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-ld: libavformat/libavformat.a: No such file: No such file or directory

  7. halosys@halosys-VirtualBox:~/Desktop/FFmpegTest/jni$ /home/halosys/Desktop/android-ndk/ndk-build
    Android NDK: ERROR:/home/halosys/Desktop/FFmpegTest/jni/Android.mk:ffmpeg-prebuilt: LOCAL_SRC_FILES points to a missing file
    Android NDK: Check that /home/halosys/Desktop/FFmpegTest/jni/ffmpeg-0.8/android/armv7-a/libffmpeg.so exists or that its path is correct
    /home/halosys/Desktop/android-ndk/build/core/prebuilt-library.mk:43: *** Android NDK: Aborting . Stop.

    Please help me

  8. Please confirm me , is some one compiled this code or not?

    Because i am alws facing issue with this code so just confirming about this code .

    1. Not only me. Many other people confirmed they can compile the code under Linux. Please read the post and the comments. But I don’t have time to help you debugging these days. Quite busy on something.

      1. It can compile on Ubuntu. And many others and I have run the example successfully.

        Sorry, I don’t have time to help you debug. Please follow the instructions and I believe you can figure it out yourself.

  9. Hi,

    Your tutorial is the best in the topic! Love it!

    I was able to build all profiles, except the neon support. No error message, simply the so file is not generated. Using Ubuntu 10.10, ffmpeg 0.8.

    Any hint would be highly appriciated.

    thx,
    Laszlo

      1. Hey, thx for your quick response. Seems it compiles if i remove the “disable-everything” line. The build is a bit big now, so I started disabling each type of stuff (encoders, demuxers) one by one. Seems disable decoders is what it doesn’t like.

  10. Ubuntu compiled successfully
    However my project need to have rtmp,h264 and aac.
    So how can i add librtmp,libx264 and libfaac
    I am not familiar with it,Could someone tell me the way???

    For windows,I dun think it can be.
    I wait for more than 1 hour but it show nothing
    but ubuntu do it!

    1. You’ll need to learn how to configure ffmpeg compilation and change the build_android.sh script. Use ./configure -h in your command line under ffmpeg source code folder to see help info of how to configure the build for ffmpeg.

  11. I keep getting the “No such file or directory” error following these steps:

    ./build_android.sh: line 56: /home/daniel/Desktop/android-ndk-r5b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-ar: No such file or directory

    In my script I changed the directory to where my NDK is but it still seems not able to find it. I am also not too familiar with working in Linux environments. I’d appreciate any insight.

  12. Hi,

    I’m building this on OSX – have used the script that ludovic_perrier posted but am getting the following error:

    /Users/Olly/Dev/android-ndk-r7/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/bin/arm-linux-androideabi-ld: libavformat/libavformat.a: No such file: No such file or directory

    Do you know how to solve this please?

    Thanks.

  13. I’m confused why we need to use sudo to compile this in ubuntu. I have tried without sudo and it doesn’t work. Is this installing the libraries in my system or something? I don’t understand why it needs super user priviledges to compile.. Anyone know why? This leaves a bad taste in my mouth.

  14. Ok I figured out how to compile without sudo priviledges.. All you do is change the make -j4 install command to
    make DESTDIR=$DESTDIR -j4 install

    Create a variable named DESTDIR at the top of the script and make it whatever you want.. This will prevent make from trying to put the files in /usr/local/lib and will put them in your directory ($DESTDIR) instead.

    1. I haven’t done it yet. But I think it’s doable. You may consider compile libx264 first, and then link the libx264 with ffmpeg when you compile it.

  15. I don’t understand what I am doing wrong. I have tried with ndk r5b and r6 (always correctly setting ndk path), on ubuntu 11.10 x64 with ffmpeg 0.8.10 ‘Love’ release. I always have a lot of “not found” :

    build_android_r6.sh: 24: function: not found
    : not foundid_r6.sh: 25: {
    “.known option ”
    See ./configure –help for available options.
    build_android_r6.sh: 27: –disable-shared: not found
    build_android_r6.sh: 28: –enable-static: not found
    build_android_r6.sh: 29: –enable-gpl: not found
    build_android_r6.sh: 30: –enable-version3: not found
    build_android_r6.sh: 31: –enable-nonfree: not found
    build_android_r6.sh: 32: –disable-doc: not found
    build_android_r6.sh: 33: –disable-ffmpeg: not found
    build_android_r6.sh: 34: –disable-ffplay: not found
    build_android_r6.sh: 35: –disable-ffprobe: not found
    build_android_r6.sh: 36: –disable-ffserver: not found
    build_android_r6.sh: 37: –disable-avdevice: not found
    build_android_r6.sh: 38: –disable-avfilter: not found
    build_android_r6.sh: 39: –disable-postproc: not found
    build_android_r6.sh: 40: –enable-small: not found
    /bin/arm-linux-androideabi-: not found3/prebuilt/linux-x86ads/android-ndk-r6
    build_android_r6.sh: 42: –enable-cross-compile: not found
    build_android_r6.sh: 43: –target-os=linux: not found
    /usr/include: not foundch-arm/ra-cflags=-I/home/guilo/Downloads/android-ndk-r6
    /usr/lib -nostdlib: not found/ra-ldflags=-L/home/guilo/Downloads/android-ndk-r6
    build_android_r6.sh: 46: –arch=arm: not found
    build_android_r6.sh: 47: –disable-symver: not found
    build_android_r6.sh: 48: –disable-debug: not found
    build_android_r6.sh: 49: –disable-stripping: not found
    : not foundid_r6.sh: 50:
    : Aucun fichier ou dossier de ce type
    : Aucun fichier ou dossier de ce type
    : Aucun fichier ou dossier de ce type
    : Aucun fichier ou dossier de ce type
    : Aucun fichier ou dossier de ce type
    : Aucun fichier ou dossier de ce type
    ». Arrêt.Pas de règle pour fabriquer la cible « clean
    ». Arrêt.Pas de règle pour fabriquer la cible « install
    /bin/arm-linux-androideabi-ar: not foundprebuilt/linux-x86-r6
    /bin/arm-linux-androideabi-ld: not foundprebuilt/linux-x86-r6
    : not foundid_r6.sh: 61: }
    build_android_r6.sh: 62: function: not found
    : not foundid_r6.sh: 63: {
    /bin/arm-linux-androideabi-ar: not foundprebuilt/linux-x86-r6
    /bin/arm-linux-androideabi-ld: not foundprebuilt/linux-x86-r6
    : not foundid_r6.sh: 66: }
    : not foundid_r6.sh: 79: build_one_r6

  16. I would like to put some help here.
    I am using the Ubuntu 11.4 “Natty Narwhal”. I was building it for the Nvidia Tegra chipset.

    I wasn’t able to get it build, the error thrown was (It’s a build one error you get in the end):

    : not found id_r6.sh: 79: build_one_r6

    Here, what I did.
    Do not call the build script with sudo (unless you are helpless).
    Instead make the current user the owner of the directory wherever you extract the ffmpeg source code.
    And, don’t forget to create the directory path ./android/armv7-a/ in ffmpeg directory, even if you are building it with ndk-r5b.(The folder name depend on the cpu type, you’ll understand it better if you have already tried poking around)

    To download android ndk revision 5b and rev.6 use the following command:
    wget http://dl.google.com/android/ndk/android-ndk-r5b-linux-x86.tar.bz2

    wget http://dl.google.com/android/ndk/android-ndk-r6-linux-x86.tar.bz2

  17. Hi,

    I really appreciate that you have shared your build process, it works like a charm! I have just successfully built the latest FFmpeg 0.10 “Freedom” with the latest Android NDK r7b on Mac OS X Lion.

    Many thanks!!!
    Cheers, Vita

  18. Hi,

    i got this following error after ./build_android.sh command

    INSTALL install-progs-yes
    INSTALL ffmpeg
    INSTALL ffplay
    INSTALL ffprobe
    INSTALL ffserver
    libavcodec/libavcodec.a: member libavcodec/libavcodec.a(4xm.o) in archive is not an object

    can any one know how to solve this error ?
    im using ubuntu 10.04 64bit.

    regards
    vs

    1. Linux x64 will not work as you need to have bothe Android SDK and NDK for linux and google does not provide a 64 sdk for linux only x86 but does offer a x64 for the ndk but ndk needs to have the sdk to work so x64 verison w/o sdk is pointless as nothing will build with it so try x86 of ubuntu or linux and it will work im using xubuntu 11.10 x86

  19. hi ,
    i got the error as follows after ./build_android.sh command

    INSTALL libswresample/libswresample.a
    INSTALL libswscale/libswscale.a
    INSTALL libavutil/libavutil.a
    LD ffmpeg_g
    LD ffplay_g
    LD ffprobe_g
    LD ffserver_g
    CP ffmpeg
    CP ffplay
    STRIP ffmpeg
    STRIP ffplay
    CP ffprobe
    STRIP ffprobe
    CP ffserver
    STRIP ffserver
    INSTALL install-progs-yes
    INSTALL ffmpeg
    INSTALL ffplay

    any one know how to solve this error ?
    im using ubuntu 10.04 64bit

    thanks
    vs
    INSTALL ffprobe
    INSTALL ffserver
    libavcodec/libavcodec.a: member libavcodec/libavcodec.a(4xm.o) in archive is not an object

  20. Hi,
    I’ve the problem with ffmpeg. I compiled source successful without error by tutorial, but in my device (Asus TF101 – Tegra2) at startup ./ffmpeg I get error: [1] + Stopped (signal) and [1] Segmentation fault.

    Any ideas?

    Thx and sorry for my english :)

  21. same problem here, i build ffmpeg binary based android-8 (for my “samsung galaxy S”) i get ./ffmpeg Segmentation fault. any solution ?

  22. HI,
    I have been using the ndk-r7 and compiled successfully.I got teh android folder in the ffmpeg directory where i can see
    armv7-a ( So i think there is no need to create one)
    i have got the libffmpeg.so inside it.Is it all right?
    Why the ndk-r6 ‘s build.sh has to changed? Have i done all correct?Is there any self check method.? I can paste this .so in my Android jni folder correct?So many questions?Where is author of the blog.Thanks to him for posting these steps but can i answer my questions as well.
    Rgds
    Saurabh

  23. Can you please give me a method to build ffmpeg on Windows.
    I’m really struggling to build it on Windows 7.

    Thanks.
    Rahul

  24. Thanks for your nice tutorial.
    I’m using ndk-r7c to compile the native code, the version of ffmpeg i used is 0.10.2, and the script I used to build ffmpeg is your first one.
    Every thing works fine, but when I run my app I get a “FC”. Take a look on logcat I saw this error
    “java.lang.UnsatisfiedLinkError: Couldn’t load ffmpeg: findLibrary returned null”
    Can you get me out of this?

  25. hey there!

    thanks for the article and the build files!

    currently I’m trying to build ffmpeg-0.10.2 on ubuntu 10.4 with the ndk-r7c for armv7-a but I’m not able to build it.

    I’m getting a

    “WARNING: /android-ndk-r7c/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-pkg-config not found, library detection may fail.”

    warning and then the build failes with a lot of warnings and:

    collect2: ld returned 1 exit status
    make: *** [ffmpeg_g] Error 1

    did you ever try to build it with this versions?

    cheers

  26. using ndk-r8 and vmplayer (ubuntu 12.04) on windows…

    had to make one, small revision…

    after chmod”ing ‘android-build.sh’ I had to use ‘sudo’ in the expression calling the shell…

    sudo ./build_android.sh

  27. Thanks a lot! This worked like a charm! Any idea what I’d have to do to compile it for an Android device running Intel chips?

  28. Hi,
    I’m using ubuntu-12.04,ndk-0.8,ffmpeg-0.8 But at the line
    if ((lError = av_open_input_file(&gFormatCtx, gFileName, NULL, 0, NULL)) !=0 ) {
    LOGE(1, “Error open video file: %d”, lError);
    return; //open file failed
    }
    the application is getting fail.
    without solving this issue there is nothing useful in this app .any help will be appraciated..
    thanks in advance.

  29. Hi,
    Thanks for the great post!
    When I run the .sh file I get all kind of errors:

    Makefile:2: config.mak: No such file or directory
    Makefile:47: /common.mak: No such file or directory
    Makefile:89: /libavutil/Makefile: No such file or directory
    Makefile:89: /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:47: /common.mak: No such file or directory
    Makefile:89: /libavutil/Makefile: No such file or directory
    Makefile:89: /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

    Any ideas?

    Thanks!

  30. When I launch my app on emulator, I obtain always the same error:

    “E/AndroidRuntime(576): Caused by: java.lang.UnsatisfiedLinkError: Couldn’t load ffmpeg”

  31. Why i modify it to fit with my machine, it can run but at the end it report that:

    INSTALL libavformat/libavformat.a
    INSTALL libswscale/libswscale.a
    INSTALL libavcodec/libavcodec.a
    install: cannot stat `libswscale/libswscale.a’: No such file or directory
    install: cannot stat `libavcodec/libavcodec.a’: No such file or directory

    I don’t know why, could you help me please?

    Thanks
    Calrk

  32. Hi,

    I tried to compile ffmpeg using ubundu 12.04 and android-ndk-r8.

    I got the following error while compiling build_android.sh

    ./configure: 1660: ./configure: uname: not found
    ./configure: 1664: ./configure: uname: not found
    ./configure: 306: ./configure: tr: not found
    ./configure: 314: ./configure: sed: not found
    ./configure: 314: ./configure: sed: not found
    ./configure: 314: ./configure: sed: not found
    ./configure: 314: ./configure: sed: not found
    ./configure: 314: ./configure: sed: not found
    ./configure: 314: ./configure: sed: not found
    ./configure: 314: ./configure: sed: not found
    ./configure: 314: ./configure: sed: not found
    ./configure: 314: ./configure: sed: not found
    ./configure: 314: ./configure: sed: not found
    ./configure: 314: ./configure: sed: not found
    ./configure: 314: ./configure: sed: not found
    ./configure: 314: ./configure: sed: not found
    ./configure: 314: ./configure: sed: not found
    ./configure: 314: ./configure: sed: not found
    ./configure: 314: ./configure: sed: not found
    ./configure: 314: ./configure: sed: not found
    ./configure: 314: ./configure: sed: not found
    ./configure: 314: ./configure: sed: not found
    ./configure: 314: ./configure: sed: not found
    ./configure: 314: ./configure: sed: not found
    ./configure: 314: ./configure: sed: not found
    ./configure: 314: ./configure: sed: not found
    ./configure: 314: ./configure: sed: not found
    ./configure: 314: ./configure: sed: not found
    ./configure: 314: ./configure: sed: not found
    ./configure: 314: ./configure: sed: not found
    ./configure: 314: ./configure: sed: not found
    ./configure: 314: ./configure: sed: not found
    ./configure: 314: ./configure: sed: not found
    ./configure: 1740: ./configure: sed: not found
    ./configure: 1740: ./configure: sed: not found
    ./configure: 1740: ./configure: sed: not found
    ./configure: 1740: ./configure: sed: not found
    ./configure: 1740: ./configure: sed: not found
    ./configure: 1740: ./configure: sed: not found
    ./configure: 1740: ./configure: sed: not found
    ./configure: 1740: ./configure: sed: not found
    ./configure: 1740: ./configure: sed: not found
    ./configure: 1740: ./configure: sed: not found
    ./configure: 1740: ./configure: sed: not found
    ./configure: 1756: ./configure: ./configure: 1756: ./configure: grep: not foundls: not found

    ./configure: 1756: ./configure: ./configure: 1756: ./configure: ls: not found
    grep: not found
    ./configure: 1756: ./configure: ls: not found
    ./configure: 1756: ./configure: grep: not found
    ./configure: 1756: ./configure: ./configure: 1756: ./configure: grep: not found
    ls: not found
    ./configure: 1756: ./configure: ./configure: 1756: ./configure: grep: not found
    ls: not found
    ./configure: 302: ./configure: tr: not found
    ./configure: 302: ./configure: tr: not found
    ./configure: 302: ./configure: tr: not found
    ./configure: 302: ./configure: tr: not found
    ./configure: 302: ./configure: tr: not found
    ./configure: 302: ./configure: tr: not found
    ./configure: 302: ./configure: tr: not found
    ./configure: 302: ./configure: tr: not found
    ./configure: 302: ./configure: tr: not found
    ./configure: 302: ./configure: tr: not found
    ./configure: 302: ./configure: tr: not found
    ./configure: 1831: ./configure: sed: not found
    Unknown option “–target-os=linux”.
    See ./configure –help for available options.
    ./build_android.sh: line 54: make: command not found
    ./build_android.sh: line 55: make: command not found
    ./build_android.sh: line 56: /home/sakthi/Desktop/android/android-ndk-r5b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-ar: No such file or directory
    ./build_android.sh: line 57: /home/sakthi/Desktop/android/android-ndk-r5b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-ld: No such file or directory

    Please help me.

  33. hi, I want to use ffmpeg in android.. and i have windows os.. i cant run these sudo command… can you provide me command for windows??

  34. i am developing an app that requires video broadcasting from android device to web browser. I am using window 7 and tried to build ffmpegg for android. any suggestions

    1. ffmpeg library support RTP, you can see if it fit your needs. For building on Windows 7, I never tried before.

  35. Can you modify this to worl with the ndk-r8b please ? Or just give us any hint on how to do it.

    Thanks in advance

  36. Hi,

    I am using the ffmpeg library and want to use the ffmpeg encoder and decoder both to create a video from images.
    I have compiled the ffmpeg-8.0 and now want to use the encoder. However when i call try to fetch the h264 encoder through the following code :
    codec = avcodec_find_encoder(CODEC_ID_H264);

    I am not able toget the codec.

    I have changed my build_android.sh as follows
    –disable-shared
    –enable-static
    –extra-ldflags=”-Wl,-rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -nostdlib -lc -lm -ldl -llog”
    –disable-everything
    –enable-demuxer=mov
    –enable-demuxer=h264
    –disable-ffplay
    –enable-protocol=file
    –enable-avformat
    –enable-avcodec
    –enable-gpl
    –enable-encoder=h264
    –enable-decoder=rawvideo
    –enable-decoder=mjpeg
    –enable-decoder=h263
    –enable-decoder=mpeg4
    –enable-decoder=h264
    –enable-parser=h264
    –disable-network
    –enable-zlib
    –disable-avfilter
    –disable-avdevice

    Please help,
    Thanks in advance

  37. I tried your build_android.sh file and i change 2 path one is NDK and below of that.. but it show me this error

    ./build_android.sh./build_android.sh: line 1: {rtf1ansiansicpg1252cocoartf1038cocoasubrtf360: command not found./build_android.sh: line 2: syntax error near unexpected token `}’./build_android.sh: line 2: `{fonttblf0fmodernfcharset0 Courier;}’Swapnil-Adsure:ffmpeg-0.11.1 swapnil$

    I am On mac os
    please help me my ndk and ffmpeg i kept on desktop

  38. Hello roman10,

    Great tutorial sets, it has been useful. Thanks a lot for that.

    I am trying to include libx264 to ffmpeg build as well, however I am failing. I encountered the famous libx264 not found error when I enabled libx264. I built x264 seperately and obtained libx264.a static library, now I want to include it to ffmpeg build and enable libx264 in ffmpeg as well.

    How should I do it based on your script? Which flag I should change?

    Thanks in advance.

    1. I also would like to add something as well. I have followed your tutorial and obtained libffmpeg.so with a size around 6mb.

      I have tried the same script(the one you put for 5b) with a newer version of ffmpeg and NDK 7b, managed to obtain libffmpeg.so with a size around 3mb.

      Does this indicate a problem? I can see includes and libs are OK, pretty much everything is there but shared library’s size is a bit confusing. Any ideas?

  39. Please update the post for the latest ffmpeg and ndk r8b. There are lots of ffmpeg for android alternatives but they dont work and they are not as good as your solution. Please help! i have no hairs left!

  40. Could you put the script for Android ndk r8b and the last version of ffmpeg i have tried to compile it in my Ubuntu 12.04 Lts and i only have errors and i dont know how to solve them, thanks

  41. Great tutorials! Note that you need a path without space to be able to build using this method.
    Also for the ones needing the NDK-6:
    dl.google.com/android/ndk/android-ndk-r6b-linux-x86.tar.bz2

  42. I modified the script and ran and got runtime errors.

    NDK: /opt/android-ndk-r8b
    PREBUILT: arm-linux-androideabi-4.6
    PLATOFORM: android-14

    I Succeeded in compilation and got a binary file “ffprobe”. Executing this binary file always throws the following error..
    # ./ffprobe
    [1] + Stopped (signal) ./ffprobe
    Once again running
    # ./ffprobe
    [2] + Stopped (signal) ./ffprobe
    [1] Segmentation fault ./ffprobe

    Can u please help?

  43. Thanks for the good tutorail.
    But i have a problem when run ./build_android.sh

    i change only my ndk path and run cmd in terminal
    sudo chmod 755 build_android.sh
    ./build_android.sh

    error log
    sed: 1: “config.h”: command c expects followed by text
    sed: 1: “config.h”: command c expects followed by text
    sed: 1: “config.h”: command c expects followed by text
    sed: 1: “config.h”: command c expects followed by text
    sed: 1: “config.h”: command c expects followed by text
    sed: 1: “config.h”: command c expects followed by text
    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

    plz suggest me.

  44. Hi guys,
    I’m working on FFMPEG on Android and we have problems.
    1. I’m able to compile it with h264 support and it works fine.
    2. I’m are able to encode video or still frame with the ffmpeg.
    3. I’m able to merge few videos into one. But I have problem here with the native recorder’s videos.
    Simply I’m not able to encode with the same parameters as it’s done by Android device.
    The number of options is really huge and I don’t know how to use it.
    When I try to merge frames from Android and ffpmeg encoded video it’s crashing or just showing half of the video.

    Simply the biggest problem is to read encoding parameters from the native video (recorded with the build in camera), and then use it in the FFMPEG to encode compatible video – with exact parameters
    We would really appreciate help.
    I’m attaching screenshots with te parameters of Android and our FFMPEG settings.

  45. Hello everyone ,
    while trying to build this application using android ndk8 i am facing the following issues. please advice me to come out of this issues.

    $ /cygdrive/d/Android_NDK/android-ndk-r8-windows/android-ndk-r8/ndk-build
    Prebuilt : libffmpeg.so libs/armeabi-v7a/libffmpeg.so
    install: cannot open `./obj/local/armeabi-v7a/libffmpeg.so’ for reading: Permission denied
    /cygdrive/d/Android_NDK/android-ndk-r8-windows/android-ndk-r8/build/core/build-binary.mk:409: recipe for target `libs/armeabi-v7a/libffmpeg.so’ failed
    make: *** [libs/armeabi-v7a/libffmpeg.so] Error 1

  46. I am getting an error “undefined reference to atexit”
    NDK- Latest r8e
    ffmpeg-love version

    Error is as follows
    —————————————————

    ffmpeg.c:474: error: undefined reference to ‘atexit’
    collect2: error: ld returned 1 exit status
    make: *** [ffmpeg_g] Error 1
    make: *** Waiting for unfinished jobs….
    STRIP ffprobe
    /home/android-ndk-r8e/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld: ,noexecstack: unknown -z option
    /home/android-ndk-r8e/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld: use the –help option for usage information

    Can somebody help ?

      1. I am having the same issue, I have added -static-libc++ to –extra-ldflags but it did not help. It is still giving the same error.

  47. i am using android ndk r8e and when i run the script i get this error
    “/home/talha/Downloads/android-ndk-r8e//toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86//bin/arm-linux-androideabi-ar: creating libavcodec/libavcodec.a
    /home/talha/Downloads/android-ndk-r8e//toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86//bin/arm-linux-androideabi-ld: cannot open output file ./android/armv7-a/libffmpeg.so: No such file or directory”
    Do i need to change the script for this ndk or there is some other problem?

  48. Hi, I tried your build_android.sh script it generally don’t create anything in the folder called android-armv7-a and when i checked in the usr/local/ there were four folder which of them are not containing the libffmpeg.so file which is very important i think..

  49. Thank you for your great articles and demo projects. I got this to build on windows 7 64 with your project from how-to-build-android-applications-based-on-ffmpeg-by-an-example using eclipse, NDK r9 and MinGW/MSYS (no cygwin) with the following changes to build_android.sh:

    NDK=/c/SDK/android_ndk_r9
    PLATFORM=$NDK/platforms/android-14/arch-arm/
    PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64

    and further down in the ld (linker) call (line 65):
    – change: -z,noexeckstack to: -z noexecstack
    – change dynamic linker to correct version (in my case 4.8. see above):
    –dynamic-linker=/system/bin/linker $PREBUILT/lib/gcc/arm-linux-androideabi/4.8/libgcc.a
    and remove –warn-once (seems to be unsupported since 4.4.3)

    libffmpeg.so is created in the correct directory.
    Then I just added the NDKBuild to Project->Properties->Builders:
    – New -> Program -> select ndk-build.cmd (from windows NDK)
    – workspace: ${workspace_loc:/FFmpegTest}

    Works fine, thanks again!

  50. Hi,I am getting an error ,
    NDK- r8c
    ffmpeg-2.0
    Error is as follows:
    ~/android/android_tools/android-ndk-r8c/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-ld: libavcodec/libavcodec.a(012v.o): Relocations in generic ELF (EM: 3)libavcodec/libavcodec.a(012v.o): could not read symbols: File in wrong format,
    Can somebody help me?

  51. Thanks for this tutorial but can you send me full source code for eclipse by which i can import and run in eclipse, because of i am not found any sample on net, and am new to FFmpeg. So please help.

  52. hi,
    I want to convert wav file to m4a using ffmpeg for android
    please help in creating a module.

    Please share sample applicatio if any one have

  53. Hi i’m getting below mentioned error while running the app

    10-25 13:50:57.358: E/AndroidRuntime(25527): Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: link_image[1891]: 1402 could not load needed library ‘libavformat-55.so’ for ‘libtutorial03.so’ (load_library[1093]: Library ‘libavformat-55.so’ not found)

  54. getting this type of error how to resolve-
    Android/android-ndk-r9c/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

  55. Hey

    i want to create a square video.
    can you suggest something.

    is there is any way to achieve this like we cropping bitmap files.

  56. SOS ,I’m build in win8 + cygwin + ffmpeg2.2

    always error:
    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’。 停止。
    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’。 停止。
    C:developandroid-ndk-r9d-windows-x86_64android-ndk-r9dtoolchainsarm-linux-androideabi-4.6prebuiltwindows-x86_64binarm-linux-androideabi-ld.exe: ,noexecstack: unknown -z option
    C:developandroid-ndk-r9d-windows-x86_64android-ndk-r9dtoolchainsarm-linux-androideabi-4.6prebuiltwindows-x86_64binarm-linux-androideabi-ld.exe: use the –help option for usage information

  57. Hi, you really do a good job, I built ffmpeg successfully under your description.

    Although there is something worth mention. The ld command in your build_android.sh has an extra comma after the -z option, which should be replaced by a space. My environment is android NDK r10, which has no androideabi-4.4.3, I used 4.6 instead, and –warn-once is not a valid option to ld command. Hope that help others.

    Thanks again.

    Regards.

  58. I am getting this error.

    check_cpp_condition newlib.h defined _NEWLIB_VERSION
    check_cpp
    BEGIN /tmp/ffconf.dkWUWsGo.c
    1 #include
    2 #if !(defined _NEWLIB_VERSION)
    3 #error “unsatisfied condition: defined _NEWLIB_VERSION”
    4 #endif
    END /tmp/ffconf.dkWUWsGo.c
    D:/android-ndk-r10b/toolchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm-linux-androideabi-gcc –sysroot=D:/android-ndk-r10b/platforms/android-8/arch-arm/ -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -O3 -fpic -DANDROID -DHAVE_SYS_UIO_H=1 -Dipv6mr_interface=ipv6mr_ifindex -fasm -Wno-psabi -fno-short-enums -fno-strict-aliasing -finline-limit=300 -mfloat-abi=softfp -mfpu=vfpv3-d16 -marm -march=armv7-a -march=armv7-a -std=c99 -E -o /tmp/ffconf.BMIcTDua.o /tmp/ffconf.dkWUWsGo.c
    C:/Users/vmewada/AppData/Local/Temp/ffconf.dkWUWsGo.c:1:20: fatal error: newlib.h: No such file or directory
    #include

Leave a Reply

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