Compile ffmpeg for Android

转载地址:https://yesimroy.gitbooks.io/android-note/content/compile_ffmpeg_for_android.html

Before Continuing this page, if u want to enable x264, please complete building x264 using android toolchain first. Check this.

Please put x264 folder at same level of hierarchy with ffmpeg fodler

╭─yesimroy@RoyMBPR  ~/Documents/
╰─$ ls
x264 ffmpeg-3.0

This tutorial is for generating android jni needed ffmpeg shared libraries for platform (armeabi, armeabi-v7a, arm64-v8a, x86, x86_64, mips).

1. Download and Unzip ffmpeg

Download ffmpeg from the link, please check lib version first. It shows the description about the version of libries it has.

For ex, FFmpeg 3.0 "Einstein" includes the following library versions:


libavutil      55. 17.103
libavcodec     57. 24.102
libavformat    57. 25.100
libavdevice    57.  0.101
libavfilter     6. 31.100
libavresample   3.  0.  0
libswscale      4.  0.100
libswresample   2.  0.101
libpostproc    54.  0.100

2. Edit output shared library file name

For the output format like this libavcodec-55.so, which is accepted in Android. You need to edit ffmpeg/configure as follow:

Warning: Cause of Markdown double dollar sign ($) issue, the dollar sign $$ bellow should be correct into the right $$

Find these codes:

 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)'

And modify into these ones:

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. Download build scripts of ffmpeg & x264 for android ndk from my repository

Link to my ffmpeg + x264 build scripts repository

4. Copy build scripts into ffmpeg folder

Copy the scripts inside build-scripts-of-ffmpeg-x264-for-android-ndk-master/ffmpeg to your downloaded ffmpeg src code folder. Ex.

Here take ffmpeg-3.0 as an example.

cp build-scripts-of-ffmpeg-x264-for-android-ndk-master/ffmpeg/* ffmpeg-3.0/

Open text editor, check each build script, whether the ndk path and toolchain path are correct or not.

#check the paths bellow, make sure any words is correct.
#for ex. if you want to build shared libraries for arm64, the lowest platform level is 21. for 32 bits, usually i choose android-18. (as you want)
NDK=/Users/yesimroy/Library/Android/sdk/ndk-bundle
PLATFORM=$NDK/platforms/android-21/arch-arm64/
PREBUILT=$NDK/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64

5. Run the build-all script for generating all platform shared library

Run the build-all script and wait for it, you can check the console logs in case there is an error.

cd ffmpeg-3.0

./build_android_all.sh

6. After compiling success

After compiling success, you will see an folder called android including all platform libraries inside your ffmpeg folder.

╭─yesimroy@MBPR  ~/Documents/ffmpeg-3.0
╰─$ ls android
arm64-v8a  armeabi  armeabi-v7a  x86  x86_64  mips

References

  1. https://github.com/hrydgard/ppsspp-ffmpeg
  2. http://blog.csdn.net/myxuan475/article/details/48625823
  3. http://stackoverflow.com/questions/4119359/build-ffmpeg-on-osx
  4. http://blog.csdn.net/jinrall/article/details/50556328
  5. https://dl.dropboxusercontent.com/u/22605641/ffmpeg_android/main.html
  6. https://trac.ffmpeg.org/attachment/ticket/4928/build_ffmpeg.sh
  7. https://github.com/hrydgard/ppsspp-ffmpeg/tree/master/android
  8. http://vinsol.com/blog/2014/07/30/cross-compiling-ffmpeg-with-x264-for-android/
  9. http://codex.wiki/post/174761-227
  10. http://stackoverflow.com/questions/27421134/system-loadlibrary-couldnt-find-native-library-in-my-case
  11. https://github.com/ongakuer/javacpp-presets/blob/custom_ffmpeg/ffmpeg/cppbuild.sh
  12. http://m.blog.csdn.net/article/details?id=50500444
  13. http://www.pcpop.com/doc/2/2541/2541831.shtml
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值