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 CHANGED
@@ -1,5 +1,5 @@
1
- [![Build Status](https://travis-ci.org/samirkumardas/jmuxer.svg?branch=master)](https://travis-ci.org/samirkumardas/jmuxer)
2
- ![Maintenance](https://img.shields.io/maintenance/yes/2024.svg)
1
+ [![pages-build-deployment](https://github.com/samirkumardas/jmuxer/actions/workflows/pages/pages-build-deployment/badge.svg)](https://github.com/samirkumardas/jmuxer/actions/workflows/pages/pages-build-deployment)
2
+ ![Maintenance](https://img.shields.io/maintenance/yes/2025.svg)
3
3
  ![license](https://img.shields.io/github/license/mashape/apistatus.svg)
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://samirkumardas.github.io/jmuxer/) to view a working demo
11
+ [Click here](https://webstream-labs.github.io/jmuxer/) to view a working demo
12
12
 
13
- [Click here](https://samirkumardas.github.io/jmuxer/h264_player.html) to play a h264 file online
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
- A simple node server and some demo media data are available in the example directory. In the example, each chunk/packet is consist of 4 bytes of header and the payload following the header. The first two bytes of the header contain the chunk duration and remaining two bytes contain the audio data length. Packet format is shown in the image below:
182
-
183
- **Packet format**
184
-
185
- | 2 bytes | 2 bytes | | |
186
- |-------------|-----------------|----------------|-----------------|
187
- |Duration (ms)|Audio Data Length|Audio Data (AAC)|Video Data (H264)|
188
-
189
- A step guideline to obtain above the packet format from your mp4 file using ffmpeg:
190
- 1. Spliting video into 2 seconds chunks: `ffmpeg -i input.mp4 -c copy -map 0 -segment_time 2 -f segment %03d.mp4`
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
- *node h264.js*
204
+ You can read further details on how they work in `example/server.mjs`.
212
205
 
213
- then, visit *example/h264.html* page using any webserver.
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
  ---------