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 CHANGED
@@ -14,7 +14,7 @@ Live Demo
14
14
 
15
15
  How to use?
16
16
  -------
17
- a distribution version is available on dist folder.
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 seconds. Default value is 1500 miliseconds.
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
- *clearBuffer* - true/false. Either it will clear played media buffer automatically or not. Default is true.
33
+ *maxDelay* - Maximum delay time in milliseconds. Default value is 500 milliseconds.
34
34
 
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.
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 miliseconds */
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
- *video* - h264 buffer
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 miliseconds of the provided chunk. If duration is not provided, it will calculate frame duration wtih the provided frame rate (fps).
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 miliseconds */
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-dev jmuxer
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
- 1. 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`
160
- 1. Extracting audio for all chunks: `for f in *.mp4; do ffmpeg -i "$f" -acodec copy -vn "${f:0:3}.aac"; done`
161
- 1. Extracting duration for all chunks: `for f in *.mp4; do ffprobe "$f" -show_format 2>&1 | sed -n 's/duration=//p'; done`
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