How to Build FFmpeg for Android

529人阅读 评论(0) 收藏 举报


For how to build ffmpeg 2.0.1 with NDK r9, please refer to:

ffmpeg is an open-source platform for recording, converting, playing and streaming video and audio. It includes libavcodec, a popular video/audio codec.

Several popular Android applications are built based on FFmpeg, including RockPlayer, MoboPlayer, acrMedia, vitalPlayer, V-Cut Express etc. If you’re developing multimedia applications that needs a video/audio codec, ffmpeg is a good choice.

This blog covers how to compile ffmpeg for Android, and next blog will cover how to use ffmpeg to build a simple application.

The steps below are done on Ubuntu 10.10, android NDK r5b, and ffmpeg 0.8. It should work on other versions of Android NDK and ffmpeg, but it may require minor changes.

0. Download Android NDK r5b

You can download the NDK here. Once downloaded, simply extract the file, and you’ll have a folder named android-ndk-r5b. You’ll need the folder location for configurations later.

1. Download Source Code for FFmpeg

You can download the source code from here. If you want to get the latest code, you can use git or svn, the link has detailed  instructions. But for this tutorial, the FFmpeg 0.8 “Love” release is downloaded.

After downloaded the source, extract it and you’ll have a folder named ffmpeg-0.8.

2. Build FFmpeg (The script is based on RockPlayer build script)

2.1 Copy and Paste the bash script from here to a text editor, and save it as under ffmpeg-0.8 folder.

Note that NDK location has to be changed according to your android-ndk-r5b folder location. In my machine, it’s at ~/Desktop/android/, so it’s set as


You may also need to adjust the PLATFORM based on which version of SDK you’re using, android-8 corresponds to android SDK 2.2.

The default configuration in the script disables a lot of stuff to speed up the build, you can change the configuration to suit your needs. Besides, you can compile for multiple hardware platforms, but here we only enable arm v7vfpv3 to speed up the build process.

2.2 Make sure the bash script is executable. Go to the ffmpeg-0.8 directory in terminal, then type the following command,

sudo chmod 755

2.3 Then execute the script, by typing the following command,


The compilation will take a while (several minutes or above depends on your machine) to finish.

Update for NDK-r6:

For android NDK-r6, the script might not work. You can try the scripthere.

Note that you may need to create ./android/armv7-a/ folder in the ffmpeg directory yourself. (Thanks to mgg28831 for this).

If you encounter permission denied error, you can try sudo ./

3. The Output of the Build

Once the script finishes execution, there’ll be a folder called android under ffmpeg-0.8 directory, which contains all the output of the build.

4. To be Continued

Once the library is compiled successfuly, the next step is to use it to build Android apps. This is covered in next blog, How to Build Android Apps Based on FFmpeg By an Example.


RockPlayer open source component:


Compiling Opencv2.3.1 with ffmpeg to read the MP4

编译条件主机(Host): Virtual box + Unbuntu12.04 单板机:Freescale imx6 交叉编译器版本:4.6.2 20110630 (不支持C11) cmak...
  • FreeApe
  • FreeApe
  • 2016年09月03日 00:25
  • 895

How to Build an Economic Model in Your Spare Time (如何利用业余时间建立经济模型)

如何利用业余时间建立经济模型 How to Build an Economic Model in Your Spare Time by Hal R. Varian UC Berkeley Decemb...
  • metababy
  • metababy
  • 2008年10月20日 21:25
  • 3202


  • AndrExpert
  • AndrExpert
  • 2017年06月27日 21:40
  • 1563

How to Build Android Applications Based on FFmpeg by An Example

转自: This...
  • hjwang1
  • hjwang1
  • 2013年12月20日 12:00
  • 788

How to Build ffmpeg with NDK r9

转自: This is a updated post for a previou...
  • hjwang1
  • hjwang1
  • 2013年12月20日 11:51
  • 733

Android FFmpeg 编译(2016,亲测)

Android FFmpeg的编译是通过jni调用ffmpeg库的前提。如果你要在android上使用ffmpeg,需要通ndk编译ffmpeg。然后才能在android项目中用jni来使用ffmpe...
  • zrbcsdn
  • zrbcsdn
  • 2016年04月12日 09:37
  • 2126


提示:如果Ubuntu中未搭建android studio、或对Linux系统操作不熟悉的,可拷贝ffmpeg相关文件到windows中进行后续开发。 新建Android项目,并创建一个ffmpegl...
  • qq137722697
  • qq137722697
  • 2017年12月16日 21:49
  • 402

Android ffmpeg+librtmp+speex交叉编译

Ubuntu 14 ndk r10b librtmp 2.4 speex 1.2rc2 ffmpeg 2.8.1 1、编译librtmp # This is the And...
  • fatiao101
  • fatiao101
  • 2015年10月26日 22:04
  • 1660

什么是 Nightly Build

  • forcoder
  • forcoder
  • 2009年12月26日 18:48
  • 2156

How to Build LineageOS rom for any android device Easily ! {Full guide}

How to Build LineageOS rom for any android device Easily ! {Full guide}
  • ztguang
  • ztguang
  • 2017年02月20日 12:22
  • 916
    访问量: 12万+
    积分: 1978
    排名: 2万+