jmuxer 2.0.7 → 2.1.1
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 +29 -36
- package/dist/jmuxer.js +2770 -2020
- package/dist/jmuxer.min.js +1 -1
- package/eslint.config.mjs +21 -0
- package/package.json +20 -28
- package/rollup.config.js +13 -4
- package/src/controller/remux.js +63 -46
- package/src/jmuxer.js +40 -145
- package/src/parsers/aac.js +11 -38
- package/src/parsers/h264.js +106 -99
- package/src/parsers/h265.js +489 -0
- package/src/remuxer/aac.js +63 -7
- package/src/remuxer/base.js +2 -1
- package/src/remuxer/h264.js +176 -16
- package/src/remuxer/h265.js +295 -0
- package/src/util/debug.js +3 -5
- package/src/util/event.js +2 -2
- package/src/util/mp4-generator.js +124 -9
- package/src/util/utils.js +20 -0
- package/.idea/codeStyles/Project.xml +0 -13
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/inspectionProfiles/Project_Default.xml +0 -6
- package/.idea/jmuxer.iml +0 -9
- package/.idea/misc.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/vcs.xml +0 -6
- package/karma.conf.js +0 -77
- package/loader-thumb.jpg +0 -0
- package/packet-format.png +0 -0
- package/src/util/nalu.js +0 -72
- package/test/event.js +0 -30
- package/test/parser.js +0 -35
- package/test/utils.js +0 -19
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
[](https://github.com/samirkumardas/jmuxer/actions/workflows/pages/pages-build-deployment)
|
|
2
|
+

|
|
3
3
|

|
|
4
4
|
|
|
5
5
|
jMuxer
|
|
@@ -8,9 +8,9 @@ jMuxer - a simple javascript mp4 muxer that works in both browser and node envir
|
|
|
8
8
|
|
|
9
9
|
Live Demo
|
|
10
10
|
-------
|
|
11
|
-
[Click here](https://
|
|
11
|
+
[Click here](https://webstream-labs.github.io/jmuxer/) to view a working demo
|
|
12
12
|
|
|
13
|
-
[Click here](https://
|
|
13
|
+
[Click here](https://webstream-labs.github.io/jmuxer/h264_player.html) to play a h264 file online
|
|
14
14
|
|
|
15
15
|
How to use?
|
|
16
16
|
-------
|
|
@@ -28,6 +28,8 @@ Available options are:
|
|
|
28
28
|
|
|
29
29
|
*mode* - Available values are: both, video and audio. Default is both
|
|
30
30
|
|
|
31
|
+
*videoCodec* - Either H264 or H265 (browser must support H265 to work). Default is H264
|
|
32
|
+
|
|
31
33
|
*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
34
|
|
|
33
35
|
*maxDelay* - Maximum delay time in milliseconds. Default value is 500 milliseconds.
|
|
@@ -44,12 +46,20 @@ Available options are:
|
|
|
44
46
|
|
|
45
47
|
*onError* - function. Will be fired if jMuxer encounters any buffer related errors.
|
|
46
48
|
|
|
49
|
+
*onUnsupportedCodec* - function. Will be fired when trying to play a codec that is not supported by the browser.
|
|
50
|
+
|
|
47
51
|
*onMissingVideoFrames* - function. Will be fired if jMuxer encounters any missing video frames.
|
|
48
52
|
|
|
49
53
|
*onMissingAudioFrames* - function. Will be fired if jMuxer encounters any missing audio frames.
|
|
50
54
|
|
|
55
|
+
*onKeyframePosition* - function. Will be fired when a keyframe is detected thus the provided time is seekable.
|
|
56
|
+
|
|
51
57
|
*debug* - true/false. Will print debug log in browser console. Default is false.
|
|
52
58
|
|
|
59
|
+
*onLoggerLog* - function. When debug enabled, will be called to log basic information. Defaults to console.log
|
|
60
|
+
|
|
61
|
+
*onLoggerErr* - function. When debug enabled, will be called to log errors information. Defaults to console.error
|
|
62
|
+
|
|
53
63
|
**Complete example:**
|
|
54
64
|
|
|
55
65
|
```html
|
|
@@ -78,7 +88,7 @@ Available options are:
|
|
|
78
88
|
|
|
79
89
|
Media dataObject may have following properties:
|
|
80
90
|
|
|
81
|
-
*video* - h264 buffer
|
|
91
|
+
*video* - h264/h265 buffer
|
|
82
92
|
|
|
83
93
|
*audio* - AAC buffer
|
|
84
94
|
|
|
@@ -86,6 +96,8 @@ Media dataObject may have following properties:
|
|
|
86
96
|
|
|
87
97
|
*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.
|
|
88
98
|
|
|
99
|
+
*isLastVideoFrameComplete* - true/false. whether the last frame in the buffer provided is complete and can be immediatly pushed to the remuxer. Frame in this context refers to a H264/H265 frame, which might or might not correspond to a frame of video. This flag allows to remove a 1 frame delay which is naturally present because jMuxer doesn't know if the data it received is complete unless the next NALU header is received; use this only if you are sure of it, otherwise issues may arrise. Defaults to false.
|
|
100
|
+
|
|
89
101
|
**ES6 Example:**
|
|
90
102
|
|
|
91
103
|
Install module through `npm`
|
|
@@ -178,39 +190,20 @@ jmuxer.feed({
|
|
|
178
190
|
|
|
179
191
|
Demo Server and player example
|
|
180
192
|
-----------
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
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`
|
|
192
|
-
3. Extracting audio for all chunks: `for f in *.mp4; do ffmpeg -i "$f" -acodec copy -vn "${f:0:3}.aac"; done`
|
|
193
|
-
4. Extracting duration for all chunks: `for f in *.mp4; do ffprobe "$f" -show_format 2>&1 | sed -n 's/duration=//p'; done`
|
|
194
|
-
|
|
195
|
-
(see https://github.com/samirkumardas/jmuxer/issues/20#issuecomment-470855007)
|
|
196
|
-
|
|
197
|
-
**How to run example?**
|
|
198
|
-
|
|
199
|
-
Demo files are available in example directory. For running the example, first run the node server by following command:
|
|
200
|
-
|
|
201
|
-
*cd example*
|
|
202
|
-
|
|
203
|
-
*node server.js*
|
|
204
|
-
|
|
205
|
-
then, visit *example/index.html* page using any webserver.
|
|
206
|
-
|
|
207
|
-
Player Example for raw h264 only
|
|
208
|
-
-----------
|
|
209
|
-
Assuming you are still in `example` directory. Now run followngs:
|
|
193
|
+
Two demos are given:
|
|
194
|
+
1. Raw chunks from server, client does the muxing
|
|
195
|
+
2. Muxed by server, fMP4 streamed from server
|
|
196
|
+
|
|
197
|
+
To try them both, in the root directory run
|
|
198
|
+
```bash
|
|
199
|
+
npm i
|
|
200
|
+
npm run dev
|
|
201
|
+
```
|
|
202
|
+
then navigate to `http://localhost:8080/
|
|
210
203
|
|
|
211
|
-
|
|
204
|
+
You can read further details on how they work in `example/server.mjs`.
|
|
212
205
|
|
|
213
|
-
|
|
206
|
+
To generate the segments for the last demo, you can use the bash script in the chunks folder.
|
|
214
207
|
|
|
215
208
|
How to build?
|
|
216
209
|
---------
|