Skip to content

Getting Started

LucQuebec edited this page Jul 12, 2026 · 4 revisions

Getting Started

1. Add the dependency for your artifact and line

Every original FFmpegKit artifact name is free on Maven Central — pick the smallest one that covers the codecs your app needs (see Compatibility for the full matrix), then pick your FFmpeg line (8.1/7.1/6.0). Always pin the exact version; never + or latest.

repositories {
    mavenCentral()
}

dependencies {
    // ffmpeg-kit-full covers almost everyone (audio + video + https codecs)
    implementation 'dev.ffmpegkit-maintained:ffmpeg-kit-full:8.1.7'

    // or a smaller variant to shrink your APK:
    // implementation 'dev.ffmpegkit-maintained:ffmpeg-kit-https:8.1.7'
    // implementation 'dev.ffmpegkit-maintained:ffmpeg-kit-audio:8.1.7'
    // implementation 'dev.ffmpegkit-maintained:ffmpeg-kit-video:8.1.7'
    // implementation 'dev.ffmpegkit-maintained:ffmpeg-kit-min:8.1.7'

    // or a -gpl variant for x264/x265 (GPL-3.0 — see Licensing):
    // implementation 'dev.ffmpegkit-maintained:ffmpeg-kit-full-gpl:8.1.7'
}

Swap 8.1.7 for 7.1.6 or 6.0.3 to pick the 7.1 or 6.0 line instead — same artifact names, different version.

Pro (WhisperKit on-device speech recognition, OCR, audio fingerprinting — jokobee.com/ffmpegkit): download the .aar and add it as a local dependency:

repositories {
    flatDir {
        dirs 'libs'
    }
}

dependencies {
    implementation(name: "ffmpeg-kit-release", ext: "aar")
    implementation("androidx.annotation:annotation:1.7.1")
    implementation("com.arthenica:smart-exception-java:0.2.1")
}

Drop the downloaded .aar into your module's libs/ folder first.

2. Run a synchronous command

import com.arthenica.ffmpegkit.FFmpegKit;
import com.arthenica.ffmpegkit.FFmpegSession;
import com.arthenica.ffmpegkit.ReturnCode;

FFmpegSession session = FFmpegKit.execute("-i file1.mp4 -c:v mpeg4 file2.mp4");

if (ReturnCode.isSuccess(session.getReturnCode())) {
    // SUCCESS
} else if (ReturnCode.isCancel(session.getReturnCode())) {
    // CANCELLED
} else {
    // FAILURE
    Log.d(TAG, String.format("Command failed with state %s and rc %s.%s",
        session.getState(), session.getReturnCode(), session.getFailStackTrace()));
}

3. Run an asynchronous command

FFmpegKit.executeAsync("-i file1.mp4 -c:v mpeg4 file2.mp4", session -> {
    SessionState state = session.getState();
    ReturnCode returnCode = session.getReturnCode();
    Log.d(TAG, String.format("FFmpeg process exited with state %s and rc %s.%s",
        state, returnCode, session.getFailStackTrace()));
});

The package name and class/method signatures are unchanged from upstream com.arthenica.ffmpegkit — if you're moving from the old Maven Central artifacts, see Migration instead of rewriting call sites.

For the full API surface (FFprobe, media info, callbacks, cancellation, session history), see API Usage.

Clone this wiki locally