Constructor
new Mp4Generator(streamInfosopt, non-null)
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
streamInfos |
Array<shaka.util.Mp4Generator.StreamInfo> |
<optional> |
- Implements:
- Source:
Members
AUDIO_SAMPLE_ENTRY_TEMPLATE_ :shaka.util.Lazy<!Uint8Array>
Template for audioSampleEntry_ (28 bytes).
Dynamic fields: channelsCount [17] (uint8),
audioSamplingRate [24] (uint16).
Type:
- shaka.util.Lazy<!Uint8Array>
- Source:
BOX_TYPES_ :Map<string, !Array<number>>
Type:
- Map<string, !Array<number>>
- Source:
ESDS_TEMPLATE_ :shaka.util.Lazy<!Uint8Array>
Template ESDS (31 bytes).
Dynamic fields: ES_ID [6] (uint16), ASC byte1 [26], ASC byte2 [27].
Type:
- shaka.util.Lazy<!Uint8Array>
- Source:
HDLR_TYPES_ :{video: !shaka.util.Lazy<!Uint8Array>, audio: !shaka.util.Lazy<!Uint8Array>}
Type:
- {video: !shaka.util.Lazy<!Uint8Array>, audio: !shaka.util.Lazy<!Uint8Array>}
- Source:
MDAT_TYPE_ :shaka.util.Lazy<!Uint8Array>
'mdat' box-type bytes (ASCII).
Type:
- shaka.util.Lazy<!Uint8Array>
- Source:
MDHD_TEMPLATE_ :shaka.util.Lazy<!Uint8Array>
Template MDHD (version 1, 36 bytes).
Dynamic fields: timescale [20], upperDur [24], lowerDur [28],
language [32] (uint16).
Type:
- shaka.util.Lazy<!Uint8Array>
- Source:
MVHD_TEMPLATE_ :shaka.util.Lazy<!Uint8Array>
Template MVHD (version 1, 112 bytes).
Dynamic fields: timescale [20], upperDur [24], lowerDur [28].
Type:
- shaka.util.Lazy<!Uint8Array>
- Source:
SCHM_TEMPLATE_ :shaka.util.Lazy<!Uint8Array>
Template SCHM (12 bytes).
Dynamic field: schemeNumber [4] (uint32).
Type:
- shaka.util.Lazy<!Uint8Array>
- Source:
TFHD_TEMPLATE_ :shaka.util.Lazy<!Uint8Array>
Template TFHD (24 bytes).
Dynamic field: track_ID [4].
Type:
- shaka.util.Lazy<!Uint8Array>
- Source:
TKHD_TEMPLATE_ :shaka.util.Lazy<!Uint8Array>
Template TKHD (version 1, 96 bytes).
Dynamic fields: track_ID [20], upperDur [28], lowerDur [32],
width [88] (uint16), height [92] (uint16).
Type:
- shaka.util.Lazy<!Uint8Array>
- Source:
TREX_TEMPLATE_ :shaka.util.Lazy<!Uint8Array>
Template TREX (24 bytes).
Dynamic field: track_ID [4].
Type:
- shaka.util.Lazy<!Uint8Array>
- Source:
VIDEO_SAMPLE_ENTRIES_ :Array<!Array<string>>
The video sample entries by the prefix of their codec string: [sample entry
box, configuration box]. The Dolby Vision ones use the configuration box of
the codec they are based on, followed by their own (see dolbyVision_).
Type:
- Array<!Array<string>>
- Source:
VIDEO_SAMPLE_ENTRY_TEMPLATE_ :shaka.util.Lazy<!Uint8Array>
Template for videoSampleEntry_ (78 bytes).
Dynamic fields: width [24] (uint16), height [26] (uint16).
Type:
- shaka.util.Lazy<!Uint8Array>
- Source:
Methods
allocBox_(boxName, payloadSize) → {Uint8Array}
Generate a box that can hold a payload of a given size
Parameters:
| Name | Type | Description |
|---|---|---|
boxName |
string | |
payloadSize |
number |
- Source:
Returns:
- Type
- Uint8Array
box(boxName, …payloadnon-null) → {Uint8Array}
Generate a box
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
boxName |
string | ||
payload |
Uint8Array |
<repeatable> |
- Source:
Returns:
- Type
- Uint8Array
isStreamEncrypted_(streamnon-null) → {boolean}
Parameters:
| Name | Type | Description |
|---|---|---|
stream |
shaka.extern.Stream |
- Source:
Returns:
- Type
- boolean
audioSampleEntry_(streamInfo) → {Uint8Array}
Generate an audio sample entry box (shared implementation for MP3 / AC-3
/ EC-3 / Opus / FLAC / MP4A), which has the configuration box of the
codec after the entry.
Parameters:
| Name | Type | Description |
|---|---|---|
streamInfo |
shaka.util.Mp4Generator.StreamInfo |
- Source:
Returns:
- Type
- Uint8Array
dolbyVision_(streamInfo) → {Uint8Array}
Generate the box of the Dolby Vision configuration (dvcC or dvvC, by the
profile), if the stream has one.
Parameters:
| Name | Type | Description |
|---|---|---|
streamInfo |
shaka.util.Mp4Generator.StreamInfo |
- Source:
Returns:
- Type
- Uint8Array
esds_(streamInfo) → {Uint8Array}
Generate a ESDS box
Parameters:
| Name | Type | Description |
|---|---|---|
streamInfo |
shaka.util.Mp4Generator.StreamInfo |
- Source:
Returns:
- Type
- Uint8Array
frma_(codecs) → {Uint8Array}
Generate a FRMA box
Parameters:
| Name | Type | Description |
|---|---|---|
codecs |
string |
- Source:
Returns:
- Type
- Uint8Array
hdlr_(streamInfo) → {Uint8Array}
Generate a HDLR box
Parameters:
| Name | Type | Description |
|---|---|---|
streamInfo |
shaka.util.Mp4Generator.StreamInfo |
- Source:
Returns:
- Type
- Uint8Array
hexStringToBuffer_(str) → {Uint8Array}
Convert a hex string to buffer.
Parameters:
| Name | Type | Description |
|---|---|---|
str |
string |
- Source:
Returns:
- Type
- Uint8Array
initSegment() → {Uint8Array}
Generate a Init Segment (MP4).
- Implements:
- Source:
Returns:
- Type
- Uint8Array
mdhd_(streamInfo) → {Uint8Array}
Generate a MDHD box
Parameters:
| Name | Type | Description |
|---|---|---|
streamInfo |
shaka.util.Mp4Generator.StreamInfo |
- Source:
Returns:
- Type
- Uint8Array
mdia_(streamInfo) → {Uint8Array}
Generate a MDIA box
Parameters:
| Name | Type | Description |
|---|---|---|
streamInfo |
shaka.util.Mp4Generator.StreamInfo |
- Source:
Returns:
- Type
- Uint8Array
mfhd_(streamInfo) → {Uint8Array}
Generate a MFHD box
Parameters:
| Name | Type | Description |
|---|---|---|
streamInfo |
shaka.util.Mp4Generator.StreamInfo |
- Source:
Returns:
- Type
- Uint8Array
minf_(streamInfo) → {Uint8Array}
Generate a MINF box
Parameters:
| Name | Type | Description |
|---|---|---|
streamInfo |
shaka.util.Mp4Generator.StreamInfo |
- Source:
Returns:
- Type
- Uint8Array
moof_(streamInfo) → {Uint8Array}
Generate a MOOF box
Parameters:
| Name | Type | Description |
|---|---|---|
streamInfo |
shaka.util.Mp4Generator.StreamInfo |
- Source:
Returns:
- Type
- Uint8Array
moov_() → {Uint8Array}
Generate a MOOV box
- Source:
Returns:
- Type
- Uint8Array
mvex_() → {Uint8Array}
Generate a MVEX box
- Source:
Returns:
- Type
- Uint8Array
mvhd_(streamInfo) → {Uint8Array}
Generate a MVHD box
Parameters:
| Name | Type | Description |
|---|---|---|
streamInfo |
shaka.util.Mp4Generator.StreamInfo |
- Source:
Returns:
- Type
- Uint8Array
pasp_(streamInfo) → {Uint8Array}
Generate a PASP box
Parameters:
| Name | Type | Description |
|---|---|---|
streamInfo |
shaka.util.Mp4Generator.StreamInfo |
- Source:
Returns:
- Type
- Uint8Array
psshs(streamnon-null) → {Uint8Array}
Generate a PSSH box
Parameters:
| Name | Type | Description |
|---|---|---|
stream |
shaka.extern.Stream |
- Source:
Returns:
- Type
- Uint8Array
schi_(streamnon-null) → {Uint8Array}
Generate a SCHI box
Parameters:
| Name | Type | Description |
|---|---|---|
stream |
shaka.extern.Stream |
- Source:
Returns:
- Type
- Uint8Array
schm_(streamnon-null) → {Uint8Array}
Generate a SCHM box
Parameters:
| Name | Type | Description |
|---|---|---|
stream |
shaka.extern.Stream |
- Source:
Returns:
- Type
- Uint8Array
sdtp_(streamInfo) → {Uint8Array}
Generate a SDTP box
Parameters:
| Name | Type | Description |
|---|---|---|
streamInfo |
shaka.util.Mp4Generator.StreamInfo |
- Source:
Returns:
- Type
- Uint8Array
segmentData() → {Uint8Array}
Generate a Segment Data (MP4).
- Implements:
- Source:
Returns:
- Type
- Uint8Array
sinf(streamnon-null, codecs) → {Uint8Array}
Generate a SINF box
Parameters:
| Name | Type | Description |
|---|---|---|
stream |
shaka.extern.Stream | |
codecs |
string |
- Source:
Returns:
- Type
- Uint8Array
stbl_(streamInfo) → {Uint8Array}
Generate a STBL box
Parameters:
| Name | Type | Description |
|---|---|---|
streamInfo |
shaka.util.Mp4Generator.StreamInfo |
- Source:
Returns:
- Type
- Uint8Array
stringToCharCode_(str) → {number}
Convert a string to char code.
Parameters:
| Name | Type | Description |
|---|---|---|
str |
string |
- Source:
Returns:
- Type
- number
stsd_(streamInfo) → {Uint8Array}
Generate a STSD box
Parameters:
| Name | Type | Description |
|---|---|---|
streamInfo |
shaka.util.Mp4Generator.StreamInfo |
- Source:
Returns:
- Type
- Uint8Array
tenc_(streamnon-null) → {Uint8Array}
Generate a TENC box
Parameters:
| Name | Type | Description |
|---|---|---|
stream |
shaka.extern.Stream |
- Source:
Returns:
- Type
- Uint8Array
tfdt_(streamInfo) → {Uint8Array}
Generate a TFDT box
Parameters:
| Name | Type | Description |
|---|---|---|
streamInfo |
shaka.util.Mp4Generator.StreamInfo |
- Source:
Returns:
- Type
- Uint8Array
tfhd_(streamInfo) → {Uint8Array}
Generate a TFHD box
Parameters:
| Name | Type | Description |
|---|---|---|
streamInfo |
shaka.util.Mp4Generator.StreamInfo |
- Source:
Returns:
- Type
- Uint8Array
tkhd_(streamInfo) → {Uint8Array}
Generate a TKHD box
Parameters:
| Name | Type | Description |
|---|---|---|
streamInfo |
shaka.util.Mp4Generator.StreamInfo |
- Source:
Returns:
- Type
- Uint8Array
traf_(streamInfo) → {Uint8Array}
Generate a TRAF box
Parameters:
| Name | Type | Description |
|---|---|---|
streamInfo |
shaka.util.Mp4Generator.StreamInfo |
- Source:
Returns:
- Type
- Uint8Array
trak_(streamInfo) → {Uint8Array}
Generate a TRAK box
Parameters:
| Name | Type | Description |
|---|---|---|
streamInfo |
shaka.util.Mp4Generator.StreamInfo |
- Source:
Returns:
- Type
- Uint8Array
trex_(streamInfo) → {Uint8Array}
Generate a TREX box
Parameters:
| Name | Type | Description |
|---|---|---|
streamInfo |
shaka.util.Mp4Generator.StreamInfo |
- Source:
Returns:
- Type
- Uint8Array
trun_(streamInfo, offset) → {Uint8Array}
Generate a TRUN box
Parameters:
| Name | Type | Description |
|---|---|---|
streamInfo |
shaka.util.Mp4Generator.StreamInfo | |
offset |
number |
- Source:
Returns:
- Type
- Uint8Array
videoSampleEntry_(streamInfo, boxName, configBoxName) → {Uint8Array}
Generate a video sample entry box (shared implementation for AVC1 / HVC1
/ AV01 / VP09, and their Dolby Vision versions DVA1 / DVH1 / DAV1, which
have the Dolby Vision configuration box after the codec's). The
mediaConfig of the VP09 is the payload of the vpcC box, which is a full
box, so it starts with the version and the flags.
Parameters:
| Name | Type | Description |
|---|---|---|
streamInfo |
shaka.util.Mp4Generator.StreamInfo | |
boxName |
string | 'avc1' | 'hvc1' | 'av01' | 'vp09' | 'dva1' | 'dvh1' | 'dav1' |
configBoxName |
string | 'avcC' | 'hvcC' | 'av1C' | 'vpcC' |
- Source:
Returns:
- Type
- Uint8Array
writeUint16_(bytesnon-null, value, offset)
Parameters:
| Name | Type | Description |
|---|---|---|
bytes |
Uint8Array | |
value |
number | |
offset |
number |
- Source:
writeUint32_(bytesnon-null, value, offset)
Parameters:
| Name | Type | Description |
|---|---|---|
bytes |
Uint8Array | |
value |
number | |
offset |
number |
- Source:
Type Definitions
Data
Type:
- {sequenceNumber: number, baseMediaDecodeTime: number, samples: !Array<shaka.util.Mp4Generator.Mp4Sample>}
Properties:
| Name | Type | Description |
|---|---|---|
sequenceNumber |
number | The sequence number. |
baseMediaDecodeTime |
number | The base media decode time. |
samples |
Array<shaka.util.Mp4Generator.Mp4Sample> | The data samples. |
- Source:
Mp4Sample
Type:
- {data: !Uint8Array, size: number, duration: number, cts: number, flags: !shaka.util.Mp4Generator.Mp4SampleFlags}
Properties:
| Name | Type | Description |
|---|---|---|
data |
Uint8Array | The sample data. |
size |
number | The sample size. |
duration |
number | The sample duration. |
cts |
number | The sample composition time. |
flags |
shaka.util.Mp4Generator.Mp4SampleFlags | The sample flags. |
- Source:
Mp4SampleFlags
Type:
- {isLeading: number, isDependedOn: number, hasRedundancy: number, degradPrio: number, dependsOn: number, isNonSync: number}
Properties:
| Name | Type | Description |
|---|---|---|
isLeading |
number | |
isDependedOn |
number | |
hasRedundancy |
number | |
degradPrio |
number | |
dependsOn |
number | |
isNonSync |
number |
- Source:
StreamInfo
Type:
- {id: number, type: string, codecs: string, timescale: number, duration: number, mediaConfig: !Uint8Array, hSpacing: (number|undefined), vSpacing: (number|undefined), dolbyVisionConfig: (!Uint8Array|undefined), data: ?shaka.util.Mp4Generator.Data, stream: !shaka.extern.Stream}
Properties:
| Name | Type | Attributes | Description |
|---|---|---|---|
id |
number | A unique ID | |
type |
string | Indicate the content type: 'video' or 'audio'. | |
codecs |
string | Defaults to '' (i.e., unknown / not needed). The Stream's codecs, e.g., 'avc1.4d4015' or 'vp09.00.31.08' See https://tools.ietf.org/html/rfc6381 |
|
timescale |
number | The Stream's timescale. | |
duration |
number | The Stream's duration. | |
mediaConfig |
Uint8Array | The stream's media config. | |
hSpacing |
number | undefined | The stream's video horizontal spacing of pixels. | |
vSpacing |
number | undefined | The stream's video vertical spacing of pixels. | |
dolbyVisionConfig |
Uint8Array | undefined | The Dolby Vision configuration record of the stream, for the sample entries of Dolby Vision (the payload of the dvcC or dvvC box). | |
data |
shaka.util.Mp4Generator.Data |
<nullable> |
The stream's data. |
stream |
shaka.extern.Stream | The Stream. |
- Source: