ffmpeg x264 building error

2,384 views
Skip to first unread message

mkerim

unread,
Aug 20, 2012, 2:17:59 PM8/20/12
to andro...@googlegroups.com
Helloe everyone,

I have successfully ported ffmpeg to Android using roman10's tutorial. I have managed to obtain the .so files both for tutorial-specific versions of ffmpeg/ndk (ndk 5rb, ffmpeg-love) and ndk7rb/ ffmpeg 0.10.4 releases.

However, whenever I try to initiate building with libx264 enabled, I obtain the error saying libx264 not found. I have also enabled gpl.

I have seen some forum posts posted by people facing similar problems but I failed to obtain a clear insight about the solution.

Script I am using is as follows:

#!/bin/bash
NDK=~/Android_NDK_r7b
PLATFORM=$NDK/platforms/android-8/arch-arm/
PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86
function build_one
{
./configure --target-os=linux \
--prefix=$PREFIX \
--enable-cross-compile \
--extra-libs="-lgcc" \
--arch=arm \
--cc=$PREBUILT/bin/arm-linux-androideabi-gcc \
--cross-prefix=$PREBUILT/bin/arm-linux-androideabi- \
--nm=$PREBUILT/bin/arm-linux-androideabi-nm \
--sysroot=$PLATFORM \
--extra-cflags=" -O3 -fpic -DANDROID -DHAVE_SYS_UIO_H=1 -Dipv6mr_interface=ipv6mr_ifindex -fasm -Wno-psabi -fno-short-enums -fno-strict-aliasing -finline-limit=300 $OPTIMIZE_CFLAGS " \
--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-gpl \
--enable-libx264 \

--enable-avformat \
--enable-avcodec \
--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 \
$ADDITIONAL_CONFIGURE_FLAG

make clean
make -j4 install
$PREBUILT/bin/arm-linux-androideabi-ar d libavcodec/libavcodec.a inverse.o
$PREBUILT/bin/arm-linux-androideabi-ld -rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -soname libffmpeg.so -shared -nostdlib -z,noexecstack -Bsymbolic --whole-archive --no-undefined -o $PREFIX/libffmpeg.so libavcodec/libavcodec.a libavformat/libavformat.a libavutil/libavutil.a libswscale/libswscale.a -lc -lm -lz -ldl -llog --warn-once --dynamic-linker=/system/bin/linker $PREBUILT/lib/gcc/arm-linux-androideabi/4.4.3/libgcc.a
}


#arm v7vfpv3
CPU=armv7-a
OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=vfpv3-d16 -marm -march=$CPU "
PREFIX=./android2/$CPU
ADDITIONAL_CONFIGURE_FLAG=
build_one


As people who used roman10's script can tell, I have just added two lines to enable x264 library, but failed to build it with this configuration. 

Any help will be appreciated. Thanks a lot.

mkerim

unread,
Aug 21, 2012, 11:16:48 AM8/21/12
to andro...@googlegroups.com
Following a brief online research, I think I have to compile libx264 seperately and then link it to ffmpeg and produce a single .so file for ffmpeg. 

I am now lacking the script to actually build libx264 (cloned the last version). 

Any help will be most welcome. Thanks.

mkerim

unread,
Aug 22, 2012, 8:21:58 AM8/22/12
to andro...@googlegroups.com
Well, here I am with another update.

I have found some scripts online to build x264, but regardless of the script I am using I am getting "NO working C compiler found" error.
I have used  http://demo860.blogspot.co.uk/2010/06/ffmpeg-libx264-build-for-android.html  and  http://bongjaemoon.wordpress.com/2012/05/25/ffmpeg-x264-compile-for-using-with-android-ndk-on-mac-osx/  for building purposes. I have updated and installed build-essentials and made sure they are up to date by checking their version. However, these scripts can't find a compiler. Any help will be appreciated.

Thanks in advance.

Alexander Volkov

unread,
Sep 18, 2013, 6:17:10 AM9/18/13
to andro...@googlegroups.com, mkeri...@gmail.com
"NO working C compiler found" is because you have used wrong path to the toolchain, e.g. /usr/local/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64
Check correct path as:
$ ls -l /usr/local/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/
it maybe darwin-x86_64, linux-x86 or similar.

In relation to the problem, I think that then we use ndk to compile ffmpeg for android it searches libs somewhere alse, not in standard path like /usr/local/bin.
I think we need to put compiled x264 library in ndk lib path. Actually I can't find the place. 

среда, 22 августа 2012 г., 16:21:58 UTC+4 пользователь mkerim написал:

Alexander Volkov

unread,
Sep 18, 2013, 5:48:48 PM9/18/13
to andro...@googlegroups.com, mkeri...@gmail.com
I have used next scripts. This creates static ffmpeg:
1. Download ndk, ffmpeg and x264 sources.
2. Put them in /usr/local/android-ndk-r9, /usr/local/android-ndk-r9/sources/ffmpeg and /usr/src/x264 correspondently.
3. Run:
cd /usr/src/x264
./configure --host=arm-linux --cross-prefix=arm-linux-androideabi- --prefix=/usr/local/android-ndk-r9/platforms/android-18/arch-arm/usr/
make
sudo make install

cd /usr/local/android-ndk-r9/sources/ffmpeg

CPU=arm
PREFIX=$(pwd)/android/$CPU
ADDI_CFLAGS="-marm" 
NDK=/usr/local/android-ndk-r9
SYSROOT=$NDK/platforms/android-14/arch-arm/
TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64

./configure \
    --prefix=$PREFIX \
    --disable-shared \
    --enable-static \
    --disable-doc \
    --enable-ffmpeg \
    --enable-gpl \
    --enable-libx264 \
    --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

You will have ffmpeg in /usr/local/android-ndk-r9/sources/ffmpeg/android/bin directory.

среда, 22 августа 2012 г., 16:21:58 UTC+4 пользователь mkerim написал:
Well, here I am with another update.
Reply all
Reply to author
Forward
0 new messages