Skip to main content
The Input class represents an input media file and provides methods for reading tracks, metadata, and computing file properties.

Constructor

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

Properties

Source
Returns the source from which this input file reads its data. This is the same source that was passed to the constructor.
boolean
True if the input has been disposed.

Methods

getFormat()

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()

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

getFirstTimestamp()

Returns the timestamp at which the input file starts. More precisely, returns the smallest starting timestamp among all tracks.

getTracks()

Returns the list of all tracks of this input file.

getVideoTracks()

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

getAudioTracks()

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

getPrimaryVideoTrack()

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

getPrimaryAudioTrack()

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

getMimeType()

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

getMetadataTags()

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

dispose()

Disposes this input and frees connected resources. When an input is disposed, ongoing read operations will be canceled, all future read operations will fail, any open decoders will be closed, and all ongoing media sink operations will be canceled. Disallowed and canceled operations will throw an InputDisposedError. You are expected not to use an input after disposing it. While some operations may still work, it is not specified and may change in any future update.

Errors

InputDisposedError

Thrown when an operation was prevented because the corresponding Input has been disposed.

Example