Constructor
new LocTransmuxer(mimeType)
Parameters:
| Name | Type | Description |
|---|---|---|
mimeType |
string |
- Implements:
- Extends:
- Source:
Extends
Members
SUPPORTED_AUDIO_CODECS_ :Array<string>
Supported audio codecs.
Type:
- Array<string>
- Source:
SUPPORTED_VIDEO_CODECS_ :Array<string>
Supported video codecs.
Type:
- Array<string>
- Source:
av1Info_ :shaka.transmuxer.AV1.Info
Cached result of AV1.parseInfo(), populated from the first temporal unit
that carries a sequence header OBU. Reused for all subsequent frames.
Type:
- Source:
avcInfo_ :?{videoConfig: !Uint8Array, hSpacing: number, vSpacing: number, height: number, width: number}
Cached result of H264.parseInfo(), populated from the first IDR frame
that carries SPS+PPS. Reused for all subsequent non-IDR frames.
Type:
- ?{videoConfig: !Uint8Array, hSpacing: number, vSpacing: number, height: number, width: number}
- Source:
configStreamId_ :number
`id` of the stream the cached configs above were parsed from. One
transmuxer instance is reused across an adaptation, so this is what
tells us the cache now describes a different rendition.
Type:
- number
- Source:
frameIndex :number
Type:
- number
- Overrides:
- Source:
hvcInfo_ :?{videoConfig: !Uint8Array, hSpacing: number, vSpacing: number, height: number, width: number}
Cached result of H265.parseInfo(), populated from the first IDR frame
that carries VPS+SPS+PPS. Reused for all subsequent non-IDR frames.
Type:
- ?{videoConfig: !Uint8Array, hSpacing: number, vSpacing: number, height: number, width: number}
- Source:
initSegments :Map<string, !Uint8Array>
Type:
- Map<string, !Uint8Array>
- Overrides:
- Source:
lastInitSegment_ :Uint8Array
Type:
- Uint8Array
- Overrides:
- Source:
originalMimeType_ :string
Type:
- string
Methods
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
destroy()
Destroy
- Overrides:
- Implements:
- Source:
extractNalus_(datanon-null, codec) → {Array<shaka.extern.VideoNalu>}
Extracts NAL units from a LOC video payload.
The LOC spec (§2.1) allows two framing formats:
- **Length-prefix** (§2.1.3): 4-byte big-endian length before each NALU.
This is the canonical AVCC/HVCC format.
- **Start-code** (§2.1.4): a 4-byte value of `0x00000001` (= 1 in network
byte order) is reserved as a start-code sentinel; the extractor then
scans ahead for the next 3- or 4-byte start code boundary. Per the
spec a length value of 1 SHOULD be interpreted this way.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Uint8Array | |
codec |
string | Normalised codec string: 'avc' or 'hvc' |
- Source:
Returns:
- Type
- Array<shaka.extern.VideoNalu>
getAacStreamInfo_(datanon-null, stream, duration, referencenullable) → {shaka.util.Mp4Generator.StreamInfo}
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
data |
Uint8Array | ||
stream |
shaka.extern.Stream | ||
duration |
number | ||
reference |
shaka.media.SegmentReference |
<nullable> |
- Source:
Returns:
getAv1StreamInfo_(datanon-null, stream, duration, referencenullable) → {shaka.util.Mp4Generator.StreamInfo}
Builds the StreamInfo for an AV1 temporal unit.
Unlike AVC/HEVC there is nothing to reframe: LOC carries the temporal unit
exactly as the encoder produced it — no start codes, no length prefixes —
and that is also what an `av01` sample is, so the payload becomes one
sample unchanged. The OBUs are only walked to find the sequence header
and the frame type.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
data |
Uint8Array | ||
stream |
shaka.extern.Stream | ||
duration |
number | ||
reference |
shaka.media.SegmentReference |
<nullable> |
- Source:
Returns:
getAvcStreamInfo_(datanon-null, stream, referencenullable, duration) → {shaka.util.Mp4Generator.StreamInfo}
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
data |
Uint8Array | ||
stream |
shaka.extern.Stream | ||
reference |
shaka.media.SegmentReference |
<nullable> |
|
duration |
number |
- Source:
Returns:
getHvcStreamInfo_(datanon-null, stream, duration, referencenullable) → {shaka.util.Mp4Generator.StreamInfo}
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
data |
Uint8Array | ||
stream |
shaka.extern.Stream | ||
duration |
number | ||
reference |
shaka.media.SegmentReference |
<nullable> |
- Source:
Returns:
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
getOpusStreamInfo_(datanon-null, stream, duration, referencenullable) → {shaka.util.Mp4Generator.StreamInfo}
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
data |
Uint8Array | ||
stream |
shaka.extern.Stream | ||
duration |
number | ||
reference |
shaka.media.SegmentReference |
<nullable> |
- Source:
Returns:
getOriginalMimeType() → {string}
- Overrides:
- Implements:
- Source:
Returns:
- Type
- string
isLocContainer_(mimeType) → {boolean}
Parameters:
| Name | Type | Description |
|---|---|---|
mimeType |
string |
- Source:
Returns:
- Type
- boolean
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(mp4Generatornon-null, stream, referencenullable) → {shaka.extern.TransmuxerOutput}
Packages the init and media segments produced by the given Mp4Generator.
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 |
|---|---|---|---|
mp4Generator |
shaka.util.Mp4Generator | ||
stream |
shaka.extern.Stream | ||
reference |
shaka.media.SegmentReference |
<nullable> |
- Overrides:
- Source:
Returns:
stripAdtsHeader_(datanon-null) → {Uint8Array}
Strips the ADTS header from an AAC access unit, if the publisher left one
on.
An mp4a sample entry describes its stream through the esds
(AudioSpecificConfig), so samples must be RAW access units. A frame that
still carries its 7- or 9-byte ADTS header is not one: the decoder is
configured from the esds, then receives a packet beginning with the
0xFFFx syncword and rejects it. Chromium reports "Failed to send audio
packet for decoding" on the very first packet and fails the whole
pipeline, taking video down with it.
LOC-04 §2 defines the payload as the elementary bitstream "without any
encapsulation", so a conforming publisher never sends the header — but
some do, so detect rather than assume. The check is deliberately tighter
than a syncword match: raw AAC can begin with 0xFF by coincidence, while
a genuine ADTS frame declares a length covering exactly this object,
because in LOC one object is one frame.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Uint8Array |
- Source:
Returns:
- Type
- Uint8Array
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)>