React Native FFmpeg π₯β‘
The ultimate zero-configuration FFmpeg solution for React Native and Expo projects.
This package combines ffmpeg-kit-react-native with all necessary fixes and dependencies, providing a single-install solution that just works.
π Features
- β
Complete FFmpeg functionality - All features from ffmpeg-kit-react-native
- β
Zero configuration - No manual setup required
- β
Automatic dependency resolution - Includes smart-exception-java fix
- β
Android & iOS support - Works on both platforms
- β
Expo compatibility - Perfect for Expo projects
- β
Drop-in replacement - Same API as original ffmpeg-kit-react-native
π¦ Installation
That's it! One command:
npm install @sheehanmunim/react-native-ffmpeg
No more:
- β Manual dependency fixes
- β Gradle configuration
- β JAR file copying
- β Maven repository setup
- β Build failures
π― Usage
Use exactly the same API as the original ffmpeg-kit-react-native:
import FFmpegKit from "@sheehanmunim/react-native-ffmpeg";
FFmpegKit.execute("-i input.mp4 -c:v libx264 output.mp4").then((session) => {
const returnCode = session.getReturnCode();
if (returnCode.isValueSuccess()) {
console.log("FFmpeg process completed successfully");
}
});
π§ What's Included
Core Functionality
- Full FFmpeg command execution
- Session management
- Media information extraction
- Multiple output formats
- Hardware acceleration support
Auto-Applied Fixes
- smart-exception-java - Resolves Android compilation errors
- Maven repository setup - Ensures dependency resolution
- Gradle configuration - Automatic build.gradle modification
- JAR fallback - Local JAR files as backup
Platform Support
- Android - All architectures (arm64-v8a, armeabi-v7a, x86, x86_64)
- iOS - All architectures (arm64, x86_64)
- Expo - Full compatibility with Expo development workflow
π― Migration Guide
From ffmpeg-kit-react-native
Before:
{
"dependencies": {
"ffmpeg-kit-react-native": "6.0.2"
}
}
After:
{
"dependencies": {
"@sheehanmunim/react-native-ffmpeg": "6.0.3"
}
}
Then update your imports:
import FFmpegKit from "ffmpeg-kit-react-native";
import FFmpegKit from "@sheehanmunim/react-native-ffmpeg";
π Quick Start
-
Install:
npm install @sheehanmunim/react-native-ffmpeg
-
Use immediately:
import FFmpegKit from "@sheehanmunim/react-native-ffmpeg";
FFmpegKit.execute("-version").then((session) => {
console.log("FFmpeg version:", session.getOutput());
});
-
Build and run:
npx expo run:android
npx expo run:ios
ποΈ How It Works
This package:
- Wraps ffmpeg-kit-react-native - Provides 100% API compatibility
- Auto-detects your project - Finds React Native/Expo projects automatically
- Applies fixes during install - Postinstall script handles all configuration
- Bundles dependencies - Includes smart-exception-java and other fixes
- Validates setup - Ensures everything is configured correctly
π Troubleshooting
Build Still Failing?
The package automatically handles 99% of issues, but if you still have problems:
-
Clean and rebuild:
cd android && ./gradlew clean && cd ..
npx expo run:android
-
Check the logs - Installation should show:
π FFmpeg Kit React Native Complete - Setting up...
β
Added smart-exception-java dependency
β
Added mavenLocal repository
π Setup finished!
-
Manual verification:
Check if android/app/build.gradle contains:
dependencies {
implementation 'com.arthenica:smart-exception-java:0.2.1'
// ... other dependencies
}
Still Need Help?
Create an issue with:
- Your
package.json
- Your
android/app/build.gradle
- Full error logs
- Platform (Android/iOS/Expo)
π Requirements
- React Native >= 0.60.0
- Node.js >= 12.0.0
- Android API Level 21+ (Android 5.0+)
- iOS 12.4+
π― Examples
Video Compression
import FFmpegKit from "@sheehanmunim/react-native-ffmpeg";
const compressVideo = async (inputPath, outputPath) => {
const command = `-i ${inputPath} -c:v libx264 -crf 23 -c:a aac -b:a 128k ${outputPath}`;
const session = await FFmpegKit.execute(command);
const returnCode = session.getReturnCode();
if (returnCode.isValueSuccess()) {
console.log("Video compressed successfully!");
} else {
console.error("Compression failed");
}
};
import FFmpegKit from "@sheehanmunim/react-native-ffmpeg";
const extractAudio = async (videoPath, audioPath) => {
const command = `-i ${videoPath} -vn -acodec copy ${audioPath}`;
await FFmpegKit.execute(command);
};
Get Media Information
import { FFprobeKit } from "@sheehanmunim/react-native-ffmpeg";
const getMediaInfo = async (filePath) => {
const session = await FFprobeKit.getMediaInformation(filePath);
const mediaInformation = session.getMediaInformation();
console.log("Duration:", mediaInformation.getDuration());
console.log("Format:", mediaInformation.getFormat());
};
π License
LGPL-3.0 (same as original ffmpeg-kit-react-native)
π Credits
- FFmpeg - The amazing multimedia framework
- Arthenica - Original ffmpeg-kit creators (now retired)
- Community - For keeping FFmpeg alive in React Native
π Enjoy zero-configuration FFmpeg in React Native!