This guide explains how to build and use a local version of ffmpeg-kit-react-native in a React Native project (MyApp), including .aar generation, dependency setup, and usage instructions.
mkdir 'my-project'
cd my-project
npx @react-native-community/cli init MyApp --pm yarn
git clone https://github.com/arthenica/ffmpeg-kit
Your directory layout should look like this:
~/my-project/
βββ MyApp/ # Your React Native app
βββ ffmpeg-kit/ # Cloned ffmpeg-kit repo
βββ react-native/
Follow pre-requisites: https://github.com/arthenica/ffmpeg-kit/blob/main/android/README.md
Navigate to the ffmpeg-kit repo and run:
./android.shTo build only for modern devices (arm64-v8a):
./android.sh \
--disable-arm-v7a \
--disable-arm-v7a-neon \
--disable-x86 \
--disable-x86-64Then copy the output:
mkdir ../MyApp/android/libs/
cp prebuilt/bundle-android-aar/ffmpeg-kit/ffmpeg-kit.aar ../MyApp/android/libs/ffmpeg-kit.aarDownload from:
Copy all .jar files into:
MyApp/android/libs/Make sure to include files like:
smart-exception-java-0.2.1.jarsmart-exception-common-0.2.1.jarsmart-exception-java9-0.2.1.jarsmart-exception-logback-0.2.1.jar
allprojects {
repositories {
google()
mavenCentral()
flatDir {
dirs "$rootDir/libs"
}
}
}repositories {
flatDir {
dirs "${rootProject.projectDir}/libs"
}
}
dependencies {
implementation("com.facebook.react:react-android")
implementation fileTree(dir: "$rootDir/libs", include: ["*.jar"])
implementation(name: 'ffmpeg-kit', ext: 'aar')
if (hermesEnabled.toBoolean()) {
implementation("com.facebook.react:hermes-android")
} else {
implementation jscFlavor
}
}remove repositories and dependencies section and replace with:
repositories {
google()
mavenCentral()
}
dependencies {
api 'com.facebook.react:react-native:+'
implementation(name: 'ffmpeg-kit', ext: 'aar')
}In MyApp/package.json:
"dependencies": {
"ffmpeg-kit-react-native": "../ffmpeg-kit/react-native"
}or...
yarn add '../ffmpeg-kit/react-native/'
Then run:
yarn installAdd the following line to App.tsx in MyApp
import { FFmpegKit } from 'ffmpeg-kit-react-native';
Start Metro Server:
In one terminal window:
npx react-native start --reset-cacheClean and Launch App:
In 2nd terminal window (takes a while to compile, so be patient):
cd android
./gradlew clean
cd ..
npx react-native run-androidIf you get no errors, then you've likely compiled the app with ffmpeg correctly.
Build .aar:
./android.shBuild for arm64-v8a only:
./android.sh \
--disable-arm-v7a \
--disable-arm-v7a-neon \
--disable-x86 \
--disable-x86-64Kill Metro server (if stuck):
lsof -i :8081
kill -9 <PID>Start Metro Server:
npx react-native start --reset-cacheClean and Launch App:
cd android
./gradlew clean
cd ..
npx react-native run-android