2012年8月18日土曜日

Android NDK で ffmpeg ライブラリをビルド

とりあえず、手順だけメモ。
色々納得できないので、要継続調査。

  • NEON 有効
  • スタティックライブラリ生成
  • ダイナミックライブラリ生成
  • x264 ライブラリを利用

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

commit 7e49474aa02e93ba2d80b330cba1ec38f4c4f3ee
Date:   Sat Aug 18 05:02:58 2012 +0200

configure を修正

$ git diff configure
diff --git a/configure b/configure
index 679fae0..1591f4f 100755
--- a/configure
+++ b/configure
@@ -1949,7 +1949,7 @@ cc_default="gcc"
 cxx_default="g++"
 host_cc_default="gcc"
 install="install"
-ln_s="ln -sf"
+ln_s="cp -f"
 nm_default="nm"
 objformat="elf"
 pkg_config_default=pkg-config
@@ -3956,7 +3956,7 @@ YASM=$yasmexe
 DEPYASM=$yasmexe
 AR=$ar
 RANLIB=$ranlib
-CP=cp -p
+CP=cp -fp
 LN_S=$ln_s
 STRIP=$strip
 CPPFLAGS=$CPPFLAGS

configure 実行

TEMPDIR=`cygpath -m /tmp` \
./configure \
--sysroot=`cygpath -m $SYSROOT` \
--cross-prefix=arm-linux-androideabi- \
--enable-cross-compile \
--target-os=linux \
--arch=arm \
--cpu=cortex-a8 \
--extra-cflags='-I../x264 -mfloat-abi=softfp -mfpu=neon' \
--extra-ldflags='-L../x264 -Wl,--fix-cortex-a8' \
--enable-libx264 \
--enable-shared \
--disable-stripping \
--enable-gpl \
--enable-version3 \
--disable-doc \
--disable-htmlpages \
--disable-manpages \
--disable-podpages \
--disable-txtpages \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--disable-avdevice \
--disable-network \
--disable-devices \
--disable-protocols \
--enable-protocol=file

config.h を修正

#define CC_IDENT "gcc 4.4.3^M (GCC)"
↓
#define CC_IDENT "gcc 4.4.3 (GCC)"

config.mak を修正

CC_IDENT=gcc 4.4.3^M (GCC)
↓
CC_IDENT=gcc 4.4.3 (GCC)

ビルド実行

make -j4
「-j4」は、並列ビルドオプション。

インストール

install -m 644 libavfilter/libavfilter.a "/usr/local/lib"
install -m 755 libavfilter/libavfilter.so "/usr/local/lib/libavfilter.so.3.10.100"

install -m 644 libavformat/libavformat.a "/usr/local/lib"
install -m 755 libavformat/libavformat.so "/usr/local/lib/libavformat.so.54.25.100"

install -m 644 libavcodec/libavcodec.a "/usr/local/lib"
install -m 755 libavcodec/libavcodec.so "/usr/local/lib/libavcodec.so.54.53.100"

install -m 644 libpostproc/libpostproc.a "/usr/local/lib"
install -m 755 libpostproc/libpostproc.so "/usr/local/lib/libpostproc.so.52.0.100"

install -m 644 libswresample/libswresample.a "/usr/local/lib"
install -m 755 libswresample/libswresample.so "/usr/local/lib/libswresample.so.0.15.100"

install -m 644 libswscale/libswscale.a "/usr/local/lib"
install -m 755 libswscale/libswscale.so "/usr/local/lib/libswscale.so.2.1.101"

install -m 644 libavutil/libavutil.a "/usr/local/lib"
install -m 755 libavutil/libavutil.so "/usr/local/lib/libavutil.so.51.70.100"

install -m 644 libavfilter/asrc_abuffer.h libavfilter/avcodec.h libavfilter/avfilter.h libavfilter/avfiltergraph.h libavfilter/buffersink.h libavfilter/buffersrc.h libavfilter/version.h "/usr/local/include/libavfilter"
install -m 644 libavfilter/libavfilter.pc "/usr/local/lib/pkgconfig"

install -m 644 libavformat/avformat.h libavformat/avio.h libavformat/version.h "/usr/local/include/libavformat"
install -m 644 libavformat/libavformat.pc "/usr/local/lib/pkgconfig"

install -m 644 libavcodec/avcodec.h libavcodec/avfft.h libavcodec/dxva2.h libavcodec/old_codec_ids.h libavcodec/vaapi.h libavcodec/vda.h libavcodec/vdpau.h libavcodec/version.h libavcodec/xvmc.h "/usr/local/include/libavcodec"
install -m 644 libavcodec/libavcodec.pc "/usr/local/lib/pkgconfig"

install -m 644 libpostproc/postprocess.h "/usr/local/include/libpostproc"
install -m 644 libpostproc/libpostproc.pc "/usr/local/lib/pkgconfig"

install -m 644 libswresample/swresample.h "/usr/local/include/libswresample"
install -m 644 libswresample/libswresample.pc "/usr/local/lib/pkgconfig"

install -m 644 libswscale/swscale.h libswscale/version.h "/usr/local/include/libswscale"
install -m 644 libswscale/libswscale.pc "/usr/local/lib/pkgconfig"

install -m 644 libavutil/adler32.h libavutil/aes.h libavutil/attributes.h libavutil/audio_fifo.h libavutil/audioconvert.h libavutil/avassert.h libavutil/avstring.h libavutil/avutil.h libavutil/base64.h libavutil/blowfish.h libavutil/bprint.h libavutil/bswap.h libavutil/common.h libavutil/cpu.h libavutil/crc.h libavutil/error.h libavutil/eval.h libavutil/fifo.h libavutil/file.h libavutil/imgutils.h libavutil/intfloat.h libavutil/intfloat_readwrite.h libavutil/intreadwrite.h libavutil/lfg.h libavutil/log.h libavutil/lzo.h libavutil/mathematics.h libavutil/md5.h libavutil/mem.h libavutil/dict.h libavutil/opt.h libavutil/parseutils.h libavutil/pixdesc.h libavutil/pixfmt.h libavutil/random_seed.h libavutil/rational.h libavutil/samplefmt.h libavutil/sha.h libavutil/time.h libavutil/timecode.h libavutil/timestamp.h libavutil/version.h libavutil/xtea.h libavutil/avconfig.h "/usr/local/include/libavutil"
install -m 644 libavutil/libavutil.pc "/usr/local/lib/pkgconfig"