2017-10-20 142 views
1

我想在OSX 10.12.4上为Android编译ffmpeg。在OSX上为Android编译ffmpeg

下面是我遵循的步骤:

1°)编译pkg配置

here从下载源。在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°)编译FFMPEG

here下载源。在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 

制作失败,出现以下错误:

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.... 

我能够在源头上A0 & A1改名B0 & B1变量来修复错误(不知道为什么它修复问题),但是它在别的地方失败了。我猜想我的配置有些问题,我宁愿避免修补源代码。

所以问题是:

  • 没有人知道什么是错在这里?我需要给gcc一些参数吗?
  • 是--target-os = linux正确,还是应该是--target-os = darwin? target-os是编译完成的操作系统,还是执行ffmpeg的目标?通过使用darwin,我可以使用--enable-static进行编译,但不能使用--enable-shared(我想要)。

注意:我需要自己编译它,因为我只想要支持HTTPS的arm版本。因此我不能使用现有的内置版本。

回答

0

我也遇到这个问题,当我试图建立ffmpeg 3.4最新版本。我希望你可以尝试3.3版本,我成功地构建它。 我怀疑最新版本是不稳定的,并有一些错误。 顺便说一下,你可以采取一些答案通过这篇文章: http://alientechlab.com/how-to-build-ffmpeg-for-android/

+0

看起来我忘了回答我自己的问题,所以我会接受你的。我做了同样的事情,并采取了旧版本,这是工作。这么多时间为了这一点而输了! –