Android Videokit

This is a repository to make it relatively simple to fetch and build the latest FFMPEG and libx264 to run on Android, using the Android NDK. It differs from most of the other NDK FFMPEG building packages in that it uses configure and make to build the libraries, and only a very small Android.mk file to pack it into a shared library, rather than a large handful of custom Android.mk scripts (there are still a few script files but most of them are pretty small or are lists of configure options). Big custom Android.mk files tend to break as soon as any files move around in the FFMPEG project, whereas here it should keep working with the latest libraries.

I haven’t committed the build scripts yet so at the moment it’s just got a couple of submodules that will fetch the two libraries for you.

How to build it

  1. Run ./init-submodules.sh to pull in the FFMPEG and libx264 submodules.
  2. cd jni
  3. Edit settings.sh to set NDK to the path of your Android NDK.
  4. Run ./create_toolchain.sh to install a local copy of the standalone toolchain
  5. Run ./config_make_everything.sh to configure and make libx264 and FFMPEG.
  6. ndk-build (make sure the NDK is in your $PATH)
  7. If all is well, you should find libs/armeabi/videokit.so.

You can edit jni/videokit/videokit_interface.c to do whatever you want with the built libraries – if you make any changes to it, just run ndk-build to link it together with the static libraries.

Options

  • minimal_featureset – on by default – only compiles in a small number of codecs (specifically, JPEG decoding and x264 encoding). Change to 0 in settings.sh if you want everything, or just add whatever configure flags you like to pick the codecs and things that are useful to you.
  • If you have already created a standalone toolchain, just edit settings.sh to make the PATH point at its bin directory. Then you don’t need to run create_toolchain.sh. If you have compilation problems, it’s worth making a fresh toolchain in case you’re using a slightly older version.