new Mp4Frag(optionsopt)
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
<optional> |
Configuration options.
Properties
|
Throws:
Will throw an error if options.hlsPlaylistBase contains characters other than letters(a-zA-Z) and underscores(_).
Members
(readonly) allKeyframes
Properties:
Name | Type | Description |
---|---|---|
allKeyframes |
boolean | - Returns a boolean indicating if all segments contain a keyframe.
- Returns false if any segments do not contain a keyframe. |
(readonly) audioCodec
Properties:
Name | Type | Description |
---|---|---|
audioCodec |
string | null | - Returns the audio codec information as a string.
- Returns null if requested before initialized event. |
(readonly) duration
Properties:
Name | Type | Description |
---|---|---|
duration |
number | - Returns the duration of latest Mp4 segment as a Float(seconds).
- Returns -1 if requested before first segment event. |
(readonly) initialization
Properties:
Name | Type | Description |
---|---|---|
initialization |
Buffer | null | - Returns the Mp4 initialization fragment as a Buffer.
- Returns null if requested before initialized event. |
(readonly) keyframe
Properties:
Name | Type | Description |
---|---|---|
keyframe |
boolean | - Returns a boolean indicating if the current segment contains a keyframe.
- Returns false if the current segment does not contain a keyframe. - Returns true if segment only contains audio. |
(readonly) m3u8
Properties:
Name | Type | Description |
---|---|---|
m3u8 |
string | null | - Returns the fmp4 HLS m3u8 playlist as a string.
- Returns null if requested before initialized event. |
(readonly) mime
Properties:
Name | Type | Description |
---|---|---|
mime |
string | null | - Returns the mime type information as a string.
- Returns null if requested before initialized event. |
(readonly) poolLength
Properties:
Name | Type | Description |
---|---|---|
poolLength |
number | - Returns the number of array buffers in pool
- Returns -1 if pool not in use. |
(readonly) segment
Properties:
Name | Type | Description |
---|---|---|
segment |
Buffer | null | - Returns the latest Mp4 segment as a Buffer.
- Returns null if requested before first segment event. |
(readonly) segmentObject
Properties:
Name | Type | Description |
---|---|---|
segmentObject |
object | - Returns the latest Mp4 segment as an object.
- {segment, sequence, duration, timestamp, keyframe}
- Returns {segment: null, sequence: -1, duration: -1; timestamp: -1, keyframe: true} if requested before first segment event. |
(readonly) segmentObjects
Properties:
Name | Type | Description |
---|---|---|
segmentObjects |
Array | null | - Returns the Mp4 segments as an Array of objects
- [{segment, sequence, duration, timestamp, keyframe},...]
- Returns null if requested before first segment event. |
(readonly) sequence
Properties:
Name | Type | Description |
---|---|---|
sequence |
number | - Returns the sequence of the latest Mp4 segment as an Integer.
- Returns -1 if requested before first segment event. |
(readonly) timescale
Properties:
Name | Type | Description |
---|---|---|
timescale |
number | - Returns the timescale information as a number.
- Returns -1 if requested before initialized event. |
(readonly) timestamp
Properties:
Name | Type | Description |
---|---|---|
timestamp |
number | - Returns the timestamp of the latest Mp4 segment as an Integer(milliseconds).
- Returns -1 if requested before first segment event. |
(readonly) totalByteLength
Properties:
Name | Type | Description |
---|---|---|
totalByteLength |
number | - Returns the total byte length of the Mp4 initialization and all Mp4 segments as an Integer(bytes).
- Returns -1 if requested before initialized event. |
(readonly) totalDuration
Properties:
Name | Type | Description |
---|---|---|
totalDuration |
number | - Returns the total duration of all Mp4 segments as a Float(seconds).
- Returns -1 if requested before first segment event. |
(readonly) videoCodec
Properties:
Name | Type | Description |
---|---|---|
videoCodec |
string | null | - Returns the video codec information as a string.
- Returns null if requested before initialized event. |
Methods
getSegmentObject(sequence) → {object|null}
Parameters:
Name | Type | Description |
---|---|---|
sequence |
number | string | sequence number
- Returns the Mp4 segment that corresponds to the numbered sequence as an object.
- {segment, sequence, duration, timestamp, keyframe}
- Returns null if there is no segment that corresponds to sequence number. |
Returns:
- Type
- object | null
reset()
Clear cached values
resetCache()
Clear cached values
toJSON() → {object}
Returns:
- Type
- object
Events
initialized
Fires when the initialization of the Mp4 is parsed from the piped data.
Type:
- Event
Properties:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
object |
object |
Properties
|
reset
Fires when reset() is called.
Type:
- Event
segment
Fires when the latest Mp4 segment is parsed from the piped data.
Type:
- Event
Properties:
Name | Type | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
object |
object | Mp4Frag.segmentObject
Properties
|