Skip to content

Interface: Spec ​

TurboModule spec for the native VideoTrim module, and the type of the package's default export.

Prefer the named functions (they fill in defaults and convert colors) for calling methods. Use the on* emitters on the default export to subscribe to editor events on the New Architecture; see VideoTrimEventMap for the payloads.

Extends ​

  • TurboModule

Properties ​

PropertyModifierTypeDescription
onCancelreadonlyEventEmitter<void>Emitted when the user dismisses the editor without trimming.
onCancelTrimmingreadonlyEventEmitter<void>Emitted when the user cancels an in-progress trim operation.
onErrorreadonlyEventEmitter<{ errorCode: string; message: string; }>Emitted when loading, trimming or saving fails.
onFinishTrimmingreadonlyEventEmitter<{ duration: number; endTime: number; outputPath: string; startTime: number; }>Emitted when trimming completes successfully. All time values are in milliseconds.
onHidereadonlyEventEmitter<void>Emitted when the editor is hidden.
onLoadreadonlyEventEmitter<{ duration: number; }>Emitted when the media file has finished loading in the editor.
onLogreadonlyEventEmitter<{ level: string; message: string; sessionId: number; }>Emitted with FFmpeg log output during trimming.
onShowreadonlyEventEmitter<void>Emitted when the editor is shown.
onStartTrimmingreadonlyEventEmitter<void>Emitted when the trim operation starts.
onStatisticsreadonlyEventEmitter<{ bitrate: number; sessionId: number; size: number; speed: number; time: number; videoFps: number; videoFrameNumber: number; videoQuality: number; }>Emitted with FFmpeg encoding statistics during trimming.

Methods ​

cleanFiles() ​

ts
cleanFiles(): Promise<number>;

Delete all output files generated by past trim operations. Returns the number of files removed.

Returns ​

Promise<number>


closeEditor() ​

ts
closeEditor(): void;

Programmatically close the editor if it is currently open.

Returns ​

void


compress() ​

ts
compress(url, options): Promise<CompressResult>;

Compress a video file to reduce its size.

Parameters ​

ParameterType
urlstring
optionsCompressOptions

Returns ​

Promise<CompressResult>


deleteFile() ​

ts
deleteFile(filePath): Promise<boolean>;

Delete a single file at the given path. Resolves true on success. On Android, paths outside the library's output directories resolve false.

Parameters ​

ParameterType
filePathstring

Returns ​

Promise<boolean>


extractAudio() ​

ts
extractAudio(url, options): Promise<ExtractAudioResult>;

Extract the audio track from a video file into a separate audio file.

Parameters ​

ParameterType
urlstring
optionsExtractAudioOptions

Returns ​

Promise<ExtractAudioResult>


getFrameAt() ​

ts
getFrameAt(url, options): Promise<FrameResult>;

Extract a single frame from a video at the specified timestamp.

Parameters ​

ParameterType
urlstring
optionsFrameExtractionOptions

Returns ​

Promise<FrameResult>


isValidFile() ​

ts
isValidFile(url): Promise<FileValidationResult>;

Check whether the given URL points to a valid audio or video file.

Parameters ​

ParameterType
urlstring

Returns ​

Promise<FileValidationResult>


listFiles() ​

ts
listFiles(): Promise<string[]>;

List all output files generated by past trim operations.

Returns ​

Promise<string[]>


merge() ​

ts
merge(urls, options): Promise<MergeResult>;

Merge multiple media files into a single file. Headless only, no editor UI.

Parameters ​

ParameterType
urlsreadonly string[]
optionsMergeOptions

Returns ​

Promise<MergeResult>


mixAudio() ​

ts
mixAudio(
   videoPath, 
   audioPath, 
   options
): Promise<MixAudioResult>;

Mix (or replace) an external audio track into a video. Headless only, no editor UI. The video stream is copied unchanged; only audio is re-encoded.

Parameters ​

ParameterType
videoPathstring
audioPathstring
optionsMixAudioOptions

Returns ​

Promise<MixAudioResult>


saveToDocuments() ​

ts
saveToDocuments(filePath): Promise<SaveToDocumentsResult>;

Present the system document picker to save a file to the user's chosen location.

Parameters ​

ParameterType
filePathstring

Returns ​

Promise<SaveToDocumentsResult>


saveToPhoto() ​

ts
saveToPhoto(filePath): Promise<SaveToPhotoResult>;

Save a file to the device's photo library. Requires photo library permission.

Parameters ​

ParameterType
filePathstring

Returns ​

Promise<SaveToPhotoResult>


share() ​

ts
share(filePath): Promise<ShareResult>;

Open the system share sheet for a file.

Parameters ​

ParameterType
filePathstring

Returns ​

Promise<ShareResult>


showEditor() ​

ts
showEditor(filePath, config): void;

Open the trimmer editor for the given video or audio file.

Parameters ​

ParameterType
filePathstring
configEditorConfig

Returns ​

void


toGif() ​

ts
toGif(url, options): Promise<GifResult>;

Convert a video segment to an animated GIF.

Parameters ​

ParameterType
urlstring
optionsGifOptions

Returns ​

Promise<GifResult>


trim() ​

ts
trim(url, options): Promise<TrimResult>;

Perform a headless trim (no UI) on the given URL with the specified options.

Parameters ​

ParameterType
urlstring
optionsTrimOptions

Returns ​

Promise<TrimResult>

Released under the MIT License.