Thumbnails
createThumbnail(inputUri, options?): Promise<ThumbnailResult> independently writes a JPEG, returning { path: string, width: number, height: number }. path is an absolute cache path; dimensions describe the actual JPEG with source orientation applied.
Option | Default | Behavior |
|---|---|---|
|
| Seconds from source start; must be before source end. |
| Source dimensions | Integer bounding limits, 2–16384. Keeps aspect ratio without upscaling. |
|
| JPEG quality from 0 to 1. |
| Unique name | Filename ending in |
|
| Replace an existing thumbnail only after successful creation. |
time is a finite value from 0–2147483 seconds and must be before source end. JPEG dimensions retain aspect ratio without upscaling and do not use the video's even-pixel rule. Numeric JPEG quality is different from compression preset names. JPEG has no transparency.
import {
createThumbnail,
getVideoMetadata,
} from "react-native-media-transformer";
export async function makeVideoPreview(inputUri: string) {
const video = await getVideoMetadata(inputUri);
const image = await createThumbnail(inputUri, {
time: Math.min(1, video.duration / 2),
maxWidth: 480,
maxHeight: 320,
quality: 0.8,
});
return { video, image, imageUri: `file://${image.path}` };
}Call this helper with an accepted video URI and handle its returned promise's rejection. For a trimmed output, the thumbnail timestamp is relative to that output clip, not the original timeline. The decoder chooses a frame at or near the timestamp; exact-frame selection is not guaranteed and some timestamps can reject.