Skip to content
Class

InputVideoTrack

Represents a video track in an input file.

Extends: InputTrack

Used by

Properties

codec

ts
get codec(): VideoCodec | null;

The codec of the track's packets.

See VideoCodec.

codedHeight

ts
get codedHeight(): number;

The height in pixels of the track's coded samples, before any transformations or rotations.

codedWidth

ts
get codedWidth(): number;

The width in pixels of the track's coded samples, before any transformations or rotations.

displayHeight

ts
get displayHeight(): number;

The height in pixels of the track's frames after rotation.

displayWidth

ts
get displayWidth(): number;

The width in pixels of the track's frames after rotation.

id

ts
get id(): number;

The unique ID of this track in the input file.

internalCodecId

ts
get internalCodecId(): string | number | Uint8Array<ArrayBufferLike> | null;

The identifier of the codec used internally by the container. It is not homogenized by Mediabunny and depends entirely on the container format.

This field can be used to determine the codec of a track in case Mediabunny doesn't know that codec.

  • For ISOBMFF files, this field returns the name of the Sample Description Box (e.g. 'avc1').
  • For Matroska files, this field returns the value of the CodecID element.
  • For WAVE files, this field returns the value of the format tag in the 'fmt ' chunk.
  • For ADTS files, this field contains the MPEG-4 Audio Object Type.
  • In all other cases, this field is null.

languageCode

ts
get languageCode(): string;

The ISO 639-2/T language code for this track. If the language is unknown, this field is 'und' (undetermined).

name

ts
get name(): string | null;

A user-defined name for this track.

rotation

ts
get rotation(): Rotation;

The angle in degrees by which the track's frames should be rotated (clockwise).

See Rotation.

timeResolution

ts
get timeResolution(): number;

A positive number x such that all timestamps and durations of all packets of this track are integer multiples of 1/x.

type

ts
get type(): TrackType;

The type of the track.

See TrackType.

Methods

getColorSpace()

ts
getColorSpace(): Promise<VideoColorSpaceInit>;

Returns the color space of the track's samples.

hasHighDynamicRange()

ts
hasHighDynamicRange(): Promise<boolean>;

If this method returns true, the track's samples use a high dynamic range (HDR).

getDecoderConfig()

ts
getDecoderConfig(): Promise<VideoDecoderConfig | null>;

Returns the decoder configuration for decoding the track's packets using a VideoDecoder. Returns null if the track's codec is unknown.

getCodecParameterString()

ts
getCodecParameterString(): Promise<string | null>;

Returns the full codec parameter string for this track.

canDecode()

ts
canDecode(): Promise<boolean>;

Checks if this track's packets can be decoded by the browser.

determinePacketType()

ts
determinePacketType(
	packet: EncodedPacket,
): Promise<PacketType | null>;

For a given packet of this track, this method determines the actual type of this packet (key/delta) by looking into its bitstream. Returns null if the type couldn't be determined.

See EncodedPacket and PacketType.

isVideoTrack()

ts
isVideoTrack(): boolean;

Returns true if and only if this track is a video track.

isAudioTrack()

ts
isAudioTrack(): boolean;

Returns true if and only if this track is an audio track.

getFirstTimestamp()

ts
getFirstTimestamp(): Promise<number>;

Returns the start timestamp of the first packet of this track, in seconds. While often near zero, this value may be positive or even negative. A negative starting timestamp means the track's timing has been offset. Samples with a negative timestamp should not be presented.

computeDuration()

ts
computeDuration(): Promise<number>;

Returns the end timestamp of the last packet of this track, in seconds.

computePacketStats()

ts
computePacketStats(
	targetPacketCount: number = Infinity,
): Promise<PacketStats>;

Computes aggregate packet statistics for this track, such as average packet rate or bitrate.

Parameters:

  • targetPacketCount: This optional parameter sets a target for how many packets this method must have looked at before it can return early; this means, you can use it to aggregate only a subset (prefix) of all packets. This is very useful for getting a great estimate of video frame rate without having to scan through the entire file.

See PacketStats.

Released under the Mozilla Public License 2.0.