• Stars
    star
    661
  • Rank 68,192 (Top 2 %)
  • Language
    C
  • Created over 11 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

FFmpegMediaPlayer can be used to control playback of audio/video files and streams.

FFmpegMediaPlayer

View the project page here.

Donations

Donations can be made via PayPal:

This project needs you! If you would like to support this project's further development, the creator of this project or the continuous maintenance of this project, feel free to donate. Your donation is highly appreciated (and I love food and coffee). Thank you!

PayPal

Overview

FFmpegMediaPlayer is a reimplementation of Android's MediaPlayer class. The FFmpegMediaPlayer class provides a unified interface for playing audio files and streams.

This project uses FFmpeg version 4.2.2.

Key Features:

  • ARMv7, x86, x86_64 and ARM_64 support (Note: ARM and MIPS aren't supported as of version 1.0.4)

  • Support for API 16+

  • Support for additional formats and protocols not provided by Android's MediaPlayer class

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 FMP in your application (Android Studio)

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

dependencies {
    implementation 'com.github.wseemann:FFmpegMediaPlayer-core:1.0.5'
    implementation 'com.github.wseemann:FFmpegMediaPlayer-native:1.0.5'
}

Optionally, to support individual ABIs:

dependencies {
    implementation 'com.github.wseemann:FFmpegMediaPlayer-core:1.0.5'
    implementation 'com.github.wseemann:FFmpegMediaPlayer-native-armeabi-v7a:1.0.5'
    implementation 'com.github.wseemann:FFmpegMediaPlayer-native-x86:1.0.5'
    implementation 'com.github.wseemann:FFmpegMediaPlayer-native-x86_64:1.0.5'
    implementation 'com.github.wseemann:FFmpegMediaPlayer-native-arm64-v8a:1.0.5'
}

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

[Prebuilt AARs] (https://github.com/wseemann/FFmpegMediaPlayer/releases/download/v1.0.4/prebuilt-aars.zip)

(with HTTPS support)

[Prebuilt AARs with HTTPS] (https://github.com/wseemann/FFmpegMediaPlayer/releases/download/v1.0.3/prebuilt-aars-with-https.zip)

Demo Application

A sample application that makes use of FFmpegMediaPlayer can be downloaded [here] (https://github.com/wseemann/FFmpegMediaPlayer/blob/master/FMPDemo.apk?raw=true). 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

FFmpegMediaPlayer 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 the modules created by the build process and checked them in at: https://github.com/wseemann/FFmpegMediaPlayer/releases/download/v1.0.3/prebuilt-aars.zip. 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 FFmpegMediaPlayer/fmp-library. Once this step is complete you can use the library. If you want to compile the modules yourself follow the build 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/FFmpegMediaPlayer.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 root project 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:

sdk.dir=<path to SDK>
ndk.dir=<path to NDK>

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

sdk.dir=/Users/wseemann/Library/Android/sdk

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

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

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

Usage

Sample code:

FFmpegMediaPlayer mp = new FFmpegMediaPlayer();
mp.setOnPreparedListener(new FFmpegMediaPlayer.OnPreparedListener() {
		
    @Override
    public void onPrepared(FFmpegMediaPlayer mp) {
        mp.start();			
    }
});
mp.setOnErrorListener(new FFmpegMediaPlayer.OnErrorListener() {
		
    @Override
    public boolean onError(FFmpegMediaPlayer mp, int what, int extra) {
        mp.release();
        return false;
    }
});
	
try {
    mp.setDataSource("<some path or URL>");
    mp.prepareAsync();
} catch (IllegalArgumentException e) {
    e.printStackTrace();
} catch (SecurityException e) {
    e.printStackTrace();
} catch (IllegalStateException e) {
    e.printStackTrace();
} catch (IOException e) {
    e.printStackTrace();
}

FFmpeg

This software uses code from FFmpeg licensed under the LGPLv2.1 and its source can be downloaded here. It also uses code from SDL licensed under the zlib license.

License

FFmpegMediaPlayer: A unified interface for playing audio files and streams.

Copyright 2022 William Seemann

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

More Repositories

1

FFmpegMediaMetadataRetriever

FFmpegMediaMetadataRetriever provides a unified interface for retrieving frame and meta data from an input media file.
C
1,679
star
2

RoMote

Open source Roku remote. Turn your Android Device into a control center for your Roku Player and Roku TV.
Java
75
star
3

ServeStream

Streaming Media Player for Android
C
36
star
4

RoMote-PrivateListening

Roku remote plugin to enable private listening.
20
star
5

JavaPlaylistParser

Java based playlist parser
Java
18
star
6

RPListening

RPListening is an Open Source desktop client for Roku private listening.
Java
12
star
7

FFmpegMediaMetadataRetriever-iOS

Port of FFmpegMediaMetadataRetriever for iOS. FFmpegMediaMetadataRetriever provides a unified interface for retrieving frame and meta data from an input media file.
C
11
star
8

Jaku

A Java based wrapper for the Roku External Control Protocol (ECP).
Java
8
star
9

AntennaPod-AlarmClock

Java
1
star
10

Spotify-Bluetooth-App-Remote-Android

Manages audio playback via the Spotify Music app by routing Bluetooth commands to the Spotify App Remote SDK.
1
star
11

Jaku-WebSocket

A Java wrapper for the Roku External Control API using WebSockets
Java
1
star
12

DeskClock

AOSP Desk Clock
Java
1
star
13

MerryChristmas

Java
1
star
14

TBAWebScraper

A Java based web scraper to extract tournament data from http://www.tbasanctioning.org/
Java
1
star
15

UICombatSchedule

UICombatSchedule provides the combat room schedule as it is currently posted on the door at the University of Illinois Activities and Recreation Center (ARC).
Java
1
star
16

crinkle-crinkle-android

Open source Android application to calculate how much wrapping paper you need to wrap a present based off its dimensions.
HTML
1
star