How to Configuration FFmpeg support to Android Application ?

April 08, 2019 , , , 0 Comments

Hello Friends,

Today we Check About FFMPEG library integration,

1.Extract the project achieve, and import module the ffmpeg4android_lib (ffmpeg4android_lib is under the ffmpeg4android_demo_studio folder) to your project.

* In-case you don’t see the module in you project, add it manually to your project setting gradle:

include 'ffmpeg4android_lib'

and click the sync button.

2.Add the needed Permissions:

         <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
         <uses-permission android:name="android.permission.WAKE_LOCK" />
         to your project Manifest file.

You need to add runtime permissions:
  Call the method: GeneralUtils.checkForPermissionsMAndAbove(Main.this, false);
  On your main activity onCreate method, or add the above 2 permissions to your existing runtime permission method.

3.  Add to your App Module build.gradle this:

defaultConfig {
  applicationId "com.examples.ffmpeg4android_demo"
  minSdkVersion 19
  targetSdkVersion 27
  ndk {
      abiFilter "armeabi-v7a"

For Android Studio 3.x:

dependencies {
  implementation project(':ffmpeg4android_lib')

In case the ffmpeg4andoid_lib is not under your project folder,
Add this to your setting.gradle (set the correct path):
include 'ffmpeg4android_lib'
project(':ffmpeg4android_lib').projectDir = new File('sdcard/ffm/ffmpeg4android_lib')

For Android Studio 2.x:
dependencies {
  compile project(':ffmpeg4android_lib')

4. To your add this:


5. To call ffmpeg4android add to your code (activity, service , fragment or any over java object) :

                       GeneralUtils.checkForPermissionsMAndAbove(Main.this, true);
LoadJNI vk = new LoadJNI();
       try {
            String workFolder = getApplicationContext().getFilesDir().getAbsolutePath();
            String[] complexCommand = {"ffmpeg","-i", "/sdcard/videokit/in.mp4"};
   , workFolder , getApplicationContext());
            Log.i("test", "ffmpeg4android finished successfully");
        } catch (Throwable e) {
            Log.e("test", "vk run exception.", e);

  Make sure /sdcard/videokit/in.mp4 exists on your device sdcard, and you gave permissions to access it (step 2),
  Then run the app to your device.
  You should see ffmpeg4android finished successfully in your log (test tag).

Android Code :


Some say he’s half man half fish, others say he’s more of a seventy/thirty split. Either way he’s a fishy bastard. Google


Popular Posts

Contact Form


Email *

Message *