Skip to main content
react-native-media-transformerv0.1.0
Getting startedIntroduction

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.

Platform requirements

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

Terminal
npm install react-native-media-transformer@0.1.0 react-native-nitro-modules@^0.37.1
cd ios && pod install

Rebuild 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.

TypeScript
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