expo-ffmpeg
v0.0.13
Published
FFmpeg Kit for React Native/Expo with pre-configured binaries and Expo config plugin
Maintainers
Readme
expo-ffmpeg
FFmpeg Kit for React Native/Expo with pre-configured full-gpl binaries and Expo config plugin.
This is a fork of ffmpeg-kit-react-native with:
- Pre-patched configuration for
full-gplbinaries - Bundled Expo config plugin for automatic setup
- Utility class for common FFmpeg operations
Features
- Includes both
FFmpegandFFprobe - Supports both
AndroidandiOS - FFmpeg
v6.0 - Full GPL license with all codecs enabled
- 25+ external libraries including x264, x265, and more
Installation
yarn add expo-ffmpegExpo Configuration
Add the plugin to your app.json or app.config.js:
{
"expo": {
"plugins": [
[
"expo-ffmpeg",
{
"iosUrl": "https://github.com/Daniel-Griffiths/expo-ffmpeg/releases/download/binaries/ffmpeg-kit-ios-full-gpl.zip",
"androidUrl": "https://github.com/Daniel-Griffiths/expo-ffmpeg/releases/download/binaries/ffmpeg-kit-android-full-gpl.aar"
}
]
]
}
}Then rebuild your app:
npx expo prebuild --cleanUsage
Basic FFmpeg Commands
import { FFmpegKit, ReturnCode } from 'expo-ffmpeg';
// Execute any FFmpeg command
const session = await FFmpegKit.execute('-i input.mp4 -c:v libx264 output.mp4');
const returnCode = await session.getReturnCode();
if (ReturnCode.isSuccess(returnCode)) {
console.log('Success!');
}FFmpeg Utility Class
The package includes a utility class with common operations:
import { FFmpeg } from 'expo-ffmpeg';
// Mux video and audio
const result = await FFmpeg.mux(videoPath, audioPath, outputPath);
// Download HLS stream
const result = await FFmpeg.downloadHls(hlsUrl, outputPath, (progress) => {
console.log(`Progress: ${progress}%`);
});
// Convert video
const result = await FFmpeg.convert(inputPath, outputPath, {
codec: 'libx264',
videoBitrate: '2M',
});
// Extract audio
const result = await FFmpeg.extractAudio(videoPath, audioPath, {
format: 'mp3',
});
// Trim video
const result = await FFmpeg.trim(inputPath, outputPath, '00:00:10', '00:00:30');
// Check if URL is HLS
if (FFmpeg.isHlsUrl(url)) {
// Handle HLS stream
}
// Get temp file path
const tempPath = FFmpeg.getTempPath('video', 'mp4');
// Cleanup files
await FFmpeg.cleanup(tempPath1, tempPath2);Credits
Based on ffmpeg-kit by ARTHENICA.
