FFmpegMediaMetadataRetriever

FFmpegMediaMetadataRetriever is a reimplementation of Android's MediaMetadataRetriever class. The FFmpegMediaMetadataRetriever class provides a unified interface for retrieving frame and meta data from an input media file and uses FFmpeg as its backend.

Key Features:

Supported protocols:

  • file, http, https, mms, mmsh and rtmp

Supported formats (audio and video):

  • aac, acc+, avi, flac, mp2, mp3, mp4, ogg, 3gp and more!

Additional support for:

  • ICY Metadata (SHOUTcast metadata)

Using FMMR in your application (Android Studio)

Add the following maven dependency to your project's build.gradle file:

dependencies {
    compile 'com.github.wseemann:FFmpegMediaMetadataRetriever:1.0.14'
}

Optionally, to support individual ABIs:

dependencies {
    compile 'com.github.wseemann:FFmpegMediaMetadataRetriever-armeabi:1.0.14'
    compile 'com.github.wseemann:FFmpegMediaMetadataRetriever-armeabi-v7a:1.0.14'
    compile 'com.github.wseemann:FFmpegMediaMetadataRetriever-x86:1.0.14'
    compile 'com.github.wseemann:FFmpegMediaMetadataRetriever-mips:1.0.14'
    compile 'com.github.wseemann:FFmpegMediaMetadataRetriever-x86_64:1.0.14'
    compile 'com.github.wseemann:FFmpegMediaMetadataRetriever-arm64-v8a:1.0.14'
}

or, if your application supports individual architectures extract the appropriate AAR file into you projects "libs" folder:

Prebuilt AARs

(with HTTPS support)

Prebuilt AARs with HTTPS

Demo Application

A sample application that makes use of FFmpegMediaMetadataRetriever can be downloaded here. Note: The sample application is compiled with support for ALL available formats. This results in a larger library and APK. FFmpeg can be recompiled with a subset of codecs enabled for those wanting a smaller size.

Installation

FFmpegMediaMetadataRetriever relies on FFmpeg and native code. The build process
is complex and may be confusing for those unfamiliar the Android NDK. For this
reason I've precompiled AARs created by the build process and checked them
in here.
The modules are also included with the library. If you don't want to build the modules
you can simple unzip the prebuilt ones and copy them to your projects "libs" folder. (Note:
copy them to YOUR projects "libs" folder, NOT the "libs" folder located in
FFmpegMediaMetadataRetriever/fmmr-library. Once this step is complete you can use the
library (See: Installation in Eclipse (Kepler)). If you want to compile the modules yourself
follow the Ant instructions listed below before attempting to use the library.

Download and install the Android SDK.
Download the Android NDK.
Clone/Download/Fork the repo through GitHub or via (read-only)

git clone https://github.com/wseemann/FFmpegMediaMetadataRetriever.git

Android Studio (Gradle))

Note: The build instructions and scripts assume you are running Unix or Linux. Building
on other operating systems is currently not supported.

Execute the following in the FFmpegMediaMetadataRetriever/fmmr-library/
directory (assuming /path/to/android_sdk/tools is in your PATH):

android update project --path .

Open the newly created local.properties file and add the following lines:

ndk.dir=<path to NDK>

where is the path to your Android NDK, for example:

ndk.dir=/home/wseemann/Android/android-ndk-r11c

Note: If you wish to enable https support (for use with API 8+ only) navigate to FFmpegMediaMetadataRetriever/fmmr-library/ and execute

ant build-ffmpeg-with-ssl

To compile the library in Android Studio, highlight library in the project explorer and run Build->Make Module 'library'. This will also build the native FFmpeg binaries.

Usage

Sample code:

FFmpegMediaMetadataRetriever mmr = new FFmpegMediaMetadataRetriever();
mmr.setDataSource(mUri);
mmr.extractMetadata(FFmpegMediaMetadataRetriever.METADATA_KEY_ALBUM);
mmr.extractMetadata(FFmpegMediaMetadataRetriever.METADATA_KEY_ARTIST);
Bitmap b = mmr.getFrameAtTime(2000000, FFmpegMediaMetadataRetriever.OPTION_CLOSEST); // frame at 2 seconds
byte [] artwork = mmr.getEmbeddedPicture();

mmr.release();

FFmpeg

This software uses code of FFmpeg licensed under the LGPLv2.1 and its source can be downloaded here.

GitHub