Constructor
new TsParser()
Members
H264_NALU_TYPE_SPS_ :number
NALU type for Sequence Parameter Set (SPS) for H.264.
Type:
- number
- Source:
H265_NALU_TYPE_SPS_ :number
NALU type for Sequence Parameter Set (SPS) for H.265.
Type:
- number
- Source:
PROFILES_WITH_OPTIONAL_SPS_DATA_ :Array<number>
Values of profile_idc that indicate additional fields are included in the
SPS.
see Recommendation ITU-T H.264 (4/2013)
7.3.2.1.1 Sequence parameter set data syntax
Type:
- Array<number>
- Source:
audioData_ :Array<!Uint8Array>
Flat list of all audio TS packets.
Type:
- Array<!Uint8Array>
- Source:
audioDataPesIndices_ :Array<number>
Index into audioData_ where each audio PES unit starts.
Type:
- Array<number>
- Source:
av1Metadata_ :Uint8Array
The first three bytes of the AV1_video_descriptor, which the AV1 in
MPEG-2 TS spec requires to describe the whole stream.
Type:
- Uint8Array
- Source:
id3Data_ :Array<!Uint8Array>
Flat list of all ID3 TS packets.
Type:
- Array<!Uint8Array>
- Source:
id3DataPesIndices_ :Array<number>
Index into id3Data_ where each ID3 PES unit starts.
Type:
- Array<number>
- Source:
videoData_ :Array<!Uint8Array>
Flat list of all video TS packets.
Type:
- Array<!Uint8Array>
- Source:
videoDataPesIndices_ :Array<number>
Index into videoData_ where each video PES unit starts.
Type:
- Array<number>
- Source:
Methods
probe(data) → {boolean}
Check if the passed data corresponds to an MPEG2-TS
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Uint8Array |
- Source:
Returns:
- Type
- boolean
syncOffset(data) → {number}
Returns the synchronization offset
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Uint8Array |
- Source:
Returns:
- Type
- number
byteToHex_(x) → {string}
Convert a byte to 2 digits of hex. (Only handles values 0-255.)
Parameters:
| Name | Type | Description |
|---|---|---|
x |
number |
- Source:
Returns:
- Type
- string
concatPesPacketRange_(packetsnon-null, range) → {Uint8Array}
Parameters:
| Name | Type | Description |
|---|---|---|
packets |
Array<!Uint8Array> | Flat list of all TS packets for a PID. |
range |
{first: number, end: number} | Packet range to concatenate. |
- Source:
Returns:
- Type
- Uint8Array
concatPesPackets_(packetsnon-null, pesIndicesnon-null, pesIdx) → {Uint8Array}
Concatenate all TS packets that belong to a single PES unit.
Parameters:
| Name | Type | Description |
|---|---|---|
packets |
Array<!Uint8Array> | Flat list of all TS packets for a PID. |
pesIndices |
Array<number> | Start index in `packets` for each PES. |
pesIdx |
number | Index into `pesIndices` for the desired PES. |
- Source:
Returns:
- Type
- Uint8Array
getAudioData() → {Array<shaka.extern.MPEG_PES>}
Return the audio data
- Source:
Returns:
- Type
- Array<shaka.extern.MPEG_PES>
getAv1Info_() → {{height: ?string, width: ?string, codec: ?string, frameRate: ?number}}
Return the video information for AV1
The dimensions live in the sequence header, inside the elementary stream,
and reading them means parsing OBUs, which is the transmuxer's job. What
is available here is the AV1 video descriptor, which the spec requires to
signal the profile, tier and highest level of the whole stream.
- Source:
Returns:
- Type
- {height: ?string, width: ?string, codec: ?string, frameRate: ?number}
getAvcInfo_() → {{height: ?string, width: ?string, codec: ?string, frameRate: ?number}}
Return the video information for AVC
- Source:
Returns:
- Type
- {height: ?string, width: ?string, codec: ?string, frameRate: ?number}
getCodecs() → {{audio: ?string, video: ?string}}
Return the audio and video codecs
- Source:
Returns:
- Type
- {audio: ?string, video: ?string}
getHvcInfo_() → {{height: ?string, width: ?string, codec: ?string, frameRate: ?number}}
Return the video information for HVC
- Source:
Returns:
- Type
- {height: ?string, width: ?string, codec: ?string, frameRate: ?number}
getMetadata() → {Array<shaka.extern.ID3Metadata>}
Return the ID3 metadata
- Source:
Returns:
- Type
- Array<shaka.extern.ID3Metadata>
getPesPacketRange_(packetsnon-null, pesIndicesnon-null, pesIdx) → {{first: number, end: number}}
Parameters:
| Name | Type | Description |
|---|---|---|
packets |
Array<!Uint8Array> | Flat list of all TS packets for a PID. |
pesIndices |
Array<number> | Start index in `packets` for each PES. |
pesIdx |
number | Index into `pesIndices` for the desired PES. |
- Source:
Returns:
- Type
- {first: number, end: number}
getPmtId_(data, offset) → {number}
Get the PMT ID from the PAT
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Uint8Array | |
offset |
number |
- Source:
Returns:
- Type
- number
getRequiredPesHeaderLength_(datanon-null) → {number}
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Uint8Array | PES data with at least `MIN_PES_HEADER_LENGTH_` bytes. |
- Source:
Returns:
- Type
- number
getStartTime(contentType) → {number}
Return the start time for the audio and video
Parameters:
| Name | Type | Description |
|---|---|---|
contentType |
string |
- Source:
Returns:
- Type
- number
getStartTimeFromPes_(pes) → {number}
Parameters:
| Name | Type | Description |
|---|---|---|
pes |
{pts: ?number, dts: ?number} |
- Source:
Returns:
- Type
- number
getStartTimeFromPesHeaders(contentType) → {number}
Return the start time for the audio or video by parsing only PES headers.
This is intended for append-time timestamp offset calculation, where
callers do not need the parsed PES payloads.
Parameters:
| Name | Type | Description |
|---|---|---|
contentType |
string |
- Source:
Returns:
- Type
- number
getVideoData(naluProcessingopt) → {Array<shaka.extern.MPEG_PES>}
Return the video data
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
naluProcessing |
boolean |
<optional> |
true |
- Source:
Returns:
- Type
- Array<shaka.extern.MPEG_PES>
getVideoInfo() → {{height: ?string, width: ?string, codec: ?string, frameRate: ?number}}
Return the video information
- Source:
Returns:
- Type
- {height: ?string, width: ?string, codec: ?string, frameRate: ?number}
getVideoNalus() → {Array<shaka.extern.VideoNalu>}
Return the video data
- Source:
Returns:
- Type
- Array<shaka.extern.VideoNalu>
handleRollover_(value, reference) → {number}
Parameters:
| Name | Type | Description |
|---|---|---|
value |
number | |
reference |
number |
- Source:
Returns:
- Type
- number
parse(data) → {shaka.util.TsParser}
Parse the given data
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Uint8Array |
- Source:
Returns:
- Type
- shaka.util.TsParser
parseNalus(pes, lastInfo) → {Array<shaka.extern.VideoNalu>}
Parse AVC and HVC Nalus
The code is based on hls.js
Credit to https://github.com/video-dev/hls.js/blob/master/src/demux/tsdemuxer.ts
Parameters:
| Name | Type | Description |
|---|---|---|
pes |
shaka.extern.MPEG_PES | |
lastInfo |
{nalu: ?shaka.extern.VideoNalu, state: ?number} |
- Source:
Returns:
- Type
- Array<shaka.extern.VideoNalu>
parsePES_(datanon-null) → {shaka.extern.MPEG_PES}
Parse PES
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Uint8Array |
- Source:
Returns:
parsePESHeader_(datanon-null, fullPesByteLength) → {?{packetLength: number, payloadStartOffset: number, pts: ?number, dts: ?number}}
Parse the PES header without requiring the full payload.
This updates PTS/DTS rollover reference state, so callers that depend on
rollover-corrected timestamps across multiple PES packets must parse
headers in PES order.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Uint8Array | PES bytes available to read from. May contain only the first TS packet payload, so this can be smaller than the full PES. Use `data.byteLength` for bounds checks on readable bytes. |
fullPesByteLength |
number | Total byte length of the complete PES (sum of all its TS packet payloads), which may be larger than `data.byteLength`. Use this only for reasoning about the full PES, never for indexing into `data`. |
- Source:
Returns:
- Type
- ?{packetLength: number, payloadStartOffset: number, pts: ?number, dts: ?number}
parsePMT_(data, offset) → {shaka.util.TsParser.PMT}
Parse PMT
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Uint8Array | |
offset |
number |
- Source:
Returns:
setDiscontinuitySequence(discontinuitySequence)
Set the current discontinuity sequence number.
Parameters:
| Name | Type | Description |
|---|---|---|
discontinuitySequence |
number |
- Source:
Type Definitions
OpusMetadata
PMT.
Type:
- {channelCount: number, channelConfigCode: number, sampleRate: number}
Properties:
| Name | Type | Description |
|---|---|---|
channelCount |
number | |
channelConfigCode |
number | |
sampleRate |
number |
- Source:
PMT
PMT.
Type:
- {audio: number, video: number, id3: number, audioCodec: string, videoCodec: string}
Properties:
| Name | Type | Description |
|---|---|---|
audio |
number | Audio PID |
video |
number | Video PID |
id3 |
number | ID3 PID |
audioCodec |
string | Audio codec |
videoCodec |
string | Video codec |
- Source: