6

did someone successfully compile

ffmpeg-2.2.2 on windows with cygwin and android ndkr9c ?

Or can point me to an up to date tutorial ?

(http://www.roman10.net/how-to-build-ffmpeg-with-ndk-r9/ isn't working for me i get Makefile:2: config.mak: No such file... cygwin admin devel gnome is completely installed and make -v ok )

I need to convert a video to images(for live-wallpaper)... do you know a better method or is ffmpeg the best ?

thx

Hansjörg Hofer
  • 409
  • 1
  • 5
  • 18
  • Hello. Do you have some results? I mean build ffmpeg for android. – Volodymyr Kulyk Jun 17 '14 at 15:29
  • I did try https://github.com/guardianproject/android-ffmpeg https://github.com/wseemann/FFmpegMediaPlayer https://github.com/roman10 https://code.google.com/p/android-fplayer/source/checkout https://github.com/appunite/AndroidFFmpeg – Hansjörg Hofer Jun 18 '14 at 19:55
  • 1
    Now is start a bounty to compile ffmpeg with audio video codec for android :) – Hansjörg Hofer Jun 18 '14 at 19:57
  • I have done this! But under Ubuntu (Linux). – Volodymyr Kulyk Jun 20 '14 at 12:11
  • @VladimirKulyik: you're right, my favorite answer to the question _[how to build ffmpeg under Windows?](http://stackoverflow.com/questions/23683518/how-to-compile-ffmpeg-2-2-2-on-windows-with-cygwin-and-android-ndk-r9c)_ begins with words _[format your C: drive to ext4](http://askubuntu.com/questions/331353/how-to-replace-windows-with-ubuntu)._ This topic here is an exercise in cygwin trickery, irrelevant to 99.99% of SW developers. – Alex Cohn Jun 20 '14 at 14:16

3 Answers3

9

Start with Roman's tutorial. Following changes apply to Windows: you should use the NDK make.exe, not the one from cygwin. So, I simply wrote d:/dev/Android/ndk/prebuilt/windows-x86_64/bin/make.exe in my build_android.sh. For some weird reason, I could not run make clean - but I simply chose to ignore this problem for now.

Following the tutorial, don't forget to set

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

Also, use mixed-style paths, i.e. d:/dev/whatever and not cygwin style /cygdrive/d/dev/whatever. Be careful not to use paths with spaces - neither for ndk installation, nor for ffmpeg git clone.

With ffmpeg 2.2, you can use --target-os=android for ./configure, instead of mangling ./configure file as described in step 2.

On my machine, I did not have pr and od commands. I chose simply to fake them, writing

echo 'cat $3' > ./pr
echo 'echo od' > ./od

These do not spoil the build.

So, my build process is as follows:

git clean -d -f -x
./configure --enable-shared --disable-static --disable-doc --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --disable-avdevice --disable-doc --disable-symver --cross-prefix=d:/android-ndk-r9c/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/arm-linux-androideabi- --target-os=android --arch=arm --enable-cross-compile --sysroot=d:/android-ndk-r9c/platforms/android-9/arch-arm/ --extra-cflags="-Os -fpic"

Compilation does display some warnings, but the .so files are all produced.

To enable NEON, I used

--extra-cflags="-Os -fpic -marm -march=armv7-a -mfloat-abi=softfp -mfpu=neon"
--extra-ldflags="-Wl,--fix-cortex-a8"

Now, libavcodec.so could not be built anymore: too many files on the linker list. So, after it crashed, I launched the linker manually:

$ d:/Dev/Android/ndk/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64//bin/arm-linux-androideabi-gcc  -shared -Wl,-Bsymbolic -Wl,--version-script,libavcodec/libavcodec.ver -Llibavcodec -Llibavdevice -Llibavfilter -Llibavformat -Llibavresample -Llibavutil -Llibpostproc -Llibswscale -Llibswresample -Wl,--fix-cortex-a8  --sysroot=d:/Dev/Android/ndk/platforms/android-9/arch-arm/ -isysroot d:/Dev/Android/ndk/platforms/android-9/arch-arm/ -Wl,--as-needed -Wl,--warn-common -Wl,-rpath-link=libpostproc:libswresample:libswscale:libavfilter:libavdevice:libavformat:libavcodec:libavutil:libavresample @libavcodec/libavcodec.list -lswresample -lavutil -lm -lz -pthread -o libavcodec/libavcodec.so.55

I patch the library.mak file as follows: for $(SUBDIR)$(SLIBNAME_WITH_MAJOR), replace

$$(LD) $(SHFLAGS) $(LDFLAGS) $$(LD_O) $$(filter %.o,$$^) $(FFEXTRALIBS)

with

$(Q)echo >$(SUBDIR)lib$(NAME).list $(wordlist 1,400,$(filter %.o,$$<))
$(Q)echo >>$(SUBDIR)lib$(NAME).list $(wordlist 401,999,$(filter %.o,$$<))
$$(LD) $(SHFLAGS) $(LDFLAGS) $$(LD_O) @$(SUBDIR)lib$(NAME).list $(FFEXTRALIBS)

.. and from there, make proceeded smoothly.

PS: I used make -n libavcodec/libavcodec.so.55 to prepare the response file libavcodec/libavcodec.list.

PPS: Here is another article that helps to build and use ffmpeg for Android.

Alex Cohn
  • 56,089
  • 9
  • 113
  • 307
  • If it's not complicated for you. Can you post ready .sh file for windows?. And can I write C:/ndk/... instead of $NDK/... ? Ty for this answer. – Volodymyr Kulyk Jun 19 '14 at 20:31
  • @VladimirKulyik: `C:/ndk` is fine. Regarding `.sh` file, it won't be today, unfortunately. – Alex Cohn Jun 20 '14 at 04:22
  • 1
    Hi i made all like you did and i get ./build_android.sh d:/android-ndk-r9c/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. 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 make: *** No rule to make target `/tests/Makefile'. Stop. – Hansjörg Hofer Jun 21 '14 at 13:54
  • did try it on ubuntu and same error .. can you help me please on skype elec_29a ? – Hansjörg Hofer Jun 21 '14 at 15:42
  • I used roman10 tutorial On Ubuntu. Copy ffmpeg to ndk/sources. You should create .sh file on Linux , do not copy this file created on Windows. If you are using Ubuntux32: for TOOLCHAIN set linux-x86, else keep linux-x86_64. And before using .sh you should run: ./configure .And do not forget to give root accses for configure and .sh: sudo chmod 777 build_android.sh – Volodymyr Kulyk Jun 21 '14 at 16:22
  • Alex Cohn can you help me to solve this problem: http://stackoverflow.com/questions/24330365/build-sdl-mixer-for-android – Volodymyr Kulyk Jun 21 '14 at 16:38
  • After the `./configure` failed (_unable to create an executable file_), the **make** files are not prepared, that's why you see all these errors with `Makefile`. – Alex Cohn Jun 21 '14 at 18:49
  • 'Alex Cohn' one more question. I have RunTimeError: could not load needed library 'libswresample.so' for 'libavcodec-55.so'. But I have loaded libswresample-0.so. So what is the problem? – Volodymyr Kulyk Jun 25 '14 at 09:51
  • @VladimirKulyik: did you use `--target-os=android`? Or you manually edited `./configure`? Or *both*? – Alex Cohn Jun 25 '14 at 09:58
  • I did finally install Ubuntu and MacOsx in Vmware and is compiling fine there... cygwin is a pain :( – Hansjörg Hofer Jun 25 '14 at 20:59
  • c:/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/windows/bin/arm-linux-androideabi-gcc is unable to create an executable file. C compiler test failed.@AlexCohn – Sohail Zahid Sep 28 '15 at 13:48
  • @SohailZahid most likely, `--enable-cross-compile` did not have effect – Alex Cohn Sep 28 '15 at 15:37
  • 1
    Regarding library.mak patch... There is missing ) at the end of the line $(Q)echo >>$(SUBDIR)lib$(NAME).list $(wordlist 401,999,$(filter %.o,$$<) – Petr M Jul 12 '16 at 21:05
2

You can use this as build_android.sh i tested it and it worked with me

#!/bin/bash
NDK=D:/android/ndk/android-ndk-r10d
SYSROOT=$NDK/platforms/android-8/arch-arm/
TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/windows
function build_one
{
./configure \
--prefix=$PREFIX \
--disable-shared \
--enable-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

you need also to run this commands :

dos2unix build_android.sh
chmod +x build_android.sh
./build_android.sh

Use this Tutorial as reference

Mycoola
  • 1,135
  • 1
  • 8
  • 29
  • dos2unix and chmod exes are in C:\Program Files\Git\usr\bin directory, how to use them inside ffmpeg folder ? I hate these cmd things... – ACAkgul Apr 26 '17 at 00:41
1

Build it on Ubuntu(Guest) and copy lib's(sub folder in /andoid-ndk/sources/ffmpeg/android) folder to Windows(Host).I tried it for Window but ended with lot of bugs, finally installed Ubuntu (Free) on virtualbox. also you willl have to download Andoid (SDK, Ndk) and JDK. This may sound weird but it worked for me.

amit
  • 11
  • 1