Using FFMPEG library for video compression on Android

Issue

I am trying to use FFMPEG library for Video compression on Android.

I’ve compiled the library using : http://bambuser.com/opensource and https://www.quora.com/What-are-the-steps-for-integrating-FFMPEG-on-Android

Now next step is NDK build of this. But I am not sure what all will go as LOCAL_SRC_FILES, LOCAL_LDLIBS and LOCAL_C_INCLUDES.

Apart from that what function should be called for compression in this library.

Please suggest.

Solution

For ffmpeg use on Android (or other platforms) there are a number of common approachs you can take:

  • invoke the command line from your program via EXEC command (has some limitations and drawbacks)
  • use a wrapper around the ffmpeg command line C program
  • Directly use the ffmpeg libraries, or more accurately the libraries that ffmpeg uses

The wrapper approach may be the easiest is you simply want to get the functionality working quickly.

There are several fairly well used wrappers available on GitHub – the ones below are particularly well featured and documented (note, I have not used these as they were not so mature when I was looking at this previously, but if I was doing something like this again now I would definitely build on one of these):

Using one of the well supported and used libraries will take care of some common issues that you might otherwise encounter – having to load different binaries for different processor types, and some tricky issues with native library reloading to avoid crashes on subsequent invocations of the wrapper.

Because this approach uses the standard ffmpeg cmd line syntax for commands it also means you should be able to search and find help easily on multiple different operations (as anyone using ffmpeg in ‘normal’ model will use the same syntax for the ffmpeg command itself).

Answered By – Mick

Leave a Comment