1,編譯fdk-aac
wget -O fdk-aac.zip https://github.com/mstorsjo/fdk-aac/zipball/master
unzip fdk-aac.zip
cd mstorsjo-fdk-aac*
autoreconf -fiv
使用如下的配置文件
BUILD_PATH=/home/zangcf/ffmpeg/ffmpeg_arm/ffmpeg_build
CC_PATH=/opt/Android-ndk-toolchain/bin/arm-linux-androideabi-gcc
CPP_PATH=/opt/android-ndk-toolchain/bin/arm-linux-androideabi-cpp
./configure \
--prefix=$BUILD_PATH \
--build=arm \
CC=$CC_PATH \
CXX=/opt/android-ndk-toolchain/bin/arm-linux-androideabi-g++ \
--host=arm-linux \
--enable-static \
然後
Make
Make installl
2,編譯libx264
wget http://download.videolan.org/pub/x264/snapshots/last_x264.tar.bz2
tar xjvf last_x264.tar.bz2
cd x264-snapshot*
使用如下confiure
export ARM_ROOT=/home/zangcf/cross_compile/android-ndk-r9b
export ARM_INC=$ARM_ROOT/platforms/android-8/arch-arm/usr/include/
export ARM_LIB=$ARM_ROOT/platforms/android-8/arch-arm/usr/lib/
export ARM_TOOL=/home/zangcf/cross_compile/android-ndk-r9b/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64
export ARM_LIBO=/home/zangcf/cross_compile/android-ndk-r9b/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.8
export PATH=$ARM_TOOL/bin:$PATH
export ARM_PRE=arm-linux-androideabi
./configure --prefix=/home/zangcf/ffmpeg/ffmpeg_arm/ffmpeg_build \
--extra-cflags=" -I$ARM_INC -fPIC -DANDROID -fpic -mthumb-interwork -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -Wno-psabi -march=armv5te -mtune=xscale -msoft-float -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -DANDROID -Wa,--noexecstack -MMD -MP " \
--extra-ldflags=" -nostdlib -Bdynamic -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,nocopyreloc -Wl,-soname,/system/lib/libz.so -Wl,-rpath-link=$ARM_LIB,-dynamic-linker=/system/bin/linker -L$ARM_LIB -nostdlib $ARM_LIB/crtbegin_dynamic.o $ARM_LIB/crtend_android.o -lc -lm -ldl -lgcc " \
--cross-prefix=${ARM_PRE}- --disable-asm --host=arm-linux
make
make install
make distclean
2, 下載編譯libvpx
wget http://webm.googlecode.com/files/libvpx-v1.3.0.tar.bz2
tar xjvf libvpx-v1.3.0.tar.bz2
cd libvpx-v1.3.0
./configure --sdk-path=/home/zangcf/cross_compile/android-ndk-r9b --target=armv7-android-gcc \
--disable-runtime-cpu-detect \
--prefix=/home/zangcf/ffmpeg/ffmpeg_arm/ffmpeg_build
Make
Make install
3, libogg
下載最新版本libogg-1.3.1.tar.gz,注意老版本會有問題。
使用如下configure
#!/bin/sh
BUILD_PATH=/home/zangcf/ffmpeg/ffmpeg_arm/ffmpeg_build
CC_PATH=/opt/android-ndk-toolchain/bin/arm-linux-androideabi-gcc
CPP_PATH=/opt/android-ndk-toolchain/bin/arm-linux-androideabi-cpp
./configure \
--prefix=$BUILD_PATH \
--build=arm \
CC=$CC_PATH \
CPP=$CPP_PATH \
--host=arm-linux \
--enable-static \
Make
Make install
4,libvorbis
下載最新版本libvorbis-1.3.4.tar.gz,注意老版本可能會有問題
使用如下的configure
#!/bin/sh
BUILD_PATH=/home/zangcf/ffmpeg/ffmpeg_arm/ffmpeg_build
CC_PATH=/opt/android-ndk-toolchain/bin/arm-linux-androideabi-gcc
CPP_PATH=/opt/android-ndk-toolchain/bin/arm-linux-androideabi-cpp
./configure \
--prefix=$BUILD_PATH \
--build=arm \
CC=$CC_PATH \
CPP=$CPP_PATH \
--host=arm-linux \
--enable-static \
Make
Make install
5,解決NDK交叉編譯 selected processor does not support ARM mode libtheora的錯誤
下載最新的libtheora, wget http://downloads.xiph.org/releases/theora/libtheora-1.2.0alpha1.tar.gz
解壓縮,然後使用如下configure來編譯
#!/bin/sh
BUILD_PATH=/home/zangcf/ffmpeg/ffmpeg_arm/ffmpeg_build
CC_PATH=/opt/android-ndk-toolchain/bin/arm-linux-androideabi-gcc
CPP_PATH=/opt/android-ndk-toolchain/bin/arm-linux-androideabi-cpp
./configure \
--prefix=$BUILD_PATH \
--build=arm \
CC=$CC_PATH \
CPP=$CPP_PATH \
--host=arm-linux \
--enable-static \
--with-ogg=/home/zangcf/ffmpeg/ffmpeg_arm/ffmpeg_build \
AS=/opt/android-ndk-toolchain/bin/arm-linux-androideabi-as \
AR=/opt/android-ndk-toolchain/bin/arm-linux-androideabi-ar \
然後make,結果出現如下錯誤
selected processor does not support ARM mode
很多很多
通過對編譯文件的仔細研究,發現只要加一個
--disable-asm
配置選項,就可以完全解決這個問題
6,下載lame-3.99.5
解壓,然後使用如下配置文件配置
#!/bin/sh
BUILD_PATH=/home/zangcf/ffmpeg/ffmpeg_arm/ffmpeg_build
CC_PATH=/opt/android-ndk-toolchain/bin/arm-linux-androideabi-gcc
CPP_PATH=/opt/android-ndk-toolchain/bin/arm-linux-androideabi-cpp
./configure \
--prefix=$BUILD_PATH \
--build=arm \
CC=$CC_PATH \
CPP=$CPP_PATH \
--host=arm-linux \
--enable-static \
AS=/opt/android-ndk-toolchain/bin/arm-linux-androideabi-as \
AR=/opt/android-ndk-toolchain/bin/arm-linux-androideabi-ar \
然後
Make
Make install
---libass 和libopus
4, 下載編譯ffmpeg
wget http://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2
tar xjvf ffmpeg-snapshot.tar.bz2
cd ffmpeg
使用如下configure
export ARM_ROOT=/home/zangcf/cross_compile/android-ndk-r9b
export ARM_INC=$ARM_ROOT/platforms/android-8/arch-arm/usr/include/
export ARM_LIB=$ARM_ROOT/platforms/android-8/arch-arm/usr/lib/
export ARM_TOOL=/home/zangcf/cross_compile/android-ndk-r9b/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64
export ARM_LIBO=/home/zangcf/cross_compile/android-ndk-r9b/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.8
export PATH=$ARM_TOOL/bin:$PATH
export ARM_PRE=arm-linux-androideabi
export LIB_INC=/home/zangcf/ffmpeg/ffmpeg_arm/ffmpeg_build/include
export LIB_LIB=/home/zangcf/ffmpeg/ffmpeg_arm/ffmpeg_build/lib
./configure --target-os=linux \
--arch=armv5te \
--enable-cross-compile \
--cc=$ARM_TOOL/bin/${ARM_PRE}-gcc \
--cross-prefix=$ARM_TOOL/bin/${ARM_PRE}- \
--extra-cflags=" -fPIC -DANDROID -fpic -mthumb-interwork -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -Wno-psabi -march=armv5te -mtune=xscale -msoft-float -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -D
ANDROID -Wa,--noexecstack -MMD -MP " \
--enable-static \
--disable-shared --enable-libx264 --enable-gpl \
--disable-asm --disable-yasm \
--prefix=/home/zangcf/ffmpeg/ffmpeg_arm/ffmpeg_build \
--disable-amd3dnow --disable-amd3dnowext --disable-mmx --disable-sse --disable-ssse3 \
--extra-cflags="-I$ARM_INC -std=gnu99 -I$LIB_INC " \
--extra-libs="-lc -lm -ldl -lgcc -lz -lx264 " \
--extra-ldflags=" -L$LIB_LIB -Wl,-rpath-link=$LIB_LIB -nostdlib -Bdynamic -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,nocopyreloc -Wl,-soname,/system/lib/libz.so
-Wl,-rpath-link=$ARM_LIB,-dynamic-linker=/system/bin/linker -L$ARM_LIB -nostdlib $ARM_LIB/crtbegin_dynamic.o $ARM_LIB/crtend_android.o "
/////////////////////////////////////////////////////////////////////
執行configure的時候,怎麼都提示找不到h264,經過仔細分析研讀,分析configure文件,發現是x264的編譯選項有問題,少了一個--enable-static
加上這個選項,重新編譯x264,呵呵ffmpeg的配置編譯都通過了。
make
make install
make distclean
hash -r
最後確定的configure需要增加很多解碼工具,配置如下
export ARM_ROOT=/home/zangcf/cross_compile/android-ndk-r9b
export ARM_INC=$ARM_ROOT/platforms/android-8/arch-arm/usr/include/
export ARM_LIB=$ARM_ROOT/platforms/android-8/arch-arm/usr/lib/
export ARM_TOOL=/home/zangcf/cross_compile/android-ndk-r9b/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64
export ARM_LIBO=/home/zangcf/cross_compile/android-ndk-r9b/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.8
export PATH=$ARM_TOOL/bin:$PATH
export ARM_PRE=arm-linux-androideabi
export LIB_INC=/home/zangcf/ffmpeg/ffmpeg_arm/ffmpeg_build/include
export LIB_LIB=/home/zangcf/ffmpeg/ffmpeg_arm/ffmpeg_build/lib
PKG_CONFIG_PATH=/home/zangcf/ffmpeg/ffmpeg_arm/ffmpeg_build/lib/pkgconfig
./configure --target-os=linux \
--pkg-config=/home/zangcf/ffmpeg/ffmpeg_arm/ffmpeg_build/lib/pkgconfig \
--arch=armv5te \
--enable-cross-compile \
--cc=$ARM_TOOL/bin/${ARM_PRE}-gcc \
--cross-prefix=$ARM_TOOL/bin/${ARM_PRE}- \
--extra-cflags=" -fPIC -DANDROID -fpic -mthumb-interwork -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -Wno-psabi -march=armv5te -mtune=xscale -msoft-float -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -D ANDROID -Wa,--noexecstack -MMD -MP -I$LIB_INC -I$ARM_INC -std=gnu99" \
--enable-static \
--disable-shared --enable-libx264 --enable-gpl \
--disable-asm --disable-yasm \
--prefix=/home/zangcf/ffmpeg/ffmpeg_arm/ffmpeg_build \
--disable-amd3dnow --disable-amd3dnowext --disable-mmx --disable-sse --disable-ssse3 \
--extra-libs="-lc -lm -ldl -lgcc -lz -lx264 -lopus" \
--extra-ldflags=" -L$LIB_LIB -Wl,-rpath-link=$LIB_LIB -nostdlib -Bdynamic -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,nocopyreloc -Wl,-soname,/system/lib/libz.so
-Wl,-rpath-link=$ARM_LIB,-dynamic-linker=/system/bin/linker -L$ARM_LIB -nostdlib $ARM_LIB/crtbegin_dynamic.o $ARM_LIB/crtend_android.o " \
--enable-libfdk-aac \
--enable-nonfree \
--enable-libvpx \
--enable-libvorbis \
--enable-libtheora \
--enable-libmp3lame \
更多Android相關信息見Android 專題頁面 http://www.linuxidc.com/topicnews.aspx?tid=11
更多Android相關信息見Android 專題頁面 http://www.linuxidc.com/topicnews.aspx?tid=11