参考: http://www.roman10.net/how-to-build-ffmpeg-with-ndk-r9/

ffmpeg用的是2.3.2版本。

困扰了很久,终于使用参考链接里的脚本成功编译了ffmpeg232版本,具体步骤为:

1. 下载ffmpeg源码并解压,我解压后的源码目录为:E:\android;(参考链接说需要放到ndk目录下的source目录下,实测表明不是必须的如此)

2. 安装MinGW; (1,2步参考http://blog.csdn.net/finewind/article/details/38854517,实际上我使用的也是当时编译VS版FFMPEG的环境);

3. 下载android NDK,下载地址:http://developer.android.com/tools/sdk/ndk/index.html,要注意win7是32位版还是64位版,我下载的是android-ndk-r10d-windows-x86_64.exe

,双击解压,我最后把解压后的android-ndk-r10d文件夹放在E:\android下面;

4. 修改配置文件(参考链接里说需要修改配置文件,但我不修改也能成功编译);

将以下内容:

SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
SLIB_INSTALL_NAME='$(SLIBNAME_WITH_VERSION)'
SLIB_INSTALL_LINKS='$(SLIBNAME_WITH_MAJOR) $(SLIBNAME)'

修改为:

SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
SLIB_INSTALL_LINKS='$(SLIBNAME)'

5. 在ffmpeg源码目录下新建一个build_android.sh脚本,并输入如下内容:

NDK=E:/android/android-ndk-r9d
SYSROOT=$NDK/platforms/android-19/arch-arm/
TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64
CPU=arm
PREFIX=$(pwd)/android/$CPU
ADDI_CFLAGS="-marm"function build_one
{
./configure \--prefix=$PREFIX \--enable-shared \--disable-static \--disable-doc \--disable-ffmpeg \--disable-ffplay \--disable-ffprobe \--disable-ffserver \--disable-avdevice \--disable-doc \--disable-symver \--cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- \--target-os=linux \--arch=arm \--enable-cross-compile \--sysroot=$SYSROOT \--extra-cflags="-Os -fpic $ADDI_CFLAGS" \--extra-ldflags="$ADDI_LDFLAGS"
make clean
make
make install
}
build_one

(注意不要直接从网页上复制这个脚本,如果直接从网页复制,有些行结尾会有2个空格,这会导致配置失败,可以用代码段上方的复制功能复制脚本)

6. 双击msys.bat,进入类linux shell界面(mysy在C:\MinGW\msys\1.0下),然后跳转到ffmpeg源码目录下(cd E:/android/ffmpeg232/);先用chmod +x build_android.sh给build_android.sh增加执行权限,在输入build_android.sh,然后就静等ffmpeg编译完成.

以下是链接地址原文:

This is a updated post for a previous post, where we built ffmpeg 0.8 with Android NDK r5 and r6. This post will give instructions of how to build ffmpeg 2.0.1 with Android NDK r9.

0. Download Android NDK

The latest version of Android NDK can be downloaded at Android NDK website. At the time of writing, the newest version is NDK r9. Note that the website provides both current and legacy toolchains. We only need the current toolchain to compile ffmpeg.

After download NDK, simply decompress the archive. Note that we’ll use $NDK to represent the root path of the decompressed NDK.

1. Download ffmpeg source code

FFMPEG source code can be downloaded from the ffmpeg website. The latest stable release is 2.0.1. Download the source code and decompress it to $NDK/sources folder. We’ll discuss about the reason for doing this later.

2. Update configure file

Open ffmpeg-2.0.1/configure file with a text editor, and locate the following lines.

SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
SLIB_INSTALL_NAME='$(SLIBNAME_WITH_VERSION)'
SLIB_INSTALL_LINKS='$(SLIBNAME_WITH_MAJOR) $(SLIBNAME)'

This cause ffmpeg shared libraries to be compiled to libavcodec.so.<version> (e.g. libavcodec.so.55), which is not compatible with Android build system. Therefore we’ll need to replace the above lines with the following lines.

SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
SLIB_INSTALL_LINKS='$(SLIBNAME)'

3. Build ffmpeg

Copy the following text to a text editor and save it as build_android.sh.

#!/bin/bash
NDK=$HOME/Desktop/adt/android-ndk-r9
SYSROOT=$NDK/platforms/android-9/arch-arm/
TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64
function build_one
{
./configure \
    --prefix=$PREFIX \
    --enable-shared \
    --disable-static \
    --disable-doc \
    --disable-ffmpeg \
    --disable-ffplay \
    --disable-ffprobe \
    --disable-ffserver \
    --disable-avdevice \
    --disable-doc \
    --disable-symver \
    --cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- \
    --target-os=linux \
    --arch=arm \
    --enable-cross-compile \
    --sysroot=$SYSROOT \
    --extra-cflags="-Os -fpic $ADDI_CFLAGS" \
    --extra-ldflags="$ADDI_LDFLAGS" \
    $ADDITIONAL_CONFIGURE_FLAG
make clean
make
make install
}
CPU=arm
PREFIX=$(pwd)/android/$CPU 
ADDI_CFLAGS="-marm"
build_one

We disabled static library and enabled shared library. Note that the build script is not optimized for a particular CPU. One should refer to ffmpeg documentation for detailed information about available configure options.

Once the file is saved, make sure the script is executable by the command below,

sudo chmod +x build_android.sh

Then execute the script by the command,

./build_android.sh

4. Build Output

The build can take a while to finish depending on your computer speed. Once it’s done, you should be able to find a folder $NDK/sources/ffmpeg-2.0.1/android, which contains arm/lib and arm/include folders.

The arm/lib folder contains the shared libraries, while arm/include folder contains the header files for libavcodec, libavformat, libavfilter, libavutil, libswscale etc.

Note that the arm/lib folder contains both the library files (e.g.: libavcodec-55.so) and symbolic links (e.g.: libavcodec.so) to them. We can remove the symbolic links to avoid confusion.

5. Make ffmpeg Libraries available for Your Projects

Now we’ve compiled the ffmpeg libraries and ready to use them. Android NDK allows us to reuse a compiled module through the import-module build command.

The reason we built our ffmpeg source code under $NDK/sources folder is that NDK build system will search for directories under this path for external modules automatically. To declare the ffmpeg libraries as reusable modules, we’ll need to add a file named $NDK/sources/ffmpeg-2.0.1/android/arm/Android.mk with the following content,

LOCAL_PATH:= $(call my-dir)
 
include $(CLEAR_VARS)
LOCAL_MODULE:= libavcodec
LOCAL_SRC_FILES:= lib/libavcodec-55.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)
 
include $(CLEAR_VARS)
LOCAL_MODULE:= libavformat
LOCAL_SRC_FILES:= lib/libavformat-55.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)
 
include $(CLEAR_VARS)
LOCAL_MODULE:= libswscale
LOCAL_SRC_FILES:= lib/libswscale-2.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)
 
include $(CLEAR_VARS)
LOCAL_MODULE:= libavutil
LOCAL_SRC_FILES:= lib/libavutil-52.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)
 
include $(CLEAR_VARS)
LOCAL_MODULE:= libavfilter
LOCAL_SRC_FILES:= lib/libavfilter-3.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)
 
include $(CLEAR_VARS)
LOCAL_MODULE:= libwsresample
LOCAL_SRC_FILES:= lib/libswresample-0.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)

Below is an example of how we can use the libraries in a Android project’s jni/Android.mk file,

LOCAL_PATH := $(call my-dir)
 
include $(CLEAR_VARS)
 
LOCAL_MODULE    := tutorial03
LOCAL_SRC_FILES := tutorial03.c
LOCAL_LDLIBS := -llog -ljnigraphics -lz -landroid
LOCAL_SHARED_LIBRARIES := libavformat libavcodec libswscale libavutil
 
include $(BUILD_SHARED_LIBRARY)
$(call import-module,ffmpeg-2.0.1/android/arm)

Note that we called import-module with the relative path to $NDK/sources for the build system to locate the reusable ffmpeg libraries.

win7下编译android版ffmpeg相关推荐

  1. win7 android 编译环境搭建,在Win7下配置Android开发环境

    在Win7下配置Android开发环境是本文要介绍的内容,主要是来了解并学习Android开发环境,具体关于Android开发环境的详解来看本文. 一.安装 JDK 下载JDK最新版本,下载地址如下: ...

  2. cocos2d-x在win7下的android交叉编译环境

    cocos2d-x在win7下的android交叉编译环境 前面把Visual Studio+Python开发环境配好了,但还没有讲如何在Android中使用创建好的项目,本篇博客介绍如何在win7下 ...

  3. Ubuntu 16.04 LTS下编译GPU版tensorflow

    Ubuntu 16.04 LTS下编译GPU版tensorflow 机器学习与数学 · 2016-06-10 13:51 作者: 比特小组 机器学习与数学出品 机器学习必然涉及到代码,本小组选择sci ...

  4. 安卓9.0刷linux,Ubuntu系统下编译Android 9.0系统

    8种机械键盘轴体对比 本人程序员,要买一个写代码的键盘,请问红轴和茶轴怎么选? 前言 在Ubuntu系统下编译Android系统.哎呀不知道是不是换了新电脑的缘故,这次编译居然从安装JDK和配置环境下 ...

  5. 【转】ubuntu 11.10(32位系统)下编译android源码

    原文网址:http://www.cnblogs.com/dwayne/archive/2011/11/16/2251734.html 本文介绍在ubuntu 11.10系统下编译android 2.3 ...

  6. Window下编译 64位ffmpeg 引入libx264及libmp3lame编码库

    好记性不如烂笔头,每次编译总要有些时间折腾,记录下编译过程,方便后来者. 本文 介绍windows下编译64位Ffmpeg库 (版本V4.02)如何引入libx264及libmp3lame(编码mp3 ...

  7. win7下编译python源码

    win7下编译python源码 下载源码: 打开网页:https://www.python.org/downloads/release/python-2710/ 下载完成后解压即可 查看文档: 其实最 ...

  8. 安卓和Linux动态库一样吗,在Linux环境下编译Android下的最新版ffmpeg+x264单个动态库(.so)...

    最近在mac下用ndk交叉编译最ffmpeg出问题,总是显示用系统的gcc而不是ndk的toolchain的交叉编译gcc来编译的.之前明明没问题的,可能是由于最近升级macOS导致的.由于对这方面实 ...

  9. windows 环境下,编译android 版opencv-4.5.5,并添加opencv_contrib-4.5.5 扩展模块

    参考博客:(130条消息) windows10 vs2019 版本:cmake将 opencv_contrib-4.5.5 扩展模块编译添加到 opencv-4.5.5 正式版中_Chhjnavy的博 ...

最新文章

  1. tftp怎么给服务器传文件,TFTP文件传输工具使用
  2. 重写toString()
  3. PySide2安装出现Could not find a version that satisfies和No matching distribution found for
  4. 西安电话面试:谈谈Vue数据双向绑定原理,看看你的回答能打几分
  5. nodeJs 操作数据库
  6. 安装Linux后的遗留问题
  7. 主动安全,新华三融合生态之力!
  8. 【ARM-Linux开发】linux下Eclipse进行C编程时动态链接库的生成和使用
  9. SQLServer 2008 技术内幕——T-SQL 查询 笔记
  10. 我可以在同一个catch子句中捕获多个Java异常吗?
  11. java开发总结_java开发几点总结
  12. 线性代数第八章 λ 矩阵 定理8 多项式最大公约数的性质
  13. 计算机应用项目教案,计算机应用基础2项目二--电子教案.doc
  14. 计算机文化基础十一版百度云,计算机文化基础(高职高专版 第十一版)第一章答案...
  15. Android Studio连接夜神模拟器
  16. Linux ipv6设置
  17. 六十秒倒计时android,如何用jquery实现六十秒倒计时
  18. 听我给你普及师父、师傅和讲师、教师的区别
  19. 看山不是山,看水不是水
  20. GitHub开源组件集锦

热门文章

  1. 信用卡消费挺进O2O市场
  2. 5种主流的PCBA(PCB)电路板测试方法
  3. DSFNet(Dynamic and Static Fusion Network for Moving Object Detection in Satellite Videos)代码调试
  4. 如何进行社群转化?有哪些策略?
  5. 什么是原子性,什么是原子性操作
  6. 高德地图四月新增数千条重要道路 数据能力持续领先
  7. pin function和pin group:iomuxc节点解析始末
  8. python-优矿-期权合成策略分析
  9. php解压base64编码,php base64编码和urlencode
  10. win10电脑如何录屏