InputTrack
Base class representing a media track in an input file.Properties
Input
The input file this track belongs to.
TrackType
The type of the track (‘video’, ‘audio’, or ‘subtitle’).
MediaCodec | null
The codec of the track’s packets.
number
The unique ID of this track in the input file.
number
The 1-based index of this track among all tracks of the same type in the input file. For example, the first video track has number 1, the second video track has number 2, and so on.
string | number | Uint8Array | null
The identifier of the codec used internally by the container. It is not homogenized by Mediabunny and depends entirely on the container format.
- 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
CodecIDelement. - 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. - For MPEG-TS files, this field contains the
streamTypevalue from the Program Map Table. - In all other cases, this field is
null.
string
The ISO 639-2/T language code for this track. If the language is unknown, this field is
'und' (undetermined).string | null
A user-defined name for this track.
number
A positive number x such that all timestamps and durations of all packets of this track are integer multiples of 1/x.
TrackDisposition
The track’s disposition, i.e. information about its intended usage.
Methods
getFirstTimestamp()
computeDuration()
getCodecParameterString()
canDecode()
determinePacketType()
computePacketStats()
number
Optional parameter that 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.
PacketStats
isVideoTrack()
isAudioTrack()
InputVideoTrack
Represents a video track in an input file. ExtendsInputTrack with video-specific properties and methods.
Properties
VideoCodec | null
The video codec of this track.
number
The width in pixels of the track’s coded samples, before any transformations or rotations.
number
The height in pixels of the track’s coded samples, before any transformations or rotations.
Rotation
The angle in degrees by which the track’s frames should be rotated (clockwise). Can be 0, 90, 180, or 270.
Rational
The pixel aspect ratio of the track’s frames, as a rational number in its reduced form. Most videos use square pixels (1:1).
number
The width of the track’s frames in square pixels, adjusted for pixel aspect ratio but before rotation.
number
The height of the track’s frames in square pixels, adjusted for pixel aspect ratio but before rotation.
number
The display width of the track’s frames in pixels, after aspect ratio adjustment and rotation.
number
The display height of the track’s frames in pixels, after aspect ratio adjustment and rotation.
Methods
getColorSpace()
hasHighDynamicRange()
canBeTransparent()
getDecoderConfig()
VideoDecoder. Returns null if the track’s codec is unknown.
InputAudioTrack
Represents an audio track in an input file. ExtendsInputTrack with audio-specific properties and methods.
Properties
AudioCodec | null
The audio codec of this track.
number
The number of audio channels in the track.
number
The track’s audio sample rate in hertz.
Methods
getDecoderConfig()
AudioDecoder. Returns null if the track’s codec is unknown.