Skip to content
This repository has been archived by the owner on Oct 7, 2021. It is now read-only.

Using MobileFFmpeg in Unity

Taner Şener edited this page Jul 26, 2020 · 3 revisions

1. Android

  • Download the latest mobile-ffmpeg-<package>-<version>.aar file from the Releases page and copy it under the <Your Unity Project Name>/Assets/Plugins/Android folder.

    • Please note that Main releases support API Level 24 and LTS releases support API Level 16.
  • Patch mobile-ffmpeg-<package>-<version>.aar file if necessary. The latest mobile-ffmpeg releases are already patched but to use older versions you need to perform the following steps.

    • Delete res folder inside the .aar file
    • Delete android:theme="@style/AppTheme" attribute from the AndroidManifest.xml inside the .aar file
  • Disable the handling of SIGXCPU signal by running the following code block.

        AndroidJavaObject paramVal = new AndroidJavaClass("com.arthenica.mobileffmpeg.Signal").GetStatic<AndroidJavaObject>("SIGXCPU");
        configClass.CallStatic("ignoreSignal", new object[] { paramVal });
  • Use the following code block to call execute method and run ffmpeg commands.
        AndroidJavaClass jc = new AndroidJavaClass("com.arthenica.mobileffmpeg.FFmpeg");
        int rc = jc.CallStatic<int>("execute", new object[] {"-version"});
	Debug.Log("FFmpeg ended with " + rc);
  • You can call other mobile-ffmpeg API methods using a similar approach.
	string output = jc.CallStatic<string>("getLastCommandOutput", new object[] {});
	Debug.Log("Output " + output);

2. iOS / tvOS

Unity Cloud Build does support importing Xcode frameworks. So it should be possible to import mobile-ffmpeg frameworks using the Xcode frameworks guide. Unfortunately, it is not tested and documented yet.

There are unofficial blogs about using Cocoapods under Unity. If you can make them work then you can import mobile-ffmpeg by adding mobile-ffmpeg dependency into your Podfile as described in README.

Clone this wiki locally