Reputation: 43
Everyone.
Please understand that i use the wrong english.
I want to make encoding application using FFmpeg.
I was successfully building NDK with FFmpeg.
However, to encode H.264 video made had failed( Codec not found.. ).
I was learned that libx264 is need encode H.264 and libfdk-aac is need encode AAC.
so I tried to build the libx264 and libfdk-aac, But does not easily cross-compile.
Please tell me what I did wrong.
My Development Environment
OS : ubuntu 13.10 64bit
NDK : android-ndk-r9
FFmpeg : ffmpeg-2.0.2
x264 build : build_x264_android.sh
NDK=$ANDROID_NDK_HOME
TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64
PLATFORM=$NDK/platforms/android-9/arch-arm
CPU=arm
PREFIX=$NDK/sources/ffmpeg-2.0.2/android/$CPU
./configure --prefix=$PREFIX \
--enable-shared \
--enable-pic \
--disable-asm \
--disable-cli \
--host=arm-linux \
--cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- \
--sysroot=$PLATFORM
make
make install
ldconfig
fdk-aac build : build_aac_android.sh
NDK=$ANDROID_NDK_HOME
CROSS_PREFIX=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-
PLATFORM=$NDK/platforms/android-9/arch-arm
CPU=arm
PREFIX=$NDK/sources/ffmpeg-2.0.2/android/$CPU
OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=vfpv3-d16 -marm -march=armv7-a -mthumb -D__thumb__"
./configure --prefix=$PREFIX \
--with-sysroot=$PLATFORM \
--host=arm-linux \
--enable-shared \
--with-pic=no \
CC="${CROSS_PREFIX}gcc --sysroot=$PLATFORM" \
CXX="${CROSS_PREFIX}g++ --sysroot=$PLATFORM" \
RANLIB="${CROSS_PREFIX}ranlib" \
AR="${CROSS_PREFIX}ar" \
STRIP="${CROSS_PREFIX}strip" \
NM="${CROSS_PREFIX}nm" \
CFLAGS="-O3 $OPTIMIZE_CFLAGS --sysroot=$PLATFORM" \
CXXFLAGS="-O3 $OPTIMIZE_CFLAGS --sysroot=$PLATFORM"
make
make install
When I run 'build_aac_android.sh', shown error.
log in config.log
configure:2907: checking for arm-linux-gcc
configure:2934: result: /toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc --sysroot=/platforms/android-9/arch-arm
configure:3203: checking for C compiler version
configure:3212: /toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc --sysroot=/platforms/android-9/arch-arm --version >&5
./configure: line 3214: /toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc: No such file or directory
configure:3223: $? = 127
configure:3212: /toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc --sysroot=/platforms/android-9/arch-arm -v >&5
./configure: line 3214: /toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc: No such file or directory
configure:3223: $? = 127
configure:3212: /toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc --sysroot=/platforms/android-9/arch-arm -V >&5
./configure: line 3214: /toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc: No such file or directory
configure:3223: $? = 127
configure:3212: /toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc --sysroot=/platforms/android-9/arch-arm -qversion >&5
./configure: line 3214: /toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc: No such file or directory
configure:3223: $? = 127
configure:3243: checking whether the C compiler works
configure:3265: /toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc --sysroot=/platforms/android-9/arch-arm -O3 -mfloat-abi=softfp -mfpu=vfpv3-d16 -marm -march=armv7-a -mthumb -D__thumb__ --sysroot=/platforms/android-9/arch-arm conftest.c >&5
./configure: line 3267: /toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc: No such file or directory
configure:3312: error: in `/home/nel/android-ndk-r9/sources/ffmpeg-2.0.2/libfdk-aac':
configure:3314: error: C compiler cannot create executables
See `config.log' for more details
I cannot understand that error!! I was confirmed that arm-linux-androideabi-gcc is found in the directory..
I want to borrow you wisdom. Please tell me how to 'ffmpeg+x264+fdk-aac' build for android.
Thanks.. :-)
Upvotes: 4
Views: 7903
Reputation: 1459
You can try/fork/clone my library. It already compiles x264 and libfdk-aac. You can use any version of gcc toolchains (like 4.9) and supports the newest android platform (21).
You can easily build ffmpeg (2.6 or newest version) from my repo running 2-3 scripts.
It is hard to explain how to compile both but you can checkout the build_android.sh script which compiles x264 and libfdk-aac for all architectures.
You can read the bash function build_aac
and build_x264
to see how it was cross compiled.
REPO: https://github.com/matthewn4444/VPlayer_lib
INSTRUCTIONS: https://github.com/matthewn4444/VPlayer_lib/wiki/Compiling-FFmpeg
Upvotes: 1
Reputation: 977
I know it is late. I have just come across this problem and I have found your question. I have solved this issue like below. I hope it may help some guys when they find your question through googling like me. This is how to compile fdk-aac for android. NDK version is 9d
Change ANDROID_ROOT and ANDROID_BIN accordingly
export ANDROID_ROOT=/path/to/android-ndk/platforms/android-9/arch-arm
export ANDROID_BIN=/path/to/android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin
export CFLAGS="-DANDROID -fPIC -ffunction-sections -funwind-tables -fstack-protector -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300"
export LDFLAGS="-Wl,--fix-cortex-a8"
export CC="arm-linux-androideabi-gcc --sysroot=$ANDROID_ROOT"
export CXX="arm-linux-androideabi-g++ --sysroot=$ANDROID_ROOT"
export PATH=$ANDROID_BIN:$PATH
./configure --host=arm-linux-androideabi --with-sysroot="$ANDROID_ROOT" --enable-static --prefix="/tmp"
make -j4
make install
then library will be installed to /tmp directory. You can change it via --prefix above.
Upvotes: 1
Reputation: 6289
https://github.com/guardianproject/android-ffmpeg
above project for android includes x264. If you are good with git subprojects and if you are good with cross-toolchain NDK building , it should be easy to follow the builds.
If you are not then you will need to learn about building ffmpeg on linux ( no android ) . then learn NDK builds on android, then learn git subprojects , then build it.
Upvotes: 0