Skip to content
Class

Conversion

Represents a media file conversion process, used to convert one media file into another. In addition to conversion, this class can be used to resize and rotate video, resample audio, drop tracks, or trim to a specific time range.

Static methods

init()

ts
static init(
	options: ConversionOptions,
): Promise<Conversion>;

Initializes a new conversion process without starting the conversion.

See ConversionOptions.

Properties

discardedTracks

ts
readonly discardedTracks: DiscardedTrack[];

The list of tracks from the input file that have been discarded, alongside the discard reason.

See DiscardedTrack.

input

ts
readonly input: Input;

The input file.

See Input.

output

ts
readonly output: Output;

The output file.

See Output.

utilizedTracks

ts
readonly utilizedTracks: InputTrack[];

The list of tracks that are included in the output file.

See InputTrack.

Events

onProgress

ts
onProgress?: (progress: number) => unknown;

A callback that is fired whenever the conversion progresses. Returns a number between 0 and 1, indicating the completion of the conversion. Note that a progress of 1 doesn't necessarily mean the conversion is complete; the conversion is complete once execute() resolves.

In order for progress to be computed, this property must be set before execute is called.

Methods

execute()

ts
execute(): Promise<void>;

Executes the conversion process. Resolves once conversion is complete.

cancel()

ts
cancel(): Promise<void>;

Cancels the conversion process. Does nothing if the conversion is already complete.

Released under the Mozilla Public License 2.0.