编译FFmpeg lib并将其添加到Windows8上的NDK源

Nat*_*tiv 7 ffmpeg android-ndk

我已经看过一些关于如何编译和使用FFmpeg for Android的文章.

这是一个很好的例子 - 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
Run Code Online (Sandbox Code Playgroud)

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

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

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

在列表的最后,我得到以下内容:

启用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,libr ary检测可能会失败.make:*没有规则可以制定libavfilter/libavfilter.so', needed by全部目标.停止.make:*没有规则来制作目标install-libavfilter-shared', needed by安装l-libs-yes'.停止.

bit*_*tek 8

你可以粘贴你在buildmp文件目录中复制的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
Run Code Online (Sandbox Code Playgroud)

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

  • 你使用NDK版本吗?我的NDK版本是r9,我不断收到脚本错误消息的结尾:"找不到arm-linux-androideabi-pkg-config,库检测可能会故障",然后是"nonexecstack:unknown -z option" (2认同)