jmuxer 2.0.1 → 2.0.4
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 +22 -14
- package/dist/jmuxer.js +314 -158
- 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 +5 -2
- package/src/jmuxer.js +116 -50
- package/src/parsers/h264.js +33 -8
- package/src/remuxer/aac.js +3 -3
- package/src/remuxer/h264.js +5 -3
- package/src/util/exp-golomb.js +6 -0
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ Live Demo
|
|
|
14
14
|
|
|
15
15
|
How to use?
|
|
16
16
|
-------
|
|
17
|
-
|
|
17
|
+
A distribution version is available on dist folder.
|
|
18
18
|
|
|
19
19
|
```html
|
|
20
20
|
<script type="text/javascript" src="dist/jmuxer.min.js"></script>
|
|
@@ -24,18 +24,24 @@ How to use?
|
|
|
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
32
|
|
|
33
|
-
*
|
|
33
|
+
*maxDelay* - Maximum delay time in milliseconds. Default value is 500 milliseconds.
|
|
34
34
|
|
|
35
|
-
*
|
|
35
|
+
*clearBuffer* - true/false. Either it will clear played media buffer automatically or not. Default is true.
|
|
36
|
+
|
|
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
|
|
|
43
|
+
*onError* - function. Will be fired if jMuxer encounters any buffer error.
|
|
44
|
+
|
|
39
45
|
*debug* - true/false. Will print debug log in browser console. Default is false.
|
|
40
46
|
|
|
41
47
|
**Complete example:**
|
|
@@ -53,7 +59,7 @@ Available options are:
|
|
|
53
59
|
debug: false
|
|
54
60
|
});
|
|
55
61
|
|
|
56
|
-
/* Now feed media data using feed method. audio and video is buffer data and duration is in
|
|
62
|
+
/* Now feed media data using feed method. audio and video is buffer data and duration is in milliseconds */
|
|
57
63
|
jmuxer.feed({
|
|
58
64
|
audio: audio,
|
|
59
65
|
video: video,
|
|
@@ -63,13 +69,14 @@ Available options are:
|
|
|
63
69
|
</script>
|
|
64
70
|
|
|
65
71
|
```
|
|
66
|
-
Media dataObject may have folloiwng properties:
|
|
67
72
|
|
|
68
|
-
|
|
73
|
+
Media dataObject may have following properties:
|
|
74
|
+
|
|
75
|
+
*video* - h264 buffer
|
|
69
76
|
|
|
70
77
|
*audio* - AAC buffer
|
|
71
78
|
|
|
72
|
-
*duration* - duration in
|
|
79
|
+
*duration* - duration in milliseconds of the provided chunk. If duration is not provided, it will calculate frame duration wtih the provided frame rate (fps).
|
|
73
80
|
|
|
74
81
|
**ES6 Example:**
|
|
75
82
|
|
|
@@ -86,7 +93,7 @@ const jmuxer = new JMuxer({
|
|
|
86
93
|
debug: true
|
|
87
94
|
});
|
|
88
95
|
|
|
89
|
-
/* Now feed media data using feed method. audio and video is buffer data and duration is in
|
|
96
|
+
/* Now feed media data using feed method. audio and video is buffer data and duration is in milliseconds */
|
|
90
97
|
jmuxer.feed({
|
|
91
98
|
audio: audio,
|
|
92
99
|
video: video,
|
|
@@ -99,7 +106,7 @@ const jmuxer = new JMuxer({
|
|
|
99
106
|
|
|
100
107
|
Install module through `npm`
|
|
101
108
|
|
|
102
|
-
npm install --save
|
|
109
|
+
npm install --save jmuxer
|
|
103
110
|
|
|
104
111
|
```js
|
|
105
112
|
|
|
@@ -123,6 +130,7 @@ h264_feeder.pipe(jmuxer.createStream()).pipe(http_or_ws_or_any);
|
|
|
123
130
|
| ------------- |:-------------:| -----:|
|
|
124
131
|
| feed | data object | object properites may have audio, video and duration. At least one media property i.e audio or video must be provided. If no duration is provided, it will calculate duration based on fps value |
|
|
125
132
|
| createStream | - | Get a writeable stream to feed buffer. Available on NodeJS only |
|
|
133
|
+
| reset | - | Reset the jmuxer and start over |
|
|
126
134
|
| destroy | - | Destroy the jmuxer instance and release the resources |
|
|
127
135
|
|
|
128
136
|
**Typescript definition**
|
|
@@ -156,9 +164,9 @@ A simple node server and some demo media data are available in the example direc
|
|
|
156
164
|
|
|
157
165
|
A step guideline to obtain above the packet format from your mp4 file using ffmpeg:
|
|
158
166
|
1. Spliting video into 2 seconds chunks: `ffmpeg -i input.mp4 -c copy -map 0 -segment_time 2 -f segment %03d.mp4`
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
167
|
+
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`
|
|
168
|
+
3. Extracting audio for all chunks: `for f in *.mp4; do ffmpeg -i "$f" -acodec copy -vn "${f:0:3}.aac"; done`
|
|
169
|
+
4. Extracting duration for all chunks: `for f in *.mp4; do ffprobe "$f" -show_format 2>&1 | sed -n 's/duration=//p'; done`
|
|
162
170
|
|
|
163
171
|
(see https://github.com/samirkumardas/jmuxer/issues/20#issuecomment-470855007)
|
|
164
172
|
|