MobileFFmpeg
FFmpeg for Android and IOS
1. Features
-
Use prebuilt binaries available under
JCenter/CocoaPodsor build your own version with external libraries you need -
Supports
-
Both Android and IOS
-
FFmpeg
v3.4.xandv4.0.xreleases -
23 external libraries.
fontconfig,freetype,fribidi,gmp,gnutls,kvazaar,lame,libaom,libass,libiconv,libilbc,libtheora,libvorbis,libvpx,libwebp,libxml2,opencore-amr,opus,shine,snappy,soxr,speex,wavpack -
2 external libraries with GPL license
x264,xvidcore
-
-
Exposes FFmpeg capabilities both directly from FFmpeg libraries and through MobileFFmpeg wrapper library
-
Creates shared libraries (.so for Android, .dylib for IOS)
-
Includes cross-compile instructions for 35 open-source libraries
expat,ffmpeg,fontconfig,freetype,fribidi,giflib,gmp,gnutls,kvazaar,lame,libaom,libass,libiconv,libilbc,libjpeg,libjpeg-turbo,libogg,libpng,libtheora,libuuid,libvorbis,libvpx,libwebp,libxml2,nettle,opencore-amr,opus,shine,snappy,soxr,speex,tiff,wavpack,x264,xvidcore -
Licensed under LGPL 3.0, can be customized to support GPL v3.0
1.1 Android
- Supports
arm-v7a,arm-v7a-neon,arm64-v8a,x86andx86_64architectures - Creates Android archive with .aar extension
1.2 IOS
- Supports
armv7,armv7s,arm64,i386andx86_64architectures - Built with
-fembed-bitcodeflag - Creates IOS dynamic universal (fat) library
- Creates IOS dynamic framework for IOS 8 or later
2. Using
Prebuilt libraries are available under Github, JCenter and CocoaPods
There are six different prebuilt packages. Below you can see which external libraries are enabled in each of them.
* - Supported since v1.1
** - Supported since v2.0
2.1 Android
-
Add MobileFFmpeg dependency from
jcenter()dependencies {` implementation 'com.arthenica:mobile-ffmpeg-full:2.0' } -
Use the following source code to execute commands.
import com.arthenica.mobileffmpeg.FFmpeg; int rc = FFmpeg.execute("-i", "file1.mp4", "-c:v", "libxvid", "file1.avi"); Log.i(Log.TAG, String.format("Command execution %s.", (rc == 0?"completed successfully":"failed with rc=" + rc));
2.2 IOS
-
Add MobileFFmpeg pod to your
Podfilepod 'mobile-ffmpeg-full', '~> 2.0' -
Create and execute commands using the following
Objective-Cexample.#import <mobileffmpeg/mobileffmpeg.h> NSString* command = @"-i file1.mp4 -c:v libxvid file1.avi"; NSArray* commandArray = [command componentsSeparatedByString:@" "]; char **arguments = (char **)malloc(sizeof(char*) * ([commandArray count])); for (int i=0; i < [commandArray count]; i++) { NSString *argument = [commandArray objectAtIndex:i]; arguments[i] = (char *) [argument UTF8String]; } int result = mobileffmpeg_execute((int) [commandArray count], arguments); NSLog(@"Process exited with rc %d\n", result); free(arguments);
2.3 Test Application
You can see how MobileFFmpeg is used inside an application by running test applications provided.
There is an Android test application under the android/test-app folder and an IOS test application under the
ios/test-app folder. Both applications are identical and supports command execution and video encoding.
3. Versions
-
MobileFFmpeg v1.xis the current stable, includesFFmpeg v3.4.2 -
MobileFFmpeg v2.xis the next stable, includesFFmpeg v4.0.1
4. Building
4.1 Prerequisites
-
Use your package manager (apt, yum, dnf, brew, etc.) to install the following packages.
autoconf automake libtool pkg-config curl cmake gcc gperf texinfo yasm nasm
Some of these packages are not mandatory for the default build. Please visit Android Prerequisites and IOS Prerequisites for the details.
-
Android builds require these additional packages.
- Android SDK 5.0 Lollipop (API Level 21) or later
- Android NDK r16b or later with LLDB and CMake
- gradle 4.4 or later
-
IOS builds need these extra packages and tools.
- IOS SDK 7.0.x or later
- Xcode 8.x or later
- Command Line Tools
- lipo utility
4.2 Build Scripts
Use android.sh and ios.sh to build MobileFFmpeg for each platform.
After a successful build, compiled FFmpeg and MobileFFmpeg libraries can be found under prebuilt directory.
Both android.sh and ios.sh can be customized to override default settings,
android.sh and
ios.sh wiki pages include all available build options.
4.2.1 Android
export ANDROID_NDK_ROOT=<Android NDK Path>
./android.sh
4.2.2 IOS
./ios.sh
4.3 GPL Support
Sincev1.1, it is possible to enable to GPL licensed libraries x264 and xvidcore from the top level build scripts.
Their source code is not included in the repository and downloaded when enabled.
4.4 External Libraries
build directory includes build scripts for external libraries. There are two scripts for each library, one for Android
and one for IOS. They include all options/flags used to cross-compile the libraries. ASM is enabled by most of them,
exceptions are listed under the ASM Support page.
5. Documentation
A more detailed documentation is available at Wiki.
6. License
This project is licensed under the LGPL v3.0. However, if source code is built using optional --enable-gpl flag or
prebuilt binaries with -gpl postfix are used then MobileFFmpeg is subject to the GPL v3.0 license.
Source code of FFmpeg and external libraries is included in compliance with their individual licenses.
strip-frameworks.sh script included and distributed is published under the Apache License version 2.0.
Digital assets used in test applications are published in the public domain.
Please visit License page for the details.
7. Contributing
If you have any recommendations or ideas to improve it, please feel free to submit issues or pull requests. Any help is appreciated.