Android - 集成ffmpeg和android-ndk-r9c [英] Android - Integrating ffmpeg and android-ndk-r9c

查看:345
本文介绍了Android - 集成ffmpeg和android-ndk-r9c的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看过很多关于FFmpeg的帖子,在Android中使用了FFmpeg,但是我发现这些帖子中的大多数都是FFmpeg或Android NDK的旧版本。我能够从 https://github.com/mconf/android-ffmpeg,其中包括文件:libavcodec.so,libavformat.so,libavutil.so,libswscale.so。但是,只需将这些文件添加到我的项目中似乎不足以使用FFmpeg。 (我遵循 https://stackoverflow.com/a/21773572/1877798 作为参考指南)。有可能我在我的项目中配置这些文件时出错了,或者我为构建FFmpeg for Android做错了事情。 (应该有更多的文件?)



我想知道是否有任何最近的指南,用于在Android项目中构建或集成FFmpeg。我正在使用FFmpeg(截至2/27/14)和Android NDK 9c。
如果没有,有没有人有其他图书馆的其他建议?我正在尝试采取一组图像文件,并以编程方式创建一个视频/动画GIF。



谢谢! : - )






~~编辑~~



我发现 http://www.roman10.net/how-to-build-ffmpeg-with-ndk-r9/comment-page-4/ 和其他几个在GitHub上发现的。但是,他们似乎都在努力建设FFmpeg。我正在使用Mac OS X



这是我的脚本:

  #!/ bin / bash 
NDK = / Downloads / android-ndk-r9c
SYSROOT = $ NDK / platforms / android-18 / arch-arm /
TOOLCHAIN = $ NDK / toolchains / arm-linux-androideabi-4.8 / prebuilt / darwin-x86_64
#注意:更改TOOLCHAIN以适应您的主机系统。
#darwin-x86_64适用于Mac OS X,但您知道。
函数build_one
{
./configure \
--prefix = $ PREFIX \
--enable-shared \
--disable -static \
--disable-doc \
--disable-programs \
--disable-doc \
--disable-symver \
--cross-prefix = $ TOOLCHAIN / bin / arm-linux-androideabi- \
--target-os = linux \
--arch = arm \
- -enable-cross-compile \
--sysroot = $ SYSROOT \
--extra-cflags = - Os -fpic $ ADDI_CFLAGS\
--extra-ldflags = $ ADDI_LDFLAGS\
$ ADDITIONAL_CONFIGURE_FLAG
make clean
make
make install
}
CPU = arm
PREFIX = $(pwd )/ android / $ CPU
ADDI_CFLAGS = - marm
build_one

这是日志:

 配置为:--prefix = / Applications / Xcode.app / Contents / Developer / usr  - with-gxx-include-dir = / Applications / Xcode.app / Contents / Developer / Platforms / MacOSX。配置为:--prefix = / Applications / Xcode.app / Contents / Developer / usr --with-gxx-platform / Developer / SDKs / MacOSX10.9.sdk / usr / include / c ++ / 4.2.1 
include-dir = / Applications / Xcode.app / Contents / Developer / Platforms / MacOSX.platform / Developer / SDKs / MacOSX10.9.sdk / usr / include / c ++ / 4.2.1
/ Downloads / android-ndk -r9c / toolchains / arm-linux-androideabi-4.8 / prebuilt / darwin-x86_64 / bin / arm-linux-androideabi-gcc无法创建可执行文件。
C编译器测试失败。

如果您认为配置错误,请确保您使用Git中最新的
版本。如果最新版本失败,请将问题报告给irc.freenode.net上的
ffmpeg-user@ffmpeg.org邮件列表或IRC #ffmpeg。
包含由configure生成的日志文件config.log,因为这将帮助
解决问题。
Makefile:2:config.mak:没有这样的文件或目录
Makefile:48:/common.mak:没有这样的文件或目录
Makefile:91:/ libavutil / Makefile:没有这样文件或目录
Makefile:91:/library.mak:没有这样的文件或目录
Makefile:168:/ doc / Makefile:没有这样的文件或目录
Makefile:169:/ tests / Makefile:没有这样的文件或目录
make:***没有规则使目标`/ tests / Makefile'。停止。
Makefile:2:config.mak:没有这样的文件或目录
Makefile:48:/common.mak:没有这样的文件或目录
Makefile:91:/ libavutil / Makefile:没有这样文件或目录
Makefile:91:/library.mak:没有这样的文件或目录
Makefile:168:/ doc / Makefile:没有这样的文件或目录
Makefile:169:/ tests / Makefile:没有这样的文件或目录
make:***没有规则使目标`/ tests / Makefile'。停止。
Makefile:2:config.mak:没有这样的文件或目录
Makefile:48:/common.mak:没有这样的文件或目录
Makefile:91:/ libavutil / Makefile:没有这样文件或目录
Makefile:91:/library.mak:没有这样的文件或目录
Makefile:168:/ doc / Makefile:没有这样的文件或目录
Makefile:169:/ tests / Makefile:没有这样的文件或目录
make:***没有规则使目标`/ tests / Makefile'。停止。


解决方案

我正在使用android ndk r10e与ffmpeg 2.7.1和yasm 1.2.0(全部在下载文件夹中)在mac os x

 #!/ bin / bash 
#用法:
#将此脚本放在FFmpeg源代码树的顶部
#./build_android
#为以下体系结构生成二进制文件:
#ARMv6
#ARMv6 + VFP
#ARMv7 + VFPv3-d16(Tegra2)
#ARMv7 +霓虹灯(Cortex-A8)
#设置$ CPU和$ OPTIMIZE_CFLAGS
#call build_one

NDK = $ Users / samavesh / Downloads / android-ndk-r10e
SYSROOT = $ NDK / platforms / android-9 / arch-arm /
TOOLCHAIN = $ NDK / toolchains / arm-linux- androideabi-4.8 / prebuilt / darwin-x86_64

函数build_one
{
./configure --target-os = linux \
--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-shared \
--enable-static \
--extra-ldflags = - Wl,-rpath-link = $ PLATFORM / usr / lib -L ​​$ PLATFORM / usr / lib - nostdlib -lc -lm -ldl -llog\
--enable-parsers \
--enable-encoders \
--enable-decoders \
--disable-muxers \
--enable-demuxers \
--enable-swscale \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--enable-network \
--enable-indevs \
--disable-bsfs \
--enable-filters \
--enable-protocols \
--enable-asm \
$ ADDITIONAL_CONFIGURE_FLAG

#make清理
make -j4 install
$ PREBUILT / bin / arm-linux-androideabi-ar d libavcodec / libavcodec.a reverse.o

$ PREBUILT / bin / arm-linux -androideabi-ld -rpath-link = $ PLATFORM / usr / lib \
-L ​​$ PLATFORM / usr / lib -soname libffmpeg.so -shared -nostdlib \
-Bsymbolic --whole-存档--no-undefined -o $ PREFIX / libffmpeg.so \
libavcodec / libavcodec.a libavdevice / libavdevice.a libavfilter / libavfilter.a \
libavformat / libavformat.a libavutil / libavutil。 libswscale / libswscale.a \
libswresample / libswresample.a -lc -lm -lz -ldl -llog \
--dynamic-linker = / system / bin / linker \
$ PREBUILT / lib / gcc / arm-linux-androideabi / 4.8 / 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 = - 启用霓虹灯
#build_one

#arm v6 + vfp¹öÀüÄÄÆÄÀÏ
CPU = armv6
OPTIMIZE_CFLAGS = - DCMP_HAVE_VFP -mfloat-abi = softfp -mfpu = vfp -marm -march = $ CPU
PREFIX =。/ android / $ {CPU} _vfp
b TIONAL b AG

I have seen a lot of posts about FFmpeg and using FFmpeg in Android, but I am finding that a majority of these posts are for older versions of either FFmpeg or Android NDK. I was able to get a result from https://github.com/mconf/android-ffmpeg, which includes the files: "libavcodec.so", "libavformat.so", "libavutil.so", "libswscale.so". However, simply adding these files to my project does not seem to be enough to use FFmpeg. (I followed https://stackoverflow.com/a/21773572/1877798 as a reference guide). It's possible that either I've done something wrong in configuring these files in my project, or I've done something wrong in building FFmpeg for Android. (Should there be more files?)

I was wondering if there are any recent guides for building or integrating FFmpeg in an Android project. I am using FFmpeg (as of 2/27/14) and Android NDK 9c. If not, does anyone have other recommendations for other libraries? I am trying to take a set of image files and create a video/animated gif programatically.

Thanks! :-)


~~ EDIT ~~

I have found http://www.roman10.net/how-to-build-ffmpeg-with-ndk-r9/comment-page-4/ and a couple others found on GitHub. However, they all seem to struggle in building FFmpeg. I am using Mac OS X

Here is my script:

#!/bin/bash
NDK=/Downloads/android-ndk-r9c
SYSROOT=$NDK/platforms/android-18/arch-arm/
TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64
# Note: Change the TOOLCHAIN to match that available for your host system.
# darwin-x86_64 is for Mac OS X, but you knew that.
function build_one
{
./configure \
    --prefix=$PREFIX \
    --enable-shared \
    --disable-static \
    --disable-doc \
    --disable-programs \
    --disable-doc \
    --disable-symver \
    --cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- \
    --target-os=linux \
    --arch=arm \
    --enable-cross-compile \
    --sysroot=$SYSROOT \
    --extra-cflags="-Os -fpic $ADDI_CFLAGS" \
    --extra-ldflags="$ADDI_LDFLAGS" \
$ADDITIONAL_CONFIGURE_FLAG
make clean
make
make install
}
CPU=arm
PREFIX=$(pwd)/android/$CPU 
ADDI_CFLAGS="-marm"
build_one

Here is the log:

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-        dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1
/Downloads/android-ndk-r9c/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc is unable to create an executable file.
C compiler test failed.

If you think configure made a mistake, make sure you are using the latest
version from Git.  If the latest version fails, report the problem to the
ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "config.log" produced by configure as this will help
solving the problem.
Makefile:2: config.mak: No such file or directory
Makefile:48: /common.mak: No such file or directory
Makefile:91: /libavutil/Makefile: No such file or directory
Makefile:91: /library.mak: No such file or directory
Makefile:168: /doc/Makefile: No such file or directory
Makefile:169: /tests/Makefile: No such file or directory
make: *** No rule to make target `/tests/Makefile'.  Stop.
Makefile:2: config.mak: No such file or directory
Makefile:48: /common.mak: No such file or directory
Makefile:91: /libavutil/Makefile: No such file or directory
Makefile:91: /library.mak: No such file or directory
Makefile:168: /doc/Makefile: No such file or directory
Makefile:169: /tests/Makefile: No such file or directory
make: *** No rule to make target `/tests/Makefile'.  Stop.
Makefile:2: config.mak: No such file or directory
Makefile:48: /common.mak: No such file or directory
Makefile:91: /libavutil/Makefile: No such file or directory
Makefile:91: /library.mak: No such file or directory
Makefile:168: /doc/Makefile: No such file or directory
Makefile:169: /tests/Makefile: No such file or directory
make: *** No rule to make target `/tests/Makefile'.  Stop.

解决方案

I am using android ndk r10e with ffmpeg 2.7.1 and yasm 1.2.0 (all in downloads folder) in mac os x

#!/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)
# set $CPU and $OPTIMIZE_CFLAGS
# call build_one

NDK=$Users/samavesh/Downloads/android-ndk-r10e
SYSROOT=$NDK/platforms/android-9/arch-arm/
TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64

function build_one
{
./configure --target-os=linux \
--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-shared \
--enable-static \
--extra-ldflags="-Wl,-rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib  -    nostdlib -lc -lm -ldl -llog" \
--enable-parsers \
--enable-encoders  \
--enable-decoders \
--disable-muxers \
--enable-demuxers \
--enable-swscale  \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--enable-network \
--enable-indevs \
--disable-bsfs \
--enable-filters \
--enable-protocols  \
--enable-asm \
$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 \
-Bsymbolic --whole-archive --no-undefined -o $PREFIX/libffmpeg.so \
libavcodec/libavcodec.a libavdevice/libavdevice.a libavfilter/libavfilter.a \
libavformat/libavformat.a libavutil/libavutil.a libswscale/libswscale.a \
libswresample/libswresample.a -lc -lm -lz -ldl -llog \
--dynamic-linker=/system/bin/linker \
$PREBUILT/lib/gcc/arm-linux-androideabi/4.8/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

这篇关于Android - 集成ffmpeg和android-ndk-r9c的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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