使用 NDK r9 编译ffmpeg

1. 环境 ubuntu 我的是12.04  ndk r9d 64位

2. 下载ffmpeg http://www.ffmpeg.org/download.html  找到 

FFmpeg 2.1.3 "Fourier"

2.1.3 was released on 2014-01-15. It is the latest stable FFmpeg release from the 2.1 release branch, which was cut from master on 2013-10-28. Amongst lots of other changes, it includes all changes from ffmpeg-mt, libav master of 2013-10-27, libav 9 as of 2013-10-27.

It includes the following library versions:

  libavutil      52. 48.101
  libavcodec     55. 39.101
  libavformat    55. 19.104
  libavdevice    55.  5.100
  libavfilter     3. 90.100
  libswscale      2.  5.101
  libswresample   0. 17.104
  libpostproc    52.  3.100

Download bzip2 tarball  下载

下载之后 解压到 $NDK/sources   文件夹下面,这是因为编译快捷以及方便使用

3.  找到 ffmpeg-xxx/configure 找到如下几行:

Java代码   收藏代码
  1. SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'  
  2. LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'  
  3. SLIB_INSTALL_NAME='$(SLIBNAME_WITH_VERSION)'  
  4. SLIB_INSTALL_LINKS='$(SLIBNAME_WITH_MAJOR) $(SLIBNAME)'  

 上面几行会导致libavcodec.so.<version> (e.g. libavcodec.so.55),不会被android承认 ,修改为;

Java代码   收藏代码
  1. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'  
  2. LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'  
  3. SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'  
  4. SLIB_INSTALL_LINKS='$(SLIBNAME)'  

 4. 复制下面的代码到文本中 并命名为 build_android.sh,注意这个文件应该保存到 ffmpeg-xxx/configure 同一个文件夹下

Java代码   收藏代码
  1. #!/bin/bash  
  2. NDK=$HOME/Desktop/adt/android-ndk-r9  
  3. SYSROOT=$NDK/platforms/android-9/arch-arm/  
  4. TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64  
  5. function build_one  
  6. {  
  7. ./configure \  
  8.     --prefix=$PREFIX \  
  9.     --enable-shared \  
  10.     --disable-static \  
  11.     --disable-doc \  
  12.     --disable-ffmpeg \  
  13.     --disable-ffplay \  
  14.     --disable-ffprobe \  
  15.     --disable-ffserver \  
  16.     --disable-avdevice \  
  17.     --disable-doc \  
  18.     --disable-symver \  
  19.     --cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- \  
  20.     --target-os=linux \  
  21.     --arch=arm \  
  22.     --enable-cross-compile \  
  23.     --sysroot=$SYSROOT \  
  24.     --extra-cflags="-Os -fpic $ADDI_CFLAGS" \  
  25.     --extra-ldflags="$ADDI_LDFLAGS" \  
  26.     $ADDITIONAL_CONFIGURE_FLAG  
  27. make clean  
  28. make  
  29. make install  
  30. }  
  31. CPU=arm  
  32. PREFIX=$(pwd)/android/$CPU   
  33. ADDI_CFLAGS="-marm"  
  34. build_one  

 注意修改 NDK=$HOME/Desktop/adt/android-ndk-r9d 这行  

5. 执行 

Java代码   收藏代码
  1. sudo chmod +x build_android.sh  
  2.   
  3. ./build_android.sh  

 6.输出  $NDK/sources/ffmpeg-xxx/android,  arm/lib 和arm/include 

注意 arm/lib包含了两个 library files (e.g.: libavcodec-55.so) 和 symbolic links (e.g.: libavcodec.so) 我们需要删掉 symbolic links .


转载地址:http://wang-peng1.iteye.com/blog/2004897

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值