jmuxer 2.0.2 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -27
- package/dist/jmuxer.js +346 -253
- package/dist/jmuxer.min.js +1 -1
- package/package.json +9 -8
- package/rollup.config.js +2 -1
- package/src/controller/buffer.js +24 -20
- package/src/controller/remux.js +7 -1
- package/src/jmuxer.js +87 -26
- package/src/parsers/aac.js +5 -9
- package/src/parsers/h264.js +31 -3
- package/src/remuxer/aac.js +4 -0
- package/src/remuxer/h264.js +4 -2
- package/src/util/exp-golomb.js +6 -0
- package/test/parser.js +4 -2
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
[](https://travis-ci.org/samirkumardas/jmuxer)
|
|
2
|
-

|
|
3
3
|

|
|
4
4
|
|
|
5
5
|
jMuxer
|
|
@@ -14,40 +14,48 @@ Live Demo
|
|
|
14
14
|
|
|
15
15
|
How to use?
|
|
16
16
|
-------
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
A distribution version is available on dist folder.
|
|
18
|
+
|
|
19
19
|
```html
|
|
20
20
|
<script type="text/javascript" src="dist/jmuxer.min.js"></script>
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
var jmuxer = new JMuxer(option);
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
Available options are:
|
|
26
26
|
|
|
27
|
-
*node* - String ID of a video tag / Reference of the HTMLVideoElement. Required field for browsers.
|
|
27
|
+
*node* - String ID of a video tag / Reference of the HTMLVideoElement. Required field for browsers.
|
|
28
28
|
|
|
29
29
|
*mode* - Available values are: both, video and audio. Default is both
|
|
30
30
|
|
|
31
|
-
*flushingTime* - Buffer flushing time in
|
|
31
|
+
*flushingTime* - Buffer flushing time in milliseconds. Default value is 500 milliseconds. Set `flushingTime` to 0 if you want to flash buffer immediately or find any lag.
|
|
32
|
+
|
|
33
|
+
*maxDelay* - Maximum delay time in milliseconds. Default value is 500 milliseconds.
|
|
32
34
|
|
|
33
|
-
*clearBuffer* - true/false. Either it will clear played media buffer automatically or not. Default is true.
|
|
35
|
+
*clearBuffer* - true/false. Either it will clear played media buffer automatically or not. Default is true.
|
|
34
36
|
|
|
35
|
-
*fps* - Optional value. Frame rate of the video if it is known/fixed value. It will be used to find frame duration if chunk duration is not available with provided media data.
|
|
37
|
+
*fps* - Optional value. Frame rate of the video if it is known/fixed value. It will be used to find frame duration if chunk duration is not available with provided media data.
|
|
38
|
+
|
|
39
|
+
*readFpsFromTrack* - true/false. Will read FPS from MP4 track data instead of using (above) fps value. Default is false.
|
|
36
40
|
|
|
37
41
|
*onReady* - function. Will be called once MSE is ready.
|
|
38
42
|
|
|
39
|
-
*onError* - function. Will be fired if jMuxer encounters any buffer
|
|
43
|
+
*onError* - function. Will be fired if jMuxer encounters any buffer related errors.
|
|
44
|
+
|
|
45
|
+
*onMissingVideoFrames* - function. Will be fired if jMuxer encounters any missing video frames.
|
|
46
|
+
|
|
47
|
+
*onMissingAudioFrames* - function. Will be fired if jMuxer encounters any missing audio frames.
|
|
40
48
|
|
|
41
49
|
*debug* - true/false. Will print debug log in browser console. Default is false.
|
|
42
50
|
|
|
43
51
|
**Complete example:**
|
|
44
52
|
|
|
45
53
|
```html
|
|
46
|
-
|
|
54
|
+
|
|
47
55
|
<script type="text/javascript" src="dist/jmuxer.min.js"></script>
|
|
48
|
-
|
|
56
|
+
|
|
49
57
|
<video id="player"></video>
|
|
50
|
-
|
|
58
|
+
|
|
51
59
|
<script>
|
|
52
60
|
var jmuxer = new JMuxer({
|
|
53
61
|
node: 'player',
|
|
@@ -55,23 +63,26 @@ Available options are:
|
|
|
55
63
|
debug: false
|
|
56
64
|
});
|
|
57
65
|
|
|
58
|
-
/* Now feed media data using feed method. audio and video is buffer data and duration is in
|
|
66
|
+
/* Now feed media data using feed method. audio and video is buffer data and duration is in milliseconds */
|
|
59
67
|
jmuxer.feed({
|
|
60
68
|
audio: audio,
|
|
61
69
|
video: video,
|
|
62
70
|
duration: duration
|
|
63
71
|
});
|
|
64
|
-
|
|
72
|
+
|
|
65
73
|
</script>
|
|
66
74
|
|
|
67
75
|
```
|
|
68
|
-
Media dataObject may have folloiwng properties:
|
|
69
76
|
|
|
70
|
-
|
|
77
|
+
Media dataObject may have following properties:
|
|
78
|
+
|
|
79
|
+
*video* - h264 buffer
|
|
71
80
|
|
|
72
81
|
*audio* - AAC buffer
|
|
73
82
|
|
|
74
|
-
*duration* - duration in
|
|
83
|
+
*duration* - duration in milliseconds of the provided chunk. If duration is not provided, it will calculate frame duration wtih the provided frame rate (fps).
|
|
84
|
+
|
|
85
|
+
*compositionTimeOffset* - Composition time offset, difference between decode time and presentation time of frames, in milliseconds. This is only used for video and usually needed when B-frames are present in video stream.
|
|
75
86
|
|
|
76
87
|
**ES6 Example:**
|
|
77
88
|
|
|
@@ -87,8 +98,8 @@ const jmuxer = new JMuxer({
|
|
|
87
98
|
node: 'player',
|
|
88
99
|
debug: true
|
|
89
100
|
});
|
|
90
|
-
|
|
91
|
-
/* Now feed media data using feed method. audio and video is buffer data and duration is in
|
|
101
|
+
|
|
102
|
+
/* Now feed media data using feed method. audio and video is buffer data and duration is in milliseconds */
|
|
92
103
|
jmuxer.feed({
|
|
93
104
|
audio: audio,
|
|
94
105
|
video: video,
|
|
@@ -101,7 +112,7 @@ const jmuxer = new JMuxer({
|
|
|
101
112
|
|
|
102
113
|
Install module through `npm`
|
|
103
114
|
|
|
104
|
-
npm install --save
|
|
115
|
+
npm install --save jmuxer
|
|
105
116
|
|
|
106
117
|
```js
|
|
107
118
|
|
|
@@ -110,7 +121,7 @@ const jmuxer = new JMuxer({
|
|
|
110
121
|
debug: true
|
|
111
122
|
});
|
|
112
123
|
|
|
113
|
-
/*
|
|
124
|
+
/*
|
|
114
125
|
Stream in Object mode. Please check the example file for more details
|
|
115
126
|
*/
|
|
116
127
|
let h264_feeder = getFeederStreamSomehow();
|
|
@@ -130,12 +141,12 @@ h264_feeder.pipe(jmuxer.createStream()).pipe(http_or_ws_or_any);
|
|
|
130
141
|
|
|
131
142
|
**Typescript definition**
|
|
132
143
|
|
|
133
|
-
|
|
144
|
+
|
|
134
145
|
npm install --save @types/jmuxer
|
|
135
146
|
|
|
136
|
-
|
|
147
|
+
|
|
137
148
|
**Compatibility**
|
|
138
|
-
|
|
149
|
+
|
|
139
150
|
compatible with browsers supporting MSE with 'video/MP4. it is supported on:
|
|
140
151
|
|
|
141
152
|
* Chrome for Android 34+
|
|
@@ -159,9 +170,9 @@ A simple node server and some demo media data are available in the example direc
|
|
|
159
170
|
|
|
160
171
|
A step guideline to obtain above the packet format from your mp4 file using ffmpeg:
|
|
161
172
|
1. Spliting video into 2 seconds chunks: `ffmpeg -i input.mp4 -c copy -map 0 -segment_time 2 -f segment %03d.mp4`
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
173
|
+
2. Extracting h264 for all chunks: `for f in *.mp4; do ffmpeg -i "$f" -vcodec copy -an -bsf:v h264_mp4toannexb "${f:0:3}.h264"; done`
|
|
174
|
+
3. Extracting audio for all chunks: `for f in *.mp4; do ffmpeg -i "$f" -acodec copy -vn "${f:0:3}.aac"; done`
|
|
175
|
+
4. Extracting duration for all chunks: `for f in *.mp4; do ffprobe "$f" -show_format 2>&1 | sed -n 's/duration=//p'; done`
|
|
165
176
|
|
|
166
177
|
(see https://github.com/samirkumardas/jmuxer/issues/20#issuecomment-470855007)
|
|
167
178
|
|