Introduction
react-native-media-transformer provides native video compression and editing for React Native on Android and iOS.
Resize and trim videos, choose H.264 or HEVC, control audio, inspect metadata, and generate JPEG thumbnails. Media is processed on device using Android Media3 and iOS AVFoundation.
Android API 24+ and iOS 15.1+, or your React Native version’s higher minimum. Expo requires a development build. Expo Go and web processing are unsupported.
Installation
npm install react-native-media-transformer@0.1.0 react-native-nitro-modules@^0.37.1
cd ios && pod installRebuild your native app after installation. See installation requirements for compatibility details.
First export
Pass a readable video URI from your app’s picker or storage integration. The returned value is an absolute path to an MP4 in the app cache.
import { compress } from 'react-native-media-transformer';
export async function compressVideo(inputUri: string) {
try {
const outputPath = await compress(
inputUri,
{ quality: 'medium', maxHeight: 720 },
(progress) => console.log(Math.round(progress * 100))
);
return outputPath;
} catch (error) {
console.error('Compression failed:', error);
return null;
}
}The default output uses H.264 video and AAC audio when present. Add file:// when a display component requires a file URI, and copy cached files to permanent storage to keep them.
Next steps
- Quick start — compress a video, inspect its metadata, and create a thumbnail.
- Compression — resize, trim, choose codecs, and configure audio.
- React hook — add progress and cancellation to a component.
- TypeScript reference — explore every public export.