or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

captions.mdcodecs.mdflv.mdindex.mdmp2t.mdmp4.mdpartial.mdtools.md

partial.mddocs/

0

# Partial Processing

1

2

Partial processing support for handling incomplete MPEG2-TS segments. This module provides specialized transmuxing capabilities for scenarios where complete segments aren't immediately available, such as live streaming applications.

3

4

## Capabilities

5

6

### Partial Transmuxer

7

8

Specialized transmuxer for handling partial transport stream data with incremental processing capabilities.

9

10

```javascript { .api }

11

/**

12

* Partial transmuxer for incomplete transport stream segments

13

*/

14

class Transmuxer {

15

constructor();

16

17

/** Add partial transport stream data for processing */

18

push(data: Uint8Array): void;

19

20

/** Flush any remaining data and finalize processing */

21

flush(): void;

22

23

/** Register event listeners for processed segments */

24

on(event: 'data', callback: (segment: PartialSegment) => void): void;

25

on(event: 'done', callback: () => void): void;

26

27

/** Remove event listeners */

28

off(event?: string): void;

29

}

30

31

interface PartialSegment {

32

/** Initialization segment if available */

33

initSegment?: Uint8Array;

34

35

/** Partial media segment data */

36

data: Uint8Array;

37

38

/** Metadata frames if available */

39

metadata?: {

40

frames: ID3Frame[];

41

};

42

43

/** Caption data if available */

44

captions?: CaptionSet[];

45

}

46

```

47

48

**Usage Examples:**

49

50

```javascript

51

const muxjs = require("mux.js");

52

53

// Create partial transmuxer

54

const partialTransmuxer = new muxjs.partial.Transmuxer();

55

56

// Handle partial segments

57

partialTransmuxer.on('data', (segment) => {

58

if (segment.initSegment) {

59

// Initialize MSE source buffer if needed

60

const combined = new Uint8Array(

61

segment.initSegment.byteLength + segment.data.byteLength

62

);

63

combined.set(segment.initSegment, 0);

64

combined.set(segment.data, segment.initSegment.byteLength);

65

sourceBuffer.appendBuffer(combined);

66

} else {

67

// Append partial segment data

68

sourceBuffer.appendBuffer(segment.data);

69

}

70

});

71

72

// Process partial transport stream chunks

73

partialTransmuxer.push(partialChunk1);

74

partialTransmuxer.push(partialChunk2);

75

partialTransmuxer.flush();

76

```

77

78

### Audio Segment Stream (Partial)

79

80

Specialized audio segment stream for partial processing scenarios.

81

82

```javascript { .api }

83

/**

84

* Partial audio segment stream

85

*/

86

class AudioSegmentStream {

87

constructor(track: Track, options?: PartialOptions);

88

push(data: PESData): void;

89

flush(): void;

90

}

91

```

92

93

### Video Segment Stream (Partial)

94

95

Specialized video segment stream for partial processing scenarios.

96

97

```javascript { .api }

98

/**

99

* Partial video segment stream

100

*/

101

class VideoSegmentStream {

102

constructor(track: Track, options?: PartialOptions);

103

push(data: PESData): void;

104

flush(): void;

105

}

106

```

107

108

## Types

109

110

```javascript { .api }

111

interface PartialOptions {

112

/** Base media decode time for partial segments */

113

baseMediaDecodeTime?: number;

114

115

/** Preserve original timestamps */

116

keepOriginalTimestamps?: boolean;

117

}

118

119

interface ID3Frame {

120

key: string;

121

data: Uint8Array;

122

}

123

124

interface CaptionSet {

125

startTime: number;

126

endTime: number;

127

content: Caption[];

128

}

129

130

interface Caption {

131

startTime: number;

132

endTime: number;

133

text: string;

134

line: number;

135

position: number;

136

}

137

138

interface Track {

139

id: number;

140

codec: string;

141

type: 'video' | 'audio';

142

timelineStartInfo: {

143

baseMediaDecodeTime: number;

144

};

145

}

146

147

interface PESData {

148

data: Uint8Array;

149

pts?: number;

150

dts?: number;

151

streamType: number;

152

}

153

```