Skip to main content
react-native-media-transformerv0.1.0
GuidesQuality presets

Quality presets

COMPRESSION_PRESETS contains frozen preset objects; both the top-level object and nested values are immutable.

Preset

Maximum width and height

Video bitrate

Audio bitrate

low

640 × 640

700000

64000

medium

1280 × 1280

2000000

128000

high

1920 × 1920

5000000

192000

A preset supplies only maxWidth, maxHeight, bitrate, and audioBitrate. Both dimensions apply, so portrait and landscape inputs share a maximum long edge. Explicit defined options override preset fields. undefined does not clear a preset value. Omit quality for source-based defaults with no preset size cap.

For example, { quality: 'medium', maxHeight: 720 } retains a width limit of 1280, sets a height limit of 720, and uses video/audio targets of 2000000/128000. A 720 × 1280 portrait source becomes approximately 404 × 720 after even-pixel rounding. Smaller sources are not enlarged.

TypeScript
import { compress } from "react-native-media-transformer";

export async function makeClip(inputUri: string) {
  try {
    return await compress(inputUri, {
      quality: "medium",
      codec: "hevc",
      startTime: 2,
      endTime: 12,
    });
  } catch (error) {
    console.error(error);
    return null;
  }
}

This example requires a source extending beyond 2 seconds. HEVC requires a supported device encoder. There is no automatic H.264 fallback; an app can catch the failure and explicitly retry with H.264.