Update @ 2011-6-26:在 Windows 7 下使用 Android NDK r5c 编译 FFmpeg 0.7.1

Update @ 2011-6-22:在 Mac OS X 下使用 Android NDK r5b 编译 FFmpeg 0.8

 

在我写这篇随笔之前,你可以 Google 到几篇教你如何使用 NDK 编译 FFmpeg 的文章。但让人沮丧的是,当你按着文章中给出的方法去尝试编译 FFmpeg 时,你总是不能编译成功。你会遇到各种各样的错误,它们会让你渐渐丧失信心。

 

我总结了一下导致编译失败几个原因:

  1. Google 提供的 NDK 有 BUG,需要修改 build-binary.mk 文件
  2. 编译方法太复杂,或许还需要修改 FFmpeg 的源代码
  3. 文章作者使用的 FFmpeg 源代码是 SVN 版,非正式版
  4. 你所使用的操作系统不同和文章中使用的操作系统不同
  5. 你需要对 FFmpeg 重新进行配置以符合你的具体需求

 

我将在这篇随笔中解决上面这些问题:

  1. 不使用 NDK 中有问题的功能,不需要 build-binary.mk 文件
  2. 不需要修改 FFmpeg 的源代码或者是其他什么文件
  3. 使用的是 FFmpeg 正式版源代码,你可以在官网下载到这个版本
  4. 在虚拟机中进行编译,不需要你更换操作系统
  5. 可以对 FFmpeg 重新进行配置符合你的具体需求

 

下面是具体的编译方法:

 

一、下载必要软件

  1. VirtualBox 4.0.8
  2. Ubuntu 11.04 32-bit
  3. Android NDK r4b
  4. FFmpeg 0.6.3

 

二、配置编译环境

  1. 在 VirtualBox 中创建一个 Ubuntu 虚拟机
  2. 将 android-ndk-r4b-linux-x86.zip 中的内容解压缩到 /home/ScottWong 目录下
  3. 将 ffmpeg-0.6.3.tar.bz2 中的内容解压缩到 /home/ScottWong/ffmpeg 目录下
  4. 将 /home/ScottWong/ffmpeg/ffmpeg-0.6.3 目录重命名为 /home/ScottWong/ffmpeg/jni

 

三、编写 FFmpeg 配置脚本

将以下内容保存为 /Users/ScottWong/ffmpeg/jni/config.sh 文件。这里的编译参数是可以根据具体需求进行修改的。

1: ./configure \
   2:     --disable-static \
   3:     --enable-shared \
   4:     --enable-gpl \
   5:     --enable-version3 \
   6:     --enable-nonfree \
   7:     --disable-doc \
   8:     --disable-ffmpeg \
   9:     --disable-ffplay \
  10:     --disable-ffprobe \
  11:     --disable-ffserver \
  12:     --disable-avdevice \
  13:     --disable-avfilter \
  14:     --disable-mpegaudio-hp \
  15:     --enable-small \
  16:     --cross-prefix=/home/ScottWong/android-ndk-r4b/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/arm-eabi- \
  17:     --enable-cross-compile \
  18:     --target-os=linux \
  19:     --extra-cflags='-I/home/ScottWong/android-ndk-r4b/build/platforms/android-8/arch-arm/usr/include' \
  20:     --extra-ldflags='-L/home/ScottWong/android-ndk-r4b/build/platforms/android-8/arch-arm/usr/lib -nostdlib' \
  21:     --arch=arm \
  22:     --disable-debug \
  23:     --disable-stripping \
  24:  
  25: sed -i 's/HAVE_LRINT 0/HAVE_LRINT 1/g' config.h
  26: sed -i 's/HAVE_LRINTF 0/HAVE_LRINTF 1/g' config.h
  27: sed -i 's/HAVE_ROUND 0/HAVE_ROUND 1/g' config.h
  28: sed -i 's/HAVE_ROUNDF 0/HAVE_ROUNDF 1/g' config.h
  29: sed -i 's/HAVE_TRUNCF 0/HAVE_TRUNCF 1/g' config.h
  30: sed -i 's/HAVE_SYMVER 1/HAVE_SYMVER 0/g' config.h
  31:  

相关文章:

  • 2021-08-01
  • 2021-10-26
  • 2021-07-31
  • 2021-08-01
  • 2022-12-23
  • 2021-06-28
  • 2021-12-13
  • 2021-10-31
猜你喜欢
  • 2021-11-11
  • 2021-08-21
  • 2022-12-23
  • 2021-11-08
  • 2021-08-08
  • 2021-04-13
相关资源
相似解决方案