Class: shaka.transmuxer.MatroskaTransmuxer

Constructor

new MatroskaTransmuxer(mimeType)

Parameters:
Name Type Description
mimeType string
Implements:
Extends:
Source:

Extends

Members

AAC_SAMPLES_PER_FRAME_ :number

The number of samples an AAC frame codes (AAC-LC and HE-AAC alike, counted at the rate of the AAC core).
Type:
  • number
Source:

CONTINUITY_TICKS_ :number

How many ticks of the timecode scale apart two adjoining segments may be for the transmuxer to consider them continuous: half a tick of rounding error at the end of one and at the start of the other.
Type:
  • number
Source:

SUPPORTED_CODECS_ :Array<string>

The prefixes of the codec strings that can be repackaged. They are the codecs MP4 can carry and that MSE plays; see shaka.mkv.MatroskaCodecs.
Type:
  • Array<string>
Source:

VIDEO_TIMESCALE_ :number

The clock of MPEG video, 90 kHz. Video frame durations (1/24, 1/25, 1/30, 1/60 s and their 1001/1000 variants) are whole numbers of ticks at this rate, and it leaves plenty of room in the 64-bit decode times.
Type:
  • number
Source:

WEBM_CODECS_ :Array<string>

The prefixes of the codec strings that are written as WebM; the others are written as MP4.
Type:
  • Array<string>
Source:

audioInfo_ :shaka.transmuxer.MatroskaTransmuxer.AudioInfo

What the first audio segment showed about the audio stream.
Type:
Source:

frameIndex :number

Type:
  • number
Overrides:
Source:

header_ :shaka.mkv.MatroskaIndexParser.Header

The tracks and the time scale described by the last initialization segment.
Type:
Source:

initSegments :Map<string, !Uint8Array>

Type:
  • Map<string, !Uint8Array>
Overrides:
Source:

lastInitSegment_ :Uint8Array

Type:
  • Uint8Array
Overrides:
Source:

nextDecodeTime_ :number

The decode time at which the next segment is expected to start, in ticks of the timescale, or null before the first segment.
Type:
  • number
Source:

originalMimeType_ :string

Type:
  • string
Overrides:
Source:

Methods

getAudioInfo_(tracknon-null, firstFramenon-null) → {shaka.transmuxer.MatroskaTransmuxer.AudioInfo}

Works out how to describe an audio track in MP4.
Parameters:
Name Type Description
track shaka.mkv.MatroskaIndexParser.Track
firstFrame Uint8Array The first frame of the track.
Source:
Returns:
Type
shaka.transmuxer.MatroskaTransmuxer.AudioInfo

getLastDuration_(tracknon-null, decodeTimesnon-null, timescale, referencenullable) → {number}

Gets the duration of the last video sample of a segment, which has no next frame to measure it against.
Parameters:
Name Type Attributes Description
track shaka.mkv.MatroskaIndexParser.Track
decodeTimes Array<number>
timescale number
reference shaka.media.SegmentReference <nullable>
Source:
Returns:
Type
number

isSupportedCodec_(codecs) → {boolean}

Parameters:
Name Type Description
codecs string
Source:
Returns:
Type
boolean

convertCodecs(contentType, mimeType) → {string}

For any stream, convert its codecs to MP4 codecs.
Parameters:
Name Type Description
contentType string
mimeType string
Implements:
Source:
Returns:
Type
string

getContainer_(mimeType) → {string}

Parameters:
Name Type Description
mimeType string
Source:
Returns:
The MIME type without the parameters, in lower case.
Type
string

getContinuityOffset_(decodeTime, header, timescale) → {number}

Segments that follow each other should have decode times that follow each other too. Times taken from Matroska have the resolution of its timecode scale (one millisecond by default), so a segment's start can differ from the end of the previous one by that much, which MSE would see as a tiny gap or overlap. This tells how much to move the start of a segment to make it continue the previous one, when it is close enough to be the next segment.
Parameters:
Name Type Description
decodeTime number The decode time the segment starts at.
header shaka.mkv.MatroskaIndexParser.Header
timescale number
Source:
Returns:
How much to add to the decode times, in ticks.
Type
number

getId3Timestamp(id3Datanon-null, defaultTimestamp) → {number}

Reads the transport-stream timestamp carried in the given ID3 data (the 'com.apple.streaming.transportStreamTimestamp' frame), if present, falling back to the provided default otherwise.
Parameters:
Name Type Description
id3Data Uint8Array
defaultTimestamp number
Overrides:
Source:
Returns:
Type
number

getOriginalMimeType() → {string}

Overrides:
Implements:
Source:
Returns:
Type
string

getWebmTimes_(framesnon-null, tracknon-null) → {Array<number>}

Gets the time of each frame. Every block has one, and blocks written by muxers often lace several frames of audio: MSE does not take lacing, so each of those frames has to get a time of its own. What is known of a frame laced with others is the time of its block, which is the time of the first, and (for the codecs that say it) how much audio each frame holds.
Parameters:
Name Type Description
frames Array<shaka.mkv.MatroskaClusterParser.Frame>
track shaka.mkv.MatroskaIndexParser.Track
Source:
Returns:
The times in seconds.
Type
Array<number>

isSupported(mimeType, contentTypeopt) → {boolean}

Check if the mime type and the content type is supported.
Parameters:
Name Type Attributes Description
mimeType string
contentType string <optional>
Implements:
Source:
Returns:
Type
boolean

packageSegment(generatornon-null, stream, referencenullable) → {shaka.extern.TransmuxerOutput}

Packages the init and media segments produced by the given generator implementing shaka.util.SegmentGenerator. The init segment is cached per discontinuity and the running frame index is advanced. The init segment is only (re)appended when it differs from the last one used.
Parameters:
Name Type Attributes Description
generator shaka.util.SegmentGenerator
stream shaka.extern.Stream
reference shaka.media.SegmentReference <nullable>
Overrides:
Source:
Returns:
Type
shaka.extern.TransmuxerOutput

packageWebm_(bytesnon-null, stream, referencenullable) → {shaka.extern.TransmuxerOutput}

Writes the frames of a track as WebM. WebM has presentation times only, and the codecs it is used for here (VP8, Vorbis) do not reorder frames, so they are what the file says, moved by the shift.
Parameters:
Name Type Attributes Description
bytes Uint8Array
stream shaka.extern.Stream
reference shaka.media.SegmentReference <nullable>
Source:
Returns:
Type
shaka.extern.TransmuxerOutput

parseInit_(bytesnon-null, stream)

Learns what the track is from its initialization segment.
Parameters:
Name Type Description
bytes Uint8Array
stream shaka.extern.Stream
Source:

transmux(data, stream, referencenullable, duration, contentType) → {Promise<(!Uint8Array|!shaka.extern.TransmuxerOutput)>}

Transmux a input data to MP4.
Parameters:
Name Type Attributes Description
data BufferSource
stream shaka.extern.Stream
reference shaka.media.SegmentReference <nullable>
The segment reference, or null for init segments
duration number
contentType string
Implements:
Source:
Returns:
If you only want to return the result, use Uint8Array, if you want to separate the initialization segment and the data segment, you have to use shaka.extern.TransmuxerOutput
Type
Promise<(!Uint8Array|!shaka.extern.TransmuxerOutput)>

transmuxAudio_(bytesnon-null, stream, referencenullable, duration) → {shaka.extern.TransmuxerOutput}

Parameters:
Name Type Attributes Description
bytes Uint8Array
stream shaka.extern.Stream
reference shaka.media.SegmentReference <nullable>
duration number
Source:
Returns:
Type
shaka.extern.TransmuxerOutput

transmuxVideo_(bytesnon-null, stream, referencenullable, duration) → {shaka.extern.TransmuxerOutput}

Parameters:
Name Type Attributes Description
bytes Uint8Array
stream shaka.extern.Stream
reference shaka.media.SegmentReference <nullable>
duration number
Source:
Returns:
Type
shaka.extern.TransmuxerOutput

Type Definitions

AudioInfo

Type:
  • {codecs: string, timescale: number, sampleRate: number, channelCount: number, config: !Uint8Array, getDuration: function(!Uint8Array): number}
Properties:
Name Type Description
codecs string The codec, as Mp4Generator names it.
timescale number The ticks per second the media times are written in.
sampleRate number
channelCount number
config Uint8Array The payload of the codec configuration box.
getDuration function Returns the duration, in ticks, of a frame.
Source: