rockplayer_ffmpeg在AOSP中的编译

        最近为Android2.3的多媒体框架Stagefright做Extractor,考虑到ffpeg能提供相对完整的文件格式解析,因此选择了它。所谓AOSP,是Android Open Source Project的缩写,也就是说我不是用NDK进行编译的,而是在Platform中编译的。

        做过多媒体中间件的朋友都知道,视频文件在解码前必须先进行解析,主要工作是完成音视频的分流,并保存解析出来的音视频流的格式信息,如:编码格式,比特率,mime类型等等。这里提到的Extractor就是完成这个工作的,在其它多媒体框架中也有叫demuxer,parser或splitter。

        再提一下rockplayer_ffmpeg,是在开源ffmpeg基础上进行裁减后的版本,用于目前广泛流行的一个全格式多媒体播放器rockplayer上,因此起名rockplayer_ffmpeg,下载地址:http://rockplayer.freecoder.org/download/rockplayer_ffmpeg.zip

        最后说明对这个工程的修改和编译,本人将rockplayer_ffmpeg编译成.so文件。将rockplayer_ffmpeg与开源的ffmpeg进行比较,除了对目录和文件本身的差别外,最明显的差别是:rockplayer_ffmpeg的作者好人啊,将所有源文件整理成适合编译为一个单纯的.so文件中。这与目前网上广为流传的开源的ffmpeg在NDK下的编译有很大不同,尽管后者也是将其编译为一个.so,但是其中在.so中又依赖libavformat,libavutil,libavcodec等静态库。用NDK这种方式在AOSP下编译后,在使用过程中可能会遇到意想不到的错误,至少我碰到过,霎时恼人啊,列为看官希望你们好运。

 

        这里的主要工作是修改rockplayer_ffmpeg目录下的Android.mk文件,config.h文件。

 

 首先,Android.mk的修改,记录如下

1、添加几个变量:

      LOCAL_ARM_MODE := arm
      LOCAL_PRELINK_MODULE := false   //如果你愿意去修改prelink-linux-arm.map文件,可以不加该变量
      LOCAL_MODULE_TAGS := optional

2、去掉以下这几行,我这么做是由于兄弟我用的ARM芯片不支持这些个特性,如果兄弟你的支持,可以考虑加上

      LOCAL_SRC_FILES +=$(VFP_SRC_FILES)
      LOCAL_SRC_FILES +=$(ARM6_SRC_FILES)
      LOCAL_SRC_FILES +=$(NEON_SRC_FILES)

3、注释掉以下几个源文件:

      libavcodec/dxa.c
      libavcodec/flashsv.c
      libavcodec/lcldec.c
      libavcodec/pngdec.c
      libavcodec/tscc.c
      libavcodec/zmbv.c

原因是:这些文件都需要一个叫<zlib.h>的头文件,而在AOSP的标准径下没有,所以报错。看了下这这几个文件,都是codec用的,我作文件解析暂时用不到,所以直接kill掉了。如果兄弟你要用这些codec文件的话,恭喜你自己解决,要是能够把解决方法一并贴出来让大家学习就更完美了,兄弟这里先谢了。

4、可选项,针对那些需要用LOGI/D/V/W等进行信息打印的看官,那么在LOCAL_SHARED_LIBRARIES变量后添加一个libcutils


config.h的修改

1、将CONFIG_ZLIB改为0,为了关闭对<zlib.h>头文件的引用

2、如果报什么XXX_DECODER/ENCODER啥的找不到或类似错误,直接把CONFIG_XXX_DECODER/ENCODER置为0

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 12
    评论
FFmpeg for Android Introduction ======================================================= FFmpeg for Android is a set of Android makefiles which enable configuration and building FFmpeg library under Android source code tree with Android NDK. While working as a system integrator, I have come upon more than few Android ports of FFmpeg library. All of them have some non-features in common: - It is not possible to use configure script to configure the library. This may lead to invalid library configuration and output and degraded performance or feature set. - Some FFmpeg libraries are missing. Usually, only libavutil, libavcodec and libavformat are built. - FFmpeg tools (ffmpeg, ffplay, ffprobe, ffserver) are missing. - Manually added files into Android.mk, usually without proper understanding of dependencies between files and function of each file in a library. - Configuration is locked to single architecture. - The library can not be built in parallel for different target products and architectures. This is important for large test environments. - Missing or incomplete compiler and linker flags. - Building library in a "It compiles = It is working" manner. - Building library as a large single file. This project is my attempt to address these and many other issues and create makefiles for building FFmpeg library under Android source code tree which will create output as close as possible to the output of "regular" building process using standalone toolchain. These makefiles are result of combining and extending various makefiles I have found on the web and during my work. Makefiles are tested and are working fine on: Build host OS: Ubuntu 12.04 Android target OS: Android Master branch Architecture: arm, mips, x86 SDK + NDK release: highest available, selected during building Product: aosp_arm-eng, aosp_mips-eng, aosp_x86-eng FFmpeg releases: Latest releases from 0.7, 2.0 and HEAD branches ==================== Features ==================== - On-the-fly library configuration. FFmpeg will be configured on-the-fly, during Android building process, in accordance to the selected product, cpu architecture, cpu architecture variant, and fine tuning cpu parameters. - Configuration driven building. No need to manually add filenames to the makefiles, or hack through the library in order to get the build you want. - Per product configuration. Every TARGET_PRODUCT will have its own configuration. - Builds all libraries and tools, except ffplay. - Builds both shared and static libraries. - Builds latest releases from 0.7, 2.0 and HEAD branches. - Supports parallel building from the same source for the different products. =========================================================================== Known issues =========================================================================== - For a very long time now, I was not able to make a release which can build for all three major architectures - arm, mips and x86. Sometimes problem was compiler, and sometimes problems were assembler instructions. For the sake of making update to recent FFmpeg version, I released makefiles which are not able to build all version to all platforms. With this release, you can build only: For ARM: HEAD, 2.1.4, 0.7.16 For MIPS: 0.7.16 For X86: None =========================================================================== Note =========================================================================== Due to the overwhelming load on my build testing equipment, I have dramatically reduced supported versions, platforms and Android OS versions. From now on, the supported branches will be 0.7 as the last 0.6 ABI compatible, latest official release and HEAD. =========================================================================== Usage =========================================================================== Extract ffmpeg-<version>.android.tar.gz into Android source code tree, at location: <android-src-root-dir>/external Files will be located in: <android-src-root-dir>/external/ffmpeg-<version>.android Edit Android_configuration.mk and apply your customizations to the ./configure parameters, if needed. Initialize Android build environment: cd <android-src-root-dir> . build/envsetup.sh lunch <product> To configure and build the library, run make or cd external/ffmpeg-<version>.android; mm; If there is no existing library configuration for a selected product, the library will be configured on the fly, during building process, with parameters provided in Android_configuration.mk. Whenever you change configuration parameters, the library will be reconfigured. Compiled FFmpeg libraries and tools will have version suffix, eg libavcodec-2.0.a, libavutil-2.0.so, ffprobe-2.0 =========================================================================== Support =========================================================================== Since Android is changing daily, and releases are tested only on a release day, it is possible that after some time you will have issues with building FFmpeg for Android. Feel free to post on discussion board: https://sourceforge.net/p/ffmpeg4android/discussion/ Feel free to report issues: https://sourceforge.net/p/ffmpeg4android/tickets/ I will try to respond in a timely manner. =========================================================================== Plan =========================================================================== Short term plan is to test and update scripts to work on more architectures and platforms. Long term plan is to continue to provide scripts for latest FFmpeg library releases, as they appear. The Ultimate plan is to try to make scripts part of official FFmpeg library, once they are stable and robust enough. =========================================================================== License: =========================================================================== Please, note that FFmpeg library and FFmpeg for Android makefiles for building it under Android source code tree are two different projects. FFmpeg for Android makefiles are licensed under whatever license You are using FFmpeg.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 12
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

何雷 — 智能汽车

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值