Home Reference Source
import MP4Demuxer from 'hls.js/src/demux/mp4demuxer.js'
public class | source

MP4Demuxer

Static Method Summary

Static Public Methods
public static

bin2str(buffer: *): *

public static

findBox(data: *, path: *): *

public static

getStartDTS(timescale: *): number

Determine the base media decode start time, in seconds, for an MP4 fragment.

public static

offsetStartDTS(initData: *, fragment: *, timeOffset: *)

public static

Parses an MP4 initialization segment and extracts stream type and timescale values for any declared tracks.

public static

parseSegmentIndex(initSegment: *): {"earliestPresentationTime": *, "timescale": *, "version": *, "referencesCount": *, "references": *, "moovEndOffset": *}

public static

probe(data: *): *

public static

readUint16(buffer: *, offset: *): *

public static

readUint32(buffer: *, offset: *): *

public static

writeUint32(buffer: *, offset: *, value: *)

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public
public

initPTS: *

public
public

remuxer: *

public

Method Summary

Public Methods
public

append(data: *, timeOffset: *, contiguous: *, accurateTimeOffset: *)

public
public

resetInitSegment(initSegment: *, audioCodec: *, videoCodec: *, duration: *)

public

resetTimeStamp(initPTS: *)

Static Public Methods

public static bin2str(buffer: *): * source

Params:

NameTypeAttributeDescription
buffer *

Return:

*

public static findBox(data: *, path: *): * source

Params:

NameTypeAttributeDescription
data *
path *

Return:

*

public static getStartDTS(timescale: *): number source

Determine the base media decode start time, in seconds, for an MP4 fragment. If multiple fragments are specified, the earliest time is returned.

The base media decode time can be parsed from track fragment metadata:

moof > traf > tfdt.baseMediaDecodeTime

It requires the timescale value from the mdhd to interpret.

Params:

NameTypeAttributeDescription
timescale *

{object} a hash of track ids to timescale values.

Return:

number

the earliest base media decode start time for the fragment, in seconds

public static offsetStartDTS(initData: *, fragment: *, timeOffset: *) source

Params:

NameTypeAttributeDescription
initData *
fragment *
timeOffset *

public static parseInitSegment(init: *): object source

Parses an MP4 initialization segment and extracts stream type and timescale values for any declared tracks. Timescale values indicate the number of clock ticks per second to assume for time-based values elsewhere in the MP4.

To determine the start time of an MP4, you need two pieces of information: the timescale unit and the earliest base media decode time. Multiple timescales can be specified within an MP4 but the base media decode time is always expressed in the timescale from the media header box for the track:

moov > trak > mdia > mdhd.timescale
moov > trak > mdia > hdlr

Params:

NameTypeAttributeDescription
init *

{Uint8Array} the bytes of the init segment

Return:

object

a hash of track type to timescale values or null if the init segment is malformed.

public static parseSegmentIndex(initSegment: *): {"earliestPresentationTime": *, "timescale": *, "version": *, "referencesCount": *, "references": *, "moovEndOffset": *} source

Params:

NameTypeAttributeDescription
initSegment *

Return:

{"earliestPresentationTime": *, "timescale": *, "version": *, "referencesCount": *, "references": *, "moovEndOffset": *}

public static probe(data: *): * source

Params:

NameTypeAttributeDescription
data *

Return:

*

public static readUint16(buffer: *, offset: *): * source

Params:

NameTypeAttributeDescription
buffer *
offset *

Return:

*

public static readUint32(buffer: *, offset: *): * source

Params:

NameTypeAttributeDescription
buffer *
offset *

Return:

*

public static writeUint32(buffer: *, offset: *, value: *) source

Params:

NameTypeAttributeDescription
buffer *
offset *
value *

Public Constructors

public constructor() source

Public Members

public audioCodec: * source

public initPTS: * source

public observer: * source

public remuxer: * source

public videoCodec: * source

Public Methods

public append(data: *, timeOffset: *, contiguous: *, accurateTimeOffset: *) source

Params:

NameTypeAttributeDescription
data *
timeOffset *
contiguous *
accurateTimeOffset *

public destroy() source

public resetInitSegment(initSegment: *, audioCodec: *, videoCodec: *, duration: *) source

Params:

NameTypeAttributeDescription
initSegment *
audioCodec *
videoCodec *
duration *

public resetTimeStamp(initPTS: *) source

Params:

NameTypeAttributeDescription
initPTS *