Created
August 5, 2014 07:14
-
-
Save cyndibaby905/d8dc1a2324549c980fb6 to your computer and use it in GitHub Desktop.
Build ffmpeg on OS X 10.9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
此处主要参考 http://harryhsu.logdown.com/posts/198416-build-ffmpeg-on-mac-os-109 | |
根据我的编译过程做了适当修改 | |
1. Download NDK | |
https://developer.android.com/tools/sdk/ndk/index.html | |
我下载的版本是android-ndk-r10,不同的版本在下面的build脚中本需要修改的地方大致相同. | |
2. Download ffmpeg source code | |
下载 ffmpeg(http://www.ffmpeg.org/download.html) | |
推荐 git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg | |
3. Modify configure file | |
进入第2步colone下来的ffmpeg目录,编辑configure脚本,找到如下内容: | |
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)' | |
脚本会将编译出的库名字后面加上版本信息(e.g. libavcodec.a.55),Android并不支持这种格式,所以用下面的方式替代: | |
SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)' | |
LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"' | |
SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)' | |
SLIB_INSTALL_LINKS='$(SLIBNAME)' | |
4.Build ffmpeg | |
在ffmpeg目录下新增build_android.sh,输入以下内容: | |
#!/bin/bash | |
#此处是第1步下载的ndk位置 | |
NDK=$HOME/Documents/android-ndk-r10 | |
#我是用android-L编译的,也可以采用别的SDK | |
SYSROOT=$NDK/platforms/android-L/arch-arm/ | |
#根据安装的ndk版本不同,这里也需要作适当修改 | |
TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64 | |
function build_one | |
{ | |
./configure \ | |
--prefix=$PREFIX \ | |
--disable-shared \ | |
--enable-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 | |
修改脚本的文件属性: | |
sudo chmod +x build_android.sh | |
执行: | |
./build_android.sh | |
编译成功后,生成的库文件和头文件会放在ffmpeg/android/arm下面。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
得到的是.a文件,没有.so文件