Skip to content
Class

Input

Represents an input media file. This is the root object from which all media read operations start.

Used by

Type parameters

ts
Input<
	S extends Source = Source,
>

See Source.

Constructor

ts
constructor(
	options: InputOptions<S>,
): Input;

Creates a new input file from the specified options. No reading operations will be performed until methods are called on this instance.

See InputOptions.

Properties

source

ts
get source(): S;

Returns the source from which this input file reads its data. This is the same source that was passed to the constructor.

Methods

getFormat()

ts
getFormat(): Promise<InputFormat>;

Returns the format of the input file. You can compare this result directly to the InputFormat singletons or use instanceof checks for subset-aware logic (for example, format instanceof MatroskaInputFormat is true for both MKV and WebM).

computeDuration()

ts
computeDuration(): Promise<number>;

Computes the duration of the input file, in seconds. More precisely, returns the largest end timestamp among all tracks.

getTracks()

ts
getTracks(): Promise<InputTrack[]>;

Returns the list of all tracks of this input file.

See InputTrack.

getVideoTracks()

ts
getVideoTracks(): Promise<InputVideoTrack[]>;

Returns the list of all video tracks of this input file.

See InputVideoTrack.

getAudioTracks()

ts
getAudioTracks(): Promise<InputAudioTrack[]>;

Returns the list of all audio tracks of this input file.

See InputAudioTrack.

getPrimaryVideoTrack()

ts
getPrimaryVideoTrack(): Promise<InputVideoTrack | null>;

Returns the primary video track of this input file, or null if there are no video tracks.

See InputVideoTrack.

getPrimaryAudioTrack()

ts
getPrimaryAudioTrack(): Promise<InputAudioTrack | null>;

Returns the primary audio track of this input file, or null if there are no audio tracks.

See InputAudioTrack.

getMimeType()

ts
getMimeType(): Promise<string>;

Returns the full MIME type of this input file, including track codecs.

getMetadataTags()

ts
getMetadataTags(): Promise<MetadataTags>;

Returns descriptive metadata tags about the media file, such as title, author, date, or cover art.

See MetadataTags.

Released under the Mozilla Public License 2.0.