Android NDK& FFMPEG构建 [英] Android NDK & FFMPEG build

查看:169
本文介绍了Android NDK& FFMPEG构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用NDK为我的Android应用程序构建FFMPEG库。我已经从它的网站下载了源代码,我想我建立它(这是我的第一个尝试使用NDK和ffmpeg)。我已经创建了一个 build.sh 文件,我正在使用它从Mac OS X上的命令行执行它。但是我有几个问题...

I'm trying to build FFMPEG library for my android application using the NDK. I have downloaded the source code from it's website and I think I build it (it's my first try working with NDK and ffmpeg). I have created a build.sh file which I'm using to execute it from command line on Mac OS X. But I have a few questions...

首先我知道我需要Android.mk文件,所以我可以在我的应用程序中使用构建的库,但是我不知道如何做,因为我告诉你的原因以上。在我运行我的 build.sh 后,我得到了一些文件夹和一些库的 android 文件夹。所以我的第一个问题是,如何构建我需要的Android.mk文件,或者如果有人可以解释我为什么需要它。

First things is as I know I need Android.mk file so I can use the builded library in my application,but I don't know how to do that for reasons which I told you above. After I run my build.sh I get android folder with a few folders and some libraries. So my first question is, how can I build the Android.mk file which I need...and maybe if someone can explain me why I need it.

我的第二个问题是我需要一些来自ffmpeg的库可以从我的应用程序中使用它们,但在构建之后,我无法在我的源代码树中看到它们。我知道我必须在我的 build.sh 中启用它们,我想我做了,但我看不到它们。所以有关我的构建文件的任何信息将有助于我了解如何配置它。
这是它的样子:

My second question is I need some libraries from ffmpeg to be able to use them from my app, but after the build i can't see them in my source tree. I know that I have to enable them in my build.sh and I think I did,but I can't see them. So any kind of information about my build file will be helpful for me to understand how to configure it. Here is how it looks like :

    #!/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=~/Desktop/android-ndk-r5b
PLATFORM=$NDK/platforms/android-8/arch-arm/
PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86
function build_one
{
./configure \
    --target-os=darwin \
    --prefix=$PREFIX \
    --enable-cross-compile \
    --extra-libs="-lgcc" \
    --arch=arm \
    --cc=$PREBUILT/bin/arm-linux-androideabi-gcc \
    --cross-prefix=$PREBUILT/bin/arm-linux-androideabi- \
    --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-doc \
    --disable-ffmpeg \
    --disable-ffplay \
    --disable-ffserver \
    --disable-ffprobe \
    --extra-ldflags="-Wl,-rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -nostdlib -lc -lm -ldl -llog" \
    --enable-zlib \
    --enable-version3 \
    --enable-nonfree \
    --enable-libmp3lame \
    --enable-libspeex \
    --enable-libtheora \
    --enable-libfaac \
    --enable-libvorbis \
    --enable-libaacplus \
    --prefix=$DIST_DIR \
    $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 -shared -nostdlib  -z,noexecstack -Bsymbolic --whole-archive --no-undefined -o $PREFIX/libffmpeg.so libavcodec/libavcodec.a libavformat/libavformat.a libavutil/libavutil.a libswscale/libswscale.a -lc -lm -lz -ldl -llog  --warn-once  --dynamic-linker=/system/bin/linker $PREBUILT/lib/gcc/arm-linux-androideabi/4.4.3/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

感谢任何有用的信息/建议/示例等。

Thanks for any kind of useful information/suggestions/examples and etc.

推荐答案

我就如何为 ffmpeg x264 android
zip与x264的ffmpeg的构建

您还可以下载包含您在<$ c上应用程序所需的文件的zip文件$ c> android 。

You can also download the zip file containing the files you need to make an application on android.

这篇关于Android NDK&amp; FFMPEG构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆