How to Compile Ffmpeg-2.2.2 on Windows with Cygwin and Android Ndk R9C

How to compile ffmpeg-2.2.2 on windows with cygwin and android ndk r9c

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.

Can I compile ffmpeg using cygwin so that I would get redistributable dll's of it?

You seem a bit confused about the difference between MinGW and cygwin, but reading the following links will probably not be a waste of time:

  • http://www.cygwin.com/cygwin-ug-net/dll.html
  • http://www.emmestech.com/moron_guides/moron2.html
  • http://www.mingw.org/wiki/FAQ

Video editor for android - FFmpeg won't compile on windows?

Maybe you have already know that on Windows you must use Cygwin. This is open source tools which provide functionality similar to a Linux distribution on Windows.
I work with ndk in linux. It avoids many problems and errors which i can found in Windows.
Here link how to start work with Cygwin:
http://mindtherobot.com/blog/452/android-beginners-ndk-setup-step-by-step/

Compiling FFmpeg lib and add it to NDK sources on Windows8

Can you paste what's in your build_android.sh file which you've copied inside the FFmpeg directory?

I've got the same error when one of the variables defined at the start of the script where set incorrectly. Check to see if your NDK or SYSROOT or TOOLCHAIN variables are set to a valid path!

I've tried using the following steps and it worked for me:

1) Download FFmpeg

git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg

2) Create a file called build_android.sh inside the FFmpeg directory

cd ffmpeg; touch build_ffmpeg_for_android.sh;

3) Add the following content to the file

#!/usr/bin/env bash

NDK=$HOME/Software/Android/android-ndk-r10/
SYSROOT=$NDK/platforms/android-19/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 -j4
make install
}

CPU=arm
PREFIX=$(pwd)/android/$CPU
ADDI_CFLAGS="-marm"

build_one

4) Make the script executable

chmod +x build_ffmpeg_for_android.sh

5) Start the build of FFmpeg for Android (ARM)

(run the script with Bash, i.e. /usr/bin/bash not /usr/bin/sh)

./build_ffmpeg_for_android.sh

How to build and use ffmpeg libraries in Android project in Mac OS 10.9?

For building ffmpeg for Android see the following answer: Compiling FFmpeg lib and add it to NDK sources on Windows8

You can link to it in your project by adding what's written here in your Android.mk for each of the libraries you need from ffmpeg:

libavcodec.so
libavfilter.so
libavformat.so
libavutil.so
libswresample.so
libswscale.so

Also see this blog post: How to Build ffmpeg with NDK r9 which gives hands-on details on how to do it.



Related Topics



Leave a reply



Submit