jmuxer 2.0.7 → 2.1.0

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
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)
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
@@ -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
 
@@ -178,39 +188,20 @@ jmuxer.feed({
178
188
 
179
189
  Demo Server and player example
180
190
  -----------
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:
191
+ Two demos are given:
192
+ 1. Raw chunks from server, client does the muxing
193
+ 2. Muxed by server, fMP4 streamed from server
194
+
195
+ To try them both, in the root directory run
196
+ ```bash
197
+ npm i
198
+ npm run dev
199
+ ```
200
+ then navigate to `http://localhost:8080/
210
201
 
211
- *node h264.js*
202
+ You can read further details on how they work in `example/server.mjs`.
212
203
 
213
- then, visit *example/h264.html* page using any webserver.
204
+ To generate the segments for the last demo, you can use the bash script in the chunks folder.
214
205
 
215
206
  How to build?
216
207
  ---------