Latest2.0
Homepagehttps://github.com/tanersener/mobile-ffmpeg
LicenseGPL-3.0
Platformsios 8.0, requires ARC
Authors

MobileFFmpeg

Source code and scripts to build FFmpeg for Android and IOS platforms

1. Features

  • Builds both Android and IOS
  • Supports

    • FFmpeg v3.4.x and v4.0.x releases
    • 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

  • Prebuilt binaries under JCenter and CocoaPods
  • Licensed under LGPL 3.0, can be customized to support GPL v3.0

    1.1 Android

  • Supports arm-v7a, arm-v7a-neon, arm64-v8a, x86 and x86_64 architectures
  • Creates Android archive with .aar extension

    1.2 IOS

  • Supports armv7, armv7s, arm64, i386 and x86_64 architectures
  • Builds with -fembed-bitcode flag
  • 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.

minmin-gplhttpshttps-gplfullfull-gpl
external
libraries
enabled
x264
xvidcore
gnutlsgnutls
x264
xvidcore
fontconfig
freetype
fribidi
gmp
gnutls
kvazaar
lame
libaom*
libass
libiconv
libilbc

libtheora
libvorbis
libvpx
libwebp
libxml2
opencore-amr
opus
shine
snappy

soxr**
speex
wavpack
fontconfig
freetype
fribidi
gmp
gnutls
kvazaar
lame
libaom*
libass
libiconv
libilbc

libtheora
libvorbis
libvpx
libwebp
libxml2
opencore-amr
opus
shine
snappy

soxr*
speex
wavpack
x264

xvidcore*

* – Supported since v1.1

** – Supported since v2.0

2.1 Android

  1. Add MobileFFmpeg dependency from jcenter()

    dependencies {`
        implementation 'com.arthenica:mobile-ffmpeg-full:2.0'
    }
  2. 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

  3. Add MobileFFmpeg pod to your Podfile

    pod 'mobile-ffmpeg-full', '~> 2.0'
  4. Create and execute commands using the following Objective-C example.

    #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 %dn", 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.x is the current stable, includes FFmpeg v3.4.2

  • MobileFFmpeg v2.x is the next stable, includes FFmpeg v4.0.1

4. Building

4.1 Prerequisites

  1. 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.

  2. 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
  3. 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.

8. See Also

Latest podspec

{
    "name": "mobile-ffmpeg-full-gpl",
    "version": "2.0",
    "summary": "Mobile FFmpeg Full GPL Dynamic Framework",
    "description": "Includes FFmpeg v4.0.1 with fontconfig v2.13.0, freetype v2.9, fribidi v1.0.4, gmp v6.1.2, gnutls v3.5.18, kvazaar v1.2.0, libiconv v1.15, lame v3.100, libaom v2018.06.27-snashot, libass v0.14.0, libilbc v2.0.2, libtheora v1.1.1, libvorbis v1.3.6, libvpx v1.7.0, libwebp v1.0.0, libxml2 v2.9.8, opencore-amr v0.1.5, opus v1.2.1, shine v3.1.1, snappy v1.1.7, soxr v0.1.3, speex v1.2.0, wavpack v5.1.0, x264 v20180627-2245-stable and xvidcore v1.3.5 libraries enabled.",
    "homepage": "https://github.com/tanersener/mobile-ffmpeg",
    "authors": {
        "Taner Sener": "[email protected]"
    },
    "license": {
        "type": "GPL-3.0",
        "file": "mobileffmpeg.framework/LICENSE"
    },
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "ios": {
        "frameworks": [
            "Foundation",
            "AudioToolbox",
            "CoreImage"
        ],
        "libraries": [
            "z",
            "bz2"
        ],
        "vendored_frameworks": [
            "mobileffmpeg.framework",
            "libavcodec.framework",
            "libavdevice.framework",
            "libavfilter.framework",
            "libavformat.framework",
            "libavutil.framework",
            "libswresample.framework",
            "libswscale.framework"
        ]
    },
    "source": {
        "http": "https://www.dropbox.com/s/lptgi14km73q032/mobile-ffmpeg-full-gpl-2.0-ios-framework.zip"
    }
}

Pin It on Pinterest

Share This