8

我看过一些关于如何为 Android 编译和使用 FFmpeg 的文章。

这是 2 个很好的例子 - example1example2

不幸的是,非他们,或者我发现的其他人帮助了我。在这两个示例中,创建了 build_android.sh 并配置了 FFmpeg 的配置文件并调用 make。每次运行脚本时,我都会收到以下错误:

c:\android\development\android-ndk-r9\sources\ffmpeg>sh build_android.sh
c:/android/development/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebu
ilt/windows-x86_64/arm-linux-androideabi/bin/bin/arm-linux-androideabi-gcc is un

able 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:49: /common.mak: No such file or directory
Makefile:92: /libavutil/Makefile: No such file or directory
Makefile:92: /library.mak: No such file or directory
Makefile:169: /doc/Makefile: No such file or directory
Makefile:170: /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

如果有人遇到并解决了这个问题,将不胜感激!

在尝试了建议的脚本后,我遇到了一个无法解决的新问题,这是脚本的输出:

.... 启用的组件列表....

在列表的最后,我得到了以下信息:

启用 indevs:dv1394 v4l2i fbdev

启用 outdevs:fbdev v4l2

许可证:LGPL 2.1 或更高版本正在创建 config.mak、config.h 和 doc/config.texi...

警告:C:/android/development/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/arm-linux-androideabi-pkg-config 未找到,库检测可能失败. make: *** 没有规则可以使目标libavfilter/libavfilter.so', needed by 全部为 ye s'。停止。make: *** 没有规则让目标install-libavfilter-shared', needed by 安装 l-libs-yes'。停止。

4

2 回答 2

8

您可以粘贴您在 FFmpeg 目录中复制的 build_android.sh 文件中的内容吗?

当脚本开头定义的变量之一设置不正确时,我遇到了同样的错误。检查您的 NDK 或 SYSROOT 或 TOOLCHAIN 变量是否设置为有效路径!

我尝试使用以下步骤,它对我有用:

1)下载 FFmpeg

git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg

2)在 FFmpeg 目录下创建一个名为 build_android.sh 的文件

cd ffmpeg; 触摸 build_ffmpeg_for_android.sh;

3)将以下内容添加到文件中

#!/usr/bin/env bash

NDK=$HOME/Software/Android/android-ndk-r10/
SYSROOT=$NDK/platforms/android-19/arch-arm/
TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64

function build_one
{
./configure \
    --prefix=$PREFIX \
    --enable-shared \
    --disable-static \
    --disable-doc \
    --disable-ffmpeg \
    --disable-ffplay \
    --disable-ffprobe \
    --disable-ffserver \
    --disable-avdevice \
    --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 -j4
make install
}

CPU=arm
PREFIX=$(pwd)/android/$CPU
ADDI_CFLAGS="-marm"

build_one

4)使脚本可执行

chmod +x build_ffmpeg_for_android.sh

5)开始构建 FFmpeg for Android (ARM)
(使用 Bash 运行脚本,即 /usr/bin/bash 而不是 /usr/bin/sh)

./build_ffmpeg_for_android.sh

于 2013-11-10T23:20:33.313 回答
1

我遇到了与@powerX 相同的错误,我能够使用与@dZkF9RWJT6wN8ux 不同的方法解决问题。

虽然我使用的是 Ubuntu 13.10,但我希望我的回答对您有所帮助。随着 android NDK r9 和 FFMPEG 2.2“Muybridge”的发布,我终于能够从@powerX example1 链接完成名为“Build FFMPEG”的第三步:http ://www.roman10.net/how-to-build-ffmpeg-与-ndk-r9/

我最终通过将 build_android.sh 文件中的 SYSROOT 变量更改为指向“.../android-19/arch-arm”而不是.../android-9/arch-arm 来解决此问题。

希望这可以帮助。

于 2014-03-24T21:19:23.410 回答