在Mac上为Android编译ffmpeg

时间:2018-11-20 02:33:46

标签: android macos ffmpeg

我试图在Mac上为Android编译ffmpeg,但是对我来说不起作用。

onNext

我还通过#!/bin/bash NDK=/Users/user/Library/Android/sdk/ndk-bundle SYSROOT=$NDK/platforms/android-18/arch-arm/ TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64 function build_one { ./configure \ --prefix=$PREFIX \ --enable-shared \ --disable-static \ --disable-doc \ --disable-ffmpeg \ --disable-ffplay \ --disable-ffprobe \ --disable-network \ --disable-filters \ --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 all make make install } CPU=arm PREFIX=$(pwd)/android/$CPU ADDI_CFLAGS="-marm" build_one 授予执行权限

我尝试了ffmpeg chmod +x build_script.sh4.1,但是两者都不起作用,并且错误原因相同。

我还尝试了4.0.3android-21

android-18

是否需要额外安装任何工具/应用程序或库才能进行编译?我很困惑。...(这个问题可能对我没有作用,但没有解决办法)

编辑以阐明我的系统环境。

  • Mac OS X High Sierra(10.13.6)
  • Android NDK(18.1.5063045)
  • Android SDK工具和SDK构建工具
  • CMake

编辑,我也尝试了ffmpeg版本test_cpp_condition stddef.h defined __ARM_ARCH_4__ || defined __TARGET_ARCH_4 test_cpp BEGIN /tmp/ffconf.bgSdFwkD/test.c 1 #include <stddef.h> 2 #if !(defined __ARM_ARCH_4__ || defined __TARGET_ARCH_4) 3 #error "unsatisfied condition: defined __ARM_ARCH_4__ || defined __TARGET_ARCH_4" 4 #endif END /tmp/ffconf.bgSdFwkD/test.c /Users/user/Library/Android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc --sysroot=/Users/user/Library/Android/sdk/ndk-bundle/platforms/android-21/arch-arm/ -Os -fpic -marm -E -o /tmp/ffconf.bgSdFwkD/test.o /tmp/ffconf.bgSdFwkD/test.c /tmp/ffconf.bgSdFwkD/test.c:3:2: error: "unsatisfied condition: defined __ARM_ARCH_4__ || defined __TARGET_ARCH_4" #error "unsatisfied condition: defined __ARM_ARCH_4__ || defined __TARGET_ARCH_4" ^ 1 error generated. test_cpp_condition stddef.h defined __ARM_ARCH_4T__ || defined __TARGET_ARCH_4T test_cpp BEGIN /tmp/ffconf.bgSdFwkD/test.c 1 #include <stddef.h> 2 #if !(defined __ARM_ARCH_4T__ || defined __TARGET_ARCH_4T) 3 #error "unsatisfied condition: defined __ARM_ARCH_4T__ || defined __TARGET_ARCH_4T" 4 #endif END /tmp/ffconf.bgSdFwkD/test.c /Users/user/Library/Android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc --sysroot=/Users/user/Library/Android/sdk/ndk-bundle/platforms/android-21/arch-arm/ -Os -fpic -marm -E -o /tmp/ffconf.bgSdFwkD/test.o /tmp/ffconf.bgSdFwkD/test.c test_ld cc test_cc BEGIN /tmp/ffconf.bgSdFwkD/test.c 1 int main(void){ return 0; } END /tmp/ffconf.bgSdFwkD/test.c /Users/user/Library/Android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc --sysroot=/Users/user/Library/Android/sdk/ndk-bundle/platforms/android-21/arch-arm/ -Os -fpic -marm -march=armv4t -c -o /tmp/ffconf.bgSdFwkD/test.o /tmp/ffconf.bgSdFwkD/test.c /Users/user/Library/Android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc --sysroot=/Users/user/Library/Android/sdk/ndk-bundle/platforms/android-21/arch-arm/ -march=armv4t -o /tmp/ffconf.bgSdFwkD/test /tmp/ffconf.bgSdFwkD/test.o ld: unknown option: --sysroot=/Users/user/Library/Android/sdk/ndk-bundle/platforms/android-21/arch-arm/ clang: error: linker command failed with exit code 1 (use -v to see invocation) C compiler test failed. ,但它也不起作用。

2 个答案:

答案 0 :(得分:0)

您可以使用包装器https://github.com/WritingMinds/ffmpeg-android  如果要使用大多数命令。它将增加apk的大小。

我也尝试编译它,经过几次尝试,我编译了自己的。但是也很难集成。我使用下面的教程进行编译。

但是我只是想告诉您,如果您不考虑apk的大小,请使用FFmpeg包装器。在自己编译的FFmpeg中并没有获得可观的性能提升。使用您想要的上述包装纸。它运作良好。如果您更热衷于编译和集成自己的FFmpeg,请尝试上面的教程。

答案 1 :(得分:0)

我是通过 Android Studio 安装了NDK的,我认为这是问题所在,所以我手动下载了Android NDK,现在我可以配置并运行makefile。

等等!还没做完。当我使用最新的稳定NDK(r16b)运行makefile时,它说:
./libavutil/common.h:33:19: fatal error: errno.h: No such file or directory

根据this document,所以我尝试使用NDK r15c,它最终对我有用。

总结一下我如何解决此问题:手动安装NDK r15c ,不要忘记更新您的Shell脚本文件!

希望得到帮助!