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
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
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
解压缩,然后使用如下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
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 \
使用NDK交叉编译ffmpeg, android后台可执行
内容版权声明:除非注明,否则皆为本站原创文章。
转载注明出处:http://www.heiqu.com/04cb244789ac7205ceee17f2e968fa48.html