FFMpeg & x264 compile for using with Android NDK on Mac OSX

来源:互联网 发布:linux 在线安装ant 编辑:程序博客网 时间:2024/05/17 00:57
1. Toolchain for compile (This NDK version is r8)
a. Android’s NDK allows we to create toolchain installation using “make-standalone-toolchain.sh” script.
b. Execute like below.
$> /home/bywyu/android/android-ndk-r8b/build/tools/make-standalone-toolchain.sh –platform=android-14 –install-dir=/home/bywyu/work/video/lib/x264/build/new-android-toolchain
c. You can use directly with PATH, CC setting.
export PATH=/home/bywyu/work/video/lib/x264/build/arm-linux-androideabi-4.6/bin:$PATH
export CC=arm-linux-androideabi-gcc
d. Done

2. Compile & Build x264 project for FFMpeg library.
a. Download x264 project (http://www.videolan.org/developers/x264.html)
b. Configuration for arm compile. (prefix option is very important for FFMpeg compiling.)
$> ./configure –host=arm-linux \
–cross-prefix=arm-linux-androideabi- \
–enable-shared \
–enable-static \
–prefix=/home/bywyu/work/video/lib/x264/build/arm-linux-androideabi-4.6/sysroot/usr
c. make / install
$> make
$> make install
d. Done. You can find the library & include files in –prefix option’s directory.

3. Compile & Build FFMpeg project.
a. Download FFMpeg source code from http://ffmpeg.org/download.html (This case is FFmpeg 0.10.3 “Freedom” version)
b. Configuration for arm compile.
$> ./configure –enable-shared \
–enable-libx264 \
–cross-prefix=arm-linux-androideabi- \
–enable-cross-compile \
–target-os=linux \
–arch=arm \
–enable-gpl \
–prefix=/work/my-android-toolchain/sysroot/usr
c. Configuration for detailed module selection.
$> ./configure –prefix=../ffmpeg_build \
–enable-gpl \
–enable-shared \
–disable-doc \
–disable-ffmpeg \
–disable-ffplay \
–disable-ffprobe \
–disable-ffserver \
–disable-avdevice \
–disable-debug \
–disable-network \
–disable-protocols \
–disable-devices \
–disable-encoders \
–disable-decoders \
–disable-muxers \
–disable-demuxers \
–disable-parsers \
–disable-bsfs \
–disable-filters \
–enable-encoder=h264 \
–enable-libx264 \
–extra-cflags=-U__STRICT_ANSI__ \
–target-os=linux \
–extra-cflags=”-fno-short-enums” \
–extra-ldflags=”-mandroid -lm” \
–enable-cross-compile \
–cross-prefix=arm-linux-androideabi- \
–arch=arm
d. Make
$> make

e. Make install

$> make install

f. Done. You can see the library and header in ../ffmepg_build directory (in the prefix option)

http://bongjaemoon.wordpress.com/2012/05/25/ffmpeg-x264-compile-for-using-with-android-ndk-on-mac-osx/