使用android-ndk-r14b构建ffmpeg 3.3

时间:2017-05-23 14:05:13

标签: android ffmpeg android-ndk

在ffmpeg的配置文件中进行的更改:

SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
SLIB_INSTALL_LINKS='$(SLIBNAME)'

build_configure.sh

#!/bin/bash
  ######################################################
# Usage:
# put this script in top of FFmpeg source tree
# ./build_android
# It generates binary for following architectures:
# ARMv6
# ARMv6+VFP
# ARMv7+VFPv3-d16 (Tegra2)
# ARMv7+Neon (Cortex-A8)
# Customizing:
# 1. Feel free to change ./configure parameters for more features
# 2. To adapt other ARM variants
# set $CPU and $OPTIMIZE_CFLAGS
# call build_one
######################################################
NDK=$HOME/Fame/android-ndk-r14b
PLATFORM=$NDK/platforms/android-9/arch-arm/
TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64
function build_one
{
./configure --target-os=linux \
  --prefix=$PREFIX \
  --enable-cross-compile \
  --arch=arm \
  --cc=$PREBUILT/bin/arm-linux-androideabi-gcc \
  --cross-prefix=$PREBUILT/bin/arm-linux-androideabi-4.9 \
  --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 \
  --disable-everything \
  --enable-demuxer=mov \
  --enable-demuxer=h264 \
  --disable-ffplay \
  --enable-protocol=file \
  --enable-avformat \
  --enable-avcodec \
  --enable-decoder=rawvideo \
  --enable-decoder=mjpeg \
  --enable-decoder=h263 \
  --enable-decoder=h265 \
  --enable-decoder=mpeg4 \
  --enable-decoder=h264 \
  --enable-parser=h264 \
  --enable-parser=h265
  --enabled-network \
  --enable-zlib \
  --disable-avfilter \
  --disable-avdevice \
  --disable-yasm \
  --disable-ffmpeg
  --disable-ffprobe
  --disable-ffserver
  $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 -nostdlib,noexecstack -Bsymbolic \
--whole-archive --no-undefined \
-o $PREFIX/libffmpeg.so libavcodec/libavcodec.a libavformat/libavformat.a \
libavutil/libavutil.a libswscale/libswscale.a \
$PLATFORM/usr/lib/libc.so $PLATFORM/usr/lib/libm.so \
$PLATFORM/usr/lib/libz.so \
$PLATFORM/usr/lib/libdl.so $PLATFORM/usr/lib/liblog.so \
--dynamic-linker=/system/bin/linker \
$PREBUILT/lib/gcc/arm-linux-androideabi/4.9/libgcc.a
}

#arm v6
#CPU=armv6
#OPTIMIZE_CFLAGS="-marm -march=$CPU"
#PREFIX=./android/$CPU
#ADDITIONAL_CONFIGURE_FLAG=
#build_one

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

#arm v7vfp
#CPU=armv7-a
#OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=vfp -marm -march=$CPU "
#PREFIX=./android/$CPU-vfp
#ADDITIONAL_CONFIGURE_FLAG=
#build_one

#arm v7n
#CPU=armv7-a
#OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=neon -marm -march=$CPU -mtune=cortex-a8"
#PREFIX=./android/$CPU
#ADDITIONAL_CONFIGURE_FLAG=--enable-neon
#build_one

#arm v6+vfp
#CPU=armv6
#OPTIMIZE_CFLAGS="-DCMP_HAVE_VFP -mfloat-abi=softfp -mfpu=vfp -marm -march=$CPU"
#PREFIX=./android/${CPU}_vfp
#ADDITIONAL_CONFIGURE_FLAG=
#build_one

我得到的控制台出错: ./build_android.sh

./ configure:466:./ configure:无法创建ffbuild / config.log:目录不存在     ./configure:466:./ configure:无法创建ffbuild / config.log:目录不存在     / bin / arm-linux-androideabi-gcc无法创建可执行文件。     C编译器测试失败。

1 个答案:

答案 0 :(得分:0)

您可以尝试使用Standalone Toolchain。他们帮助解决了为NDK构建第三方代码的问题。不能保证,但值得一试。