【问题标题】:Android - Integrating ffmpeg and android-ndk-r9cAndroid - 集成 ffmpeg 和 android-ndk-r9c
【发布时间】:2014-03-31 13:02:50
【问题描述】:

我看过很多关于 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 作为参考指南)。可能是我在项目中配置这些文件时做错了,或者我在为 Android 构建 FFmpeg 时做错了。 (应该有更多文件吗?)

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

谢谢! :-)


~~编辑~~

我在 GitHub 上找到了 http://www.roman10.net/how-to-build-ffmpeg-with-ndk-r9/comment-page-4/ 和其他几个。然而,他们似乎都在努力构建 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
# 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

这是日志:

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.

【问题讨论】:

    标签: android macos video android-ndk ffmpeg


    【解决方案1】:

    试试我目前用过最好的这个:https://github.com/bbcallen/ijkplayer

    【讨论】:

    【解决方案2】:

    我也有同样的错误。

    "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'。停下来。”

    请检查脚本中的目录路径是否正确。即:'/Downloads/android-ndk-r9c/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64/"

    我认为它实际上是“$HOME/Downloads”

    还要确保您在“.../android-ndk-r9c/sources/FFMPEG/”目录中运行脚本。

    【讨论】:

      【解决方案3】:

      您需要修复不正确的 NDK 路径。 可能是:NDK=/user//Downloads/android-ndk-r9c

      你想在浏览器中签入:

      file:///user/xyz/Downloads/android-ndk-r9c

      如果有效,则打开“android-ndk-r9c”文件夹。当你成功后,将它放在你的 NDK 路径上并构建。

      【讨论】:

        【解决方案4】:

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

        #!/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
        

        【讨论】:

        • 您可以通过添加一些评论或解释来丰富您的答案!
        猜你喜欢
        • 2014-07-04
        • 1970-01-01
        • 2012-06-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-06-25
        • 2015-11-02
        相关资源
        最近更新 更多