Class: Mp4Frag

Mp4Frag(optionsopt) → {Mp4Frag}

new Mp4Frag(optionsopt) → {Mp4Frag}

Parameters:
Name Type Attributes Description
options Object <optional>
Configuration options.
Properties
Name Type Attributes Default Description
hlsPlaylistBase String <optional>
Base name of files in m3u8 playlist. Affects the generated m3u8 playlist by naming file fragments. Must be set to generate m3u8 playlist. e.g. 'front_door'
hlsPlaylistSize Number <optional>
4 Number of segments to use in m3u8 playlist. Must be an integer ranging from 2 to 20.
hlsPlaylistExtra Number <optional>
0 Number of extra segments to keep in memory. Must be an integer ranging from 0 to 10.
hlsPlaylistInit Boolean <optional>
true Indicates that m3u8 playlist should be generated after init segment is created and before media segments are created.
segmentCount Number <optional>
2 Number of segments to keep in memory. Has no effect if using options.hlsPlaylistBase. Must be an integer ranging from 2 to 30.
Source:
Throws:
Will throw an error if options.hlsPlaylistBase contains characters other than letters(a-zA-Z) and underscores(_).
Returns:
this - Returns reference to new instance of Mp4Frag for chaining event listeners.
Type
Mp4Frag

Members

(readonly) audioCodec

Properties:
Name Type Description
mime String | null - Returns the audio codec information as a String.
- Returns Null if requested before initialized event.
Source:

(readonly) buffer

Properties:
Name Type Description
buffer Buffer | null - Returns the Mp4Frag.initialization and Mp4Frag.segmentList concatenated as a single Buffer.
- Returns Null if requested before first segment event.
Source:

(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.
Source:

(readonly) initialization

Properties:
Name Type Description
initialization Buffer | null - Returns the Mp4 initialization fragment as a Buffer.
- Returns Null if requested before initialized event.
Source:

(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.
Source:

(readonly) mime

Properties:
Name Type Description
mime String | null - Returns the mime type information as a String.
- Returns Null if requested before initialized event.
Source:

(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.
Source:

(readonly) segmentList

Properties:
Name Type Description
segmentList Buffer | null - Returns the Mp4 segments concatenated as a single Buffer.
- Returns Null if requested before first segment event.
Source:

(readonly) segmentObject

Properties:
Name Type Description
segmentObject Object - Returns the latest Mp4 segment as an Object.
- {segment, sequence, duration, timestamp}
- Returns {segment: null, sequence: -1, duration: -1; timestamp: -1} if requested before first segment event.
Source:

(readonly) segmentObjectList

Properties:
Name Type Description
segmentObjectList Array | null - Returns the Mp4 segments as an Array of Objects
- [{buffer, sequence, duration, timestamp},...]
- Returns Null if requested before first segment event.
Source:

(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.
Source:

(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.
Source:

(readonly) videoCodec

Properties:
Name Type Description
mime String | null - Returns the video codec information as a String.
- Returns Null if requested before initialized event.
Source:

Methods

getSegment(sequence) → {Buffer|null}

Parameters:
Name Type Description
sequence Number | String - Returns the Mp4 segment that corresponds to the numbered sequence as a Buffer.
- Returns Null if there is no segment that corresponds to sequence number.
Source:
Returns:
Type
Buffer | null

getSegmentObject(sequence) → {Object|null}

Parameters:
Name Type Description
sequence Number | String - Returns the Mp4 segment that corresponds to the numbered sequence as an Object.
- {buffer, sequence, duration, timestamp}
- Returns Null if there is no segment that corresponds to sequence number.
Source:
Returns:
Type
Object | null

resetCache()

Clear cached values
Source:

Events

initialized

Fires when the init fragment of the Mp4 is parsed from the piped data.
Type:
  • Event
Properties:
Name Type Description
Object Object
Properties
Name Type Description
mime String Mp4Frag.mime
initialization Buffer Mp4Frag.initialization
m3u8 String Mp4Frag.m3u8
Source:

reset

Fires when resetCache() is called.
Type:
  • Event
Source:

segment

Fires when the latest Mp4 segment is parsed from the piped data.
Type:
  • Event
Properties:
Name Type Description
Object Object Mp4Frag.segmentObject
Properties
Name Type Description
buffer Buffer Mp4Frag.segment
sequence Number Mp4Frag.sequence
duration Number Mp4Frag.duration
timestamp Number Mp4Frag.timestamp
Source: