简体   繁体   English

在 OSX 上为 Android 编译 ffmpeg

[英]Compiling ffmpeg for Android on OSX

I'm trying to compile ffmpeg for Android, on OSX 10.12.4 .我正在尝试在 OSX 10.12.4 上为 Android 编译 ffmpeg。

Here are the steps I followed:以下是我遵循的步骤:

1°) Compile pkg-config 1°) 编译 pkg-config

Download the sources from here .这里下载源代码。 Extract && cd in the pkg-config folder.在 pkg-config 文件夹中提取 && cd。

export DST=/a/path/on/my/computer

./configure --with-internal-glib --prefix=$DST --exec-prefix=$DST
make -j2
make install

export PATH=$PATH:$DST/bin

2°) Compile ffmpeg 2°) 编译 ffmpeg

Download the sources from here .这里下载源代码。 Extract && cd in the ffmpeg folder.在 ffmpeg 文件夹中提取 && cd。

export NDK=/path/to/android-ndk-r15c
export PLATFORM_VERSION=android-26
export ARCH=arm
export PLATFORM=$NDK/platforms/$PLATFORM_VERSION/arch-$ARCH
export TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64

export PREFIX=$(pwd)/android/$ARCH

export ADDI_CFLAGS="-Os -fpic -marm"
export ADDI_CONFIGURE_FLAG=""
export ADDI_LDFLAGS=""

./configure \
  --prefix=$PREFIX \
  --enable-shared \
  --disable-static \
  --disable-doc \
  --disable-ffmpeg \
  --disable-ffplay \
  --disable-ffprobe \
  --disable-ffserver \
  --disable-symver \
  --disable-avdevice \
  \
  --pkg-config=pkg-config \
  \
  --cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- \
  --target-os=linux \
  --arch=$ARCH \
  --enable-cross-compile \
  --sysroot=$PLATFORM \
  --extra-cflags="$ADDI_CFLAGS" \
  --extra-ldflags="$ADDI_LDFLAGS" \
  \
  $ADDI_CONFIGURE_FLAG

make -j2

Make fails with the following error: Make 失败并出现以下错误:

AR  libavfilter/libavfilter.a
AR  libavformat/libavformat.a
CC  libavcodec/aaccoder.o
In file included from /Users/Tim/Library/Android/android-ndk-r15c/platforms/android-26/arch-arm/usr/include/asm/termbits.h:19:0,
from /Users/Tim/Library/Android/android-ndk-r15c/platforms/android-26/arch-arm/usr/include/asm-generic/termios.h:21,
from /Users/Tim/Library/Android/android-ndk-r15c/platforms/android-26/arch-arm/usr/include/asm/termios.h:19,
from /Users/Tim/Library/Android/android-ndk-r15c/platforms/android-26/arch-arm/usr/include/linux/termios.h:22,
from /Users/Tim/Library/Android/android-ndk-r15c/platforms/android-26/arch-arm/usr/include/sys/ioctl.h:37,
from ./libavutil/timer.h:36,
from ./libavutil/internal.h:42,
from ./libavutil/common.h:467,
from libavcodec/mathops.h:27,
from libavcodec/aaccoder.c:38:
libavcodec/aaccoder.c: In function 'search_for_ms':
libavcodec/aaccoder.c:803:25: error: expected identifier or '(' before numeric constant
int B0 = 0, B1 = 0;
^
libavcodec/aaccoder.c:865:28: error: lvalue required as left operand of assignment
B0 += b1+b2;
^
libavcodec/aaccoder.c:866:25: error: 'B1' undeclared (first use in this function)
B1 += b3+b4;
^
libavcodec/aaccoder.c:866:25: note: each undeclared identifier is reported only once for each function it appears in
make: *** [libavcodec/aaccoder.o] Error 1
make: *** Waiting for unfinished jobs....

I'm able to fix that error by renaming B0 & B1 variables in the source to A0 & A1 (don't know why it fixes the problem), but then it fails somewhere else.我可以通过将源代码中的 B0 和 B1 变量重命名为 A0 和 A1 来修复该错误(不知道它为什么解决了这个问题),但是它在其他地方失败了。 I guess something is wrong in my config, and I'd prefer to avoid having to patch the source.我想我的配置有问题,我宁愿避免修补源代码。

So the questions are:所以问题是:

  • does someone know what's wrong here?有人知道这里出了什么问题吗? Do I need to give some args to gcc?我需要给 gcc 一些参数吗?
  • is the --target-os=linux correct, or should it be --target-os=darwin? --target-os=linux 是正确的,还是应该是--target-os=darwin? Is target-os the OS where the compilation is done, or where ffmpeg will be executed? target-os 是完成编译的操作系统,还是执行 ffmpeg 的操作系统? By using darwin, I can compile using --enable-static, but not --enable-shared (which I want).通过使用 darwin,我可以使用 --enable-static 进行编译,但不能使用 --enable-shared(我想要的)。

Note: I need to compile it myself as I want only an arm version, with HTTPS support.注意:我需要自己编译它,因为我只想要一个支持 HTTPS 的 arm 版本。 Thus I can't use the existing built versions.因此我不能使用现有的构建版本。

I also met this problem when I tried to build the ffmpeg 3.4 the latest version.I wish you could try the 3.3 version.I built it successfully.我在构建ffmpeg 3.4最新版本时也遇到了这个问题,希望你能试试3.3版本,我构建成功了。 I doubt that latest version is unstable and with some bug.我怀疑最新版本不稳定并且有一些错误。 By the way,You can take some answer By this article: http://alientechlab.com/how-to-build-ffmpeg-for-android/顺便说一句,你可以通过这篇文章来回答: http : //alientechlab.com/how-to-build-ffmpeg-for-android/

Issue closed by FFmpeg team FFmpeg 团队关闭的问题

--target-os=android solves it --target-os=android解决了

./configure \ 
... 
--target-os=android 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM