@alessmicrosystems/mpegts.js 1.8.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.
Files changed (121) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +158 -0
  3. package/README_ja.md +153 -0
  4. package/README_zh.md +157 -0
  5. package/d.ts/mpegts.d.ts +524 -0
  6. package/d.ts/src/core/mse-events.d.ts +9 -0
  7. package/d.ts/src/core/transmuxing-events.d.ts +24 -0
  8. package/d.ts/src/demux/aac.d.ts +44 -0
  9. package/d.ts/src/demux/ac3.d.ts +70 -0
  10. package/d.ts/src/demux/av1-parser.d.ts +77 -0
  11. package/d.ts/src/demux/av1.d.ts +11 -0
  12. package/d.ts/src/demux/base-demuxer.d.ts +55 -0
  13. package/d.ts/src/demux/h264.d.ts +40 -0
  14. package/d.ts/src/demux/h265.d.ts +65 -0
  15. package/d.ts/src/demux/klv.d.ts +17 -0
  16. package/d.ts/src/demux/mp3.d.ts +6 -0
  17. package/d.ts/src/demux/mpeg4-audio.d.ts +28 -0
  18. package/d.ts/src/demux/pat-pmt-pes.d.ts +106 -0
  19. package/d.ts/src/demux/patpmt.d.ts +40 -0
  20. package/d.ts/src/demux/pes-private-data.d.ts +14 -0
  21. package/d.ts/src/demux/pgs-data.d.ts +9 -0
  22. package/d.ts/src/demux/scte35.d.ts +250 -0
  23. package/d.ts/src/demux/sei.d.ts +8 -0
  24. package/d.ts/src/demux/smpte2038.d.ts +22 -0
  25. package/d.ts/src/demux/ts-demuxer.d.ts +124 -0
  26. package/d.ts/src/player/live-latency-chaser.d.ts +10 -0
  27. package/d.ts/src/player/live-latency-synchronizer.d.ts +10 -0
  28. package/d.ts/src/player/loading-controller.d.ts +19 -0
  29. package/d.ts/src/player/mse-player.d.ts +30 -0
  30. package/d.ts/src/player/player-engine-dedicated-thread-worker.d.ts +2 -0
  31. package/d.ts/src/player/player-engine-dedicated-thread.d.ts +48 -0
  32. package/d.ts/src/player/player-engine-main-thread.d.ts +50 -0
  33. package/d.ts/src/player/player-engine-worker-cmd-def.d.ts +25 -0
  34. package/d.ts/src/player/player-engine-worker-msg-def.d.ts +54 -0
  35. package/d.ts/src/player/player-engine-worker.d.ts +2 -0
  36. package/d.ts/src/player/player-engine.d.ts +16 -0
  37. package/d.ts/src/player/player-events.d.ts +21 -0
  38. package/d.ts/src/player/seeking-handler.d.ts +22 -0
  39. package/d.ts/src/player/startup-stall-jumper.d.ts +14 -0
  40. package/d.ts/src/utils/typedarray-equality.d.ts +2 -0
  41. package/dist/mpegts.js +3 -0
  42. package/dist/mpegts.js.LICENSE.txt +7 -0
  43. package/dist/mpegts.js.map +1 -0
  44. package/package.json +53 -0
  45. package/src/config.js +67 -0
  46. package/src/core/features.js +88 -0
  47. package/src/core/media-info.js +127 -0
  48. package/src/core/media-segment-info.js +230 -0
  49. package/src/core/mse-controller.js +599 -0
  50. package/src/core/mse-events.ts +28 -0
  51. package/src/core/transmuxer.js +346 -0
  52. package/src/core/transmuxing-controller.js +628 -0
  53. package/src/core/transmuxing-events.ts +43 -0
  54. package/src/core/transmuxing-worker.js +286 -0
  55. package/src/demux/aac.ts +397 -0
  56. package/src/demux/ac3.ts +335 -0
  57. package/src/demux/amf-parser.js +243 -0
  58. package/src/demux/av1-parser.ts +629 -0
  59. package/src/demux/av1.ts +103 -0
  60. package/src/demux/base-demuxer.ts +69 -0
  61. package/src/demux/demux-errors.js +26 -0
  62. package/src/demux/exp-golomb.js +116 -0
  63. package/src/demux/flv-demuxer.js +1854 -0
  64. package/src/demux/h264.ts +187 -0
  65. package/src/demux/h265-parser.js +501 -0
  66. package/src/demux/h265.ts +214 -0
  67. package/src/demux/klv.ts +40 -0
  68. package/src/demux/mp3.ts +7 -0
  69. package/src/demux/mpeg4-audio.ts +45 -0
  70. package/src/demux/pat-pmt-pes.ts +132 -0
  71. package/src/demux/pes-private-data.ts +16 -0
  72. package/src/demux/pgs-data.ts +11 -0
  73. package/src/demux/scte35.ts +723 -0
  74. package/src/demux/sei.ts +99 -0
  75. package/src/demux/smpte2038.ts +89 -0
  76. package/src/demux/sps-parser.js +298 -0
  77. package/src/demux/ts-demuxer.ts +2405 -0
  78. package/src/index.js +4 -0
  79. package/src/io/fetch-stream-loader.js +266 -0
  80. package/src/io/io-controller.js +647 -0
  81. package/src/io/loader.js +134 -0
  82. package/src/io/param-seek-handler.js +85 -0
  83. package/src/io/range-seek-handler.js +52 -0
  84. package/src/io/speed-sampler.js +93 -0
  85. package/src/io/websocket-loader.js +151 -0
  86. package/src/io/xhr-moz-chunked-loader.js +211 -0
  87. package/src/io/xhr-msstream-loader.js +307 -0
  88. package/src/io/xhr-range-loader.js +366 -0
  89. package/src/mpegts.js +95 -0
  90. package/src/player/live-latency-chaser.ts +66 -0
  91. package/src/player/live-latency-synchronizer.ts +79 -0
  92. package/src/player/loading-controller.ts +142 -0
  93. package/src/player/mse-player.ts +150 -0
  94. package/src/player/native-player.js +262 -0
  95. package/src/player/player-engine-dedicated-thread.ts +479 -0
  96. package/src/player/player-engine-main-thread.ts +463 -0
  97. package/src/player/player-engine-worker-cmd-def.ts +62 -0
  98. package/src/player/player-engine-worker-msg-def.ts +102 -0
  99. package/src/player/player-engine-worker.ts +370 -0
  100. package/src/player/player-engine.ts +35 -0
  101. package/src/player/player-errors.js +39 -0
  102. package/src/player/player-events.ts +40 -0
  103. package/src/player/seeking-handler.ts +205 -0
  104. package/src/player/startup-stall-jumper.ts +86 -0
  105. package/src/remux/aac-silent.js +56 -0
  106. package/src/remux/mp4-generator.js +866 -0
  107. package/src/remux/mp4-remuxer.js +778 -0
  108. package/src/utils/browser.js +128 -0
  109. package/src/utils/exception.js +73 -0
  110. package/src/utils/logger.js +140 -0
  111. package/src/utils/logging-control.js +165 -0
  112. package/src/utils/polyfill.js +68 -0
  113. package/src/utils/typedarray-equality.ts +69 -0
  114. package/src/utils/utf8-conv.js +84 -0
  115. package/src/utils/webworkify-webpack.js +202 -0
  116. package/tsconfig.json +16 -0
  117. package/tslint.json +1 -0
  118. package/types/index.d.ts +3 -0
  119. package/types/test-flv.ts +8 -0
  120. package/types/tsconfig.json +24 -0
  121. package/webpack.config.js +55 -0
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,158 @@
1
+ mpegts.js [![npm](https://img.shields.io/npm/v/mpegts.js.svg?style=flat)](https://www.npmjs.com/package/mpegts.js)
2
+ ======
3
+ [日本語](README_ja.md) [中文说明](README_zh.md)
4
+
5
+ HTML5 MPEG2-TS stream player written in TypeScript & JavaScript.
6
+
7
+ mpegts.js is optimized for low-latency live stream playback, such as DVB/ISDB television or surveillance cameras.
8
+
9
+ This project is based on [flv.js](https://github.com/bilibili/flv.js).
10
+
11
+ ## Overview
12
+ mpegts.js works by transmuxing MPEG2-TS stream into ISO BMFF (Fragmented MP4) segments, followed by feeding mp4 segments into an HTML5 `<video>` element through [Media Source Extensions][] API.
13
+
14
+ [Media Source Extensions]: https://w3c.github.io/media-source/
15
+
16
+ ## News
17
+ - **v1.8.0**
18
+
19
+ Support working on **iOS Safari** with iOS 17.1+ through Apple's [ManagedMediaSource API](https://github.com/w3c/media-source/issues/320)
20
+
21
+ Great performance improvements by supporting [MSE in Workers](https://github.com/w3c/media-source/issues/175) on Chrome, Safari 18 (includes iOS)
22
+
23
+ Introduced support for [AV1 over MPEG-TS](https://aomediacodec.github.io/av1-mpeg2-ts/)
24
+
25
+ Introduced support for AV1 over HTTP-FLV defined in [Enhanced RTMP](https://github.com/veovera/enhanced-rtmp)
26
+
27
+ Support chasing live latency more smoothly by changing playback rate
28
+
29
+ Introduced ATSC EAC-3 audio codec in MPEG-TS
30
+
31
+ Support Opus and FLAC audio codec over HTTP-FLV (Enhanced RTMP)
32
+
33
+ - **v1.7.3**
34
+
35
+ Introduced [Enhanced RTMP] with HEVC support for FLV.
36
+
37
+ Introduced Opus and ATSC AC-3 audio codec support for MPEG-TS.
38
+
39
+ Introduced LOAS AAC support for MPEG-TS.
40
+
41
+ - **v1.7.0**
42
+
43
+ Introduced H.265/HEVC over MPEG-TS/FLV support.
44
+
45
+ [Enhanced RTMP]: https://github.com/veovera/enhanced-rtmp
46
+ ## Demo
47
+ [http://xqq.github.io/mpegts.js/demo/](http://xqq.github.io/mpegts.js/demo/)
48
+
49
+ [demo with aribb24.js](http://xqq.github.io/mpegts.js/demo/arib.html)
50
+
51
+ ## Features
52
+ - Playback for MPEG2-TS stream with H.264/H.265 + AAC codec transported in http(s) or WebSocket
53
+ - Playback for FLV stream with H.264/H.265 + AAC codec transported in http(s) or WebSocket
54
+ - Extremely low latency of less than 1 second in the best case
55
+ - Playback for `.m2ts` file like BDAV/BDMV with 192 bytes TS packet, or 204 bytes TS packet
56
+ - Support handling dynamic codec parameters change (e.g. video resolution change)
57
+ - Support Chrome, FireFox, Safari, Edge (Old or Chromium) or any Chromium-based browsers
58
+ - Support chasing latency automatically for internal buffer of HTMLMediaElement
59
+ - Low CPU overhead and low memory usage (JS heap takes about 10MiB for each instance)
60
+ - Support extracting PES private data (stream_type=0x06) like ARIB B24 subtitles (with [aribb24.js][])
61
+ - Support Timed ID3 Metadata (stream_type=0x15) callback (TIMED_ID3_METADATA_ARRIVED)
62
+
63
+ [aribb24.js]: https://github.com/monyone/aribb24.js
64
+
65
+ ## CORS
66
+ If you use standalone video server for MPEG2-TS stream, `Access-Control-Allow-Origin` header must be configured correctly on video server for cross-origin resource fetching.
67
+
68
+ See [cors.md](docs/cors.md) for more details.
69
+
70
+ ## Installation
71
+ ```bash
72
+ npm install --save mpegts.js
73
+ ```
74
+
75
+ ## Build
76
+ ```bash
77
+ npm install # install dev-dependencies
78
+ npm install -g webpack-cli # install build tool
79
+ npm run build # packaged & minimized js will be emitted in dist folder
80
+ ```
81
+
82
+ [cnpm](https://github.com/cnpm/cnpm) mirror is recommended if you are in Mainland China.
83
+
84
+ ## Getting Started
85
+ ```html
86
+ <script src="mpegts.js"></script>
87
+ <video id="videoElement"></video>
88
+ <script>
89
+ if (mpegts.getFeatureList().mseLivePlayback) {
90
+ var videoElement = document.getElementById('videoElement');
91
+ var player = mpegts.createPlayer({
92
+ type: 'mse', // could also be mpegts, m2ts, flv
93
+ isLive: true,
94
+ url: 'http://example.com/live/livestream.ts'
95
+ });
96
+ player.attachMediaElement(videoElement);
97
+ player.load();
98
+ player.play();
99
+ }
100
+ </script>
101
+ ```
102
+ mpegts.js could be tested with [Simple Realtime Server](https://github.com/ossrs/srs/).
103
+
104
+ ## TODO
105
+ - MPEG2-TS static file playback (seeking is not supported now)
106
+
107
+ ## Limitations
108
+ - mpeg2video is not supported
109
+ - HTTP MPEG2-TS live stream could not work on old browsers like IE11
110
+ - mpegts.js is not usable on iOS version 17.0 or older caused by the banning of [Media Source Extensions][] (available on iPadOS), iOS 17.1 works through Managed Media Source API
111
+
112
+ ## Features inherited from flv.js
113
+ - FLV container with H.264 + AAC / MP3 codec playback
114
+ - Multipart segmented video playback
115
+ - HTTP FLV low latency live stream playback
116
+ - FLV over WebSocket live stream playback
117
+ - Compatible with Chrome, FireFox, Safari 10, IE11 and Edge
118
+ - Extremely low overhead, and hardware accelerated by your browser!
119
+
120
+ ## FLV playback limitations
121
+ - MP3 audio codec is currently not working on IE11 / Edge
122
+ - HTTP FLV live stream is not currently working on all browsers, see [livestream.md](docs/livestream.md)
123
+
124
+ ## FLV Multipart playback
125
+ You only have to provide a playlist for `MediaDataSource`. See [multipart.md](docs/multipart.md)
126
+
127
+ ## Livestream playback
128
+ See [livestream.md](docs/livestream.md)
129
+
130
+ ## API and Configuration
131
+ See [api.md](docs/api.md)
132
+
133
+ ## Debug
134
+ ```bash
135
+ npm install # install dev-dependencies
136
+ npm install -g webpack-cli # install build tool
137
+ npm run build:debug # packaged & minimized js will be emitted in dist folder
138
+ ```
139
+
140
+ ## Design
141
+ See [design.md](docs/design.md)
142
+
143
+ ## License
144
+ ```
145
+ Copyright (C) 2021 magicxqq. All Rights Reserved.
146
+
147
+ Licensed under the Apache License, Version 2.0 (the "License");
148
+ you may not use this file except in compliance with the License.
149
+ You may obtain a copy of the License at
150
+
151
+ http://www.apache.org/licenses/LICENSE-2.0
152
+
153
+ Unless required by applicable law or agreed to in writing, software
154
+ distributed under the License is distributed on an "AS IS" BASIS,
155
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
156
+ See the License for the specific language governing permissions and
157
+ limitations under the License.
158
+ ```
package/README_ja.md ADDED
@@ -0,0 +1,153 @@
1
+ mpegts.js [![npm](https://img.shields.io/npm/v/mpegts.js.svg?style=flat)](https://www.npmjs.com/package/mpegts.js)
2
+ ======
3
+ MPEG2-TS ストリームを HTML5 上で再生するビデオプレーヤーです。
4
+
5
+ mpegts.js はライブ配信に対し、低遅延再生のために最適化しています。DVB/ISDB のテレビチャンネルや監視カメラの映像等を低遅延で再生可能になります。
6
+
7
+ mpegts.js は [flv.js](https://github.com/bilibili/flv.js) を基づいて作ってきたものです。
8
+
9
+ ## Overview
10
+ mpegts.js は、JavaScript で MPEG2-TS ストリームを解析しながら、映像と音声のデータを ISO BMFF (fmp4) フォーマットのフラグメントにリマックスして、[Media Source Extensions][] を通じて `<video>` 要素に提供することで再生することにしています。
11
+
12
+ [Media Source Extensions]: https://w3c.github.io/media-source/
13
+
14
+ ## News
15
+ - **v1.8.0**
16
+
17
+ **iOS Safari**(iOS 17.1+)での動作をサポートし、Apple の [ManagedMediaSource API](https://github.com/w3c/media-source/issues/320) を使用
18
+
19
+ [MSE in Workers](https://github.com/w3c/media-source/issues/175) 利用により、パフォーマンスが大幅に向上:Chrome と Safari 18(iOS 含む)対応
20
+
21
+ [AV1 over MPEG-TS](https://aomediacodec.github.io/av1-mpeg2-ts/) をサポート
22
+
23
+ [Enhanced RTMP](https://github.com/veovera/enhanced-rtmp) の定義による AV1 over HTTP-FLV をサポート
24
+
25
+ 再生速度を動的に変更することで、ライブ遅延の追従をよりスムーズにできる
26
+
27
+ MPEG-TS に ATSC EAC-3 音声サポートを追加
28
+
29
+ HTTP-FLV(Enhanced RTMP)で Opus および FLAC 音声サポートを追加
30
+
31
+ - **v1.7.3**
32
+
33
+ [Enhanced RTMP](https://github.com/veovera/enhanced-rtmp) における FLV での HEVC 転送の仕様をサポート
34
+
35
+ MPEG-TS に Opus および ATSC AC-3 音声コーデックのサポートを追加
36
+
37
+ MPEG-TS に LOAS AAC 再生のサポートを追加
38
+
39
+ - **v1.7.0**
40
+
41
+ H.265/HEVC 再生のサポートを追加(FLV および MPEG-TS の両方で対応)
42
+
43
+
44
+ ## Demo
45
+ [http://xqq.github.io/mpegts.js/demo/](http://xqq.github.io/mpegts.js/demo/)
46
+
47
+ [demo with aribb24.js](http://xqq.github.io/mpegts.js/demo/arib.html)
48
+
49
+ ## Features
50
+ - http(s) または WebSocket で伝送する H.264 + AAC の MPEG2-TS ストリームが再生可能
51
+ - 最良の場合は 1 秒以内の低遅延が達成可能
52
+ - TS packet が 192 bytes の `.m2ts` ファイル(BDAV/BDMV)、または 204 bytes も再生可能
53
+ - 動的パラメータ切り替えが可能 (例えば、映像解像度が途中に切り替わっても再生します)
54
+ - Chrome, FireFox, Safari, Edge (Old or Chromium) または Chromium-based ブラウザで実行可能
55
+ - HTMLMediaElement 内部バッファーの遅延を追いかける機能
56
+ - 低い CPU 使用率とメモリ使用量 (1つのインスタンスが概ね 10MiB のメモリかかります)
57
+ - ARIB-B24 字幕等の PES private data (stream_type=0x06) が抽出可能 ([aribb24.js][] と共同運用可能)
58
+ - Timed ID3 Metadata (stream_type=0x15) のコールバック支援 (TIMED_ID3_METADATA_ARRIVED)
59
+
60
+ [aribb24.js]: https://github.com/monyone/aribb24.js
61
+
62
+ ## CORS
63
+ MPEG2-TS ストリームが別のサーバー上にある場合、`Access-Control-Allow-Origin` は必須です。
64
+
65
+ [cors.md](docs/cors.md) を参照してください。
66
+
67
+ ## Installation
68
+ ```bash
69
+ npm install --save mpegts.js
70
+ ```
71
+
72
+ ## Build
73
+ ```bash
74
+ npm install # install dev-dependencies
75
+ npm install -g webpack-cli # install build tool
76
+ npm run build # packaged & minimized js will be emitted in dist folder
77
+ ```
78
+
79
+ ## Getting Started
80
+ ```html
81
+ <script src="mpegts.js"></script>
82
+ <video id="videoElement"></video>
83
+ <script>
84
+ if (mpegts.getFeatureList().mseLivePlayback) {
85
+ var videoElement = document.getElementById('videoElement');
86
+ var player = mpegts.createPlayer({
87
+ type: 'mse', // could also be mpegts, m2ts, flv
88
+ isLive: true,
89
+ url: 'http://example.com/live/livestream.ts'
90
+ });
91
+ player.attachMediaElement(videoElement);
92
+ player.load();
93
+ player.play();
94
+ }
95
+ </script>
96
+ ```
97
+ [Simple Realtime Server](https://github.com/ossrs/srs/) を用いて mpegts.js をテストすることができます。
98
+
99
+ ## TODO
100
+ - 静的 MPEG2-TS ファイルの再生 (現時点ではシークできません)
101
+
102
+ ## Limitations
103
+ - mpeg2video はサポートしていません。映像は H.264 であることが求められます
104
+ - IE11 などの古いブラウザでは、HTTP MPEG2-TS がライブ視聴できません
105
+ - iOS では、[Media Source Extensions][] が禁じられたため使えませんが、iPadOS では使用可能
106
+
107
+ ## Features inherited from flv.js
108
+ - H.264 + AAC/MP3 codec の FLV ファイルが再生可能
109
+ - マルチパットな複数の FLV ファイルも一緒に再生可能
110
+ - HTTP FLV のライブストリームが低遅延で再生可能
111
+ - WebSocket で伝送する FLV ストリームも再生可能
112
+ - Chrome, FireFox, Safari 10, IE11 and Edge のブラウザで実行可能
113
+ - ブラウザによる hardware accelerated があるためコストは非常に低い
114
+
115
+ ## FLV playback limitations
116
+ - MP3 audio codec は IE11 / Edge でサポートされていません
117
+ - HTTP FLV のライブストリームは一部のブラウザで再生できません。[livestream.md](docs/livestream.md) を参照
118
+
119
+ ## FLV Multipart playback
120
+ [multipart.md](docs/multipart.md) を参照
121
+
122
+ ## Livestream playback
123
+ [livestream.md](docs/livestream.md) を参照
124
+
125
+ ## API and Configuration
126
+ [api.md](docs/api.md) を参照
127
+
128
+ ## Debug
129
+ ```bash
130
+ npm install # install dev-dependencies
131
+ npm install -g webpack-cli # install build tool
132
+ npm run build:debug # packaged & minimized js will be emitted in dist folder
133
+ ```
134
+
135
+ ## Design
136
+ [design.md](docs/design.md) を参照
137
+
138
+ ## License
139
+ ```
140
+ Copyright (C) 2021 magicxqq. All Rights Reserved.
141
+
142
+ Licensed under the Apache License, Version 2.0 (the "License");
143
+ you may not use this file except in compliance with the License.
144
+ You may obtain a copy of the License at
145
+
146
+ http://www.apache.org/licenses/LICENSE-2.0
147
+
148
+ Unless required by applicable law or agreed to in writing, software
149
+ distributed under the License is distributed on an "AS IS" BASIS,
150
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
151
+ See the License for the specific language governing permissions and
152
+ limitations under the License.
153
+ ```
package/README_zh.md ADDED
@@ -0,0 +1,157 @@
1
+ mpegts.js [![npm](https://img.shields.io/npm/v/mpegts.js.svg?style=flat)](https://www.npmjs.com/package/mpegts.js)
2
+ ======
3
+ [日本語](README_ja.md)
4
+
5
+ mpegts.js 是在 HTML5 上直接播放 MPEG2-TS 流的播放器,针对低延迟直播优化,可用于 DVB/ISDB 数字电视流或监控摄像头等的低延迟回放。
6
+
7
+ mpegts.js 基于 [flv.js](https://github.com/bilibili/flv.js) 改造而来。
8
+
9
+ ## Overview
10
+ mpegts.js 通过在 JavaScript 中渐进化解析 MPEG2-TS 流并实时转封装为 ISO BMFF (Fragmented MP4),然后通过 [Media Source Extensions][] 把音视频数据喂入 HTML5 `<video>` 元素。
11
+
12
+ [Media Source Extensions]: https://w3c.github.io/media-source/
13
+
14
+ ## News
15
+ - **v1.8.0**
16
+
17
+ 支持在 **iOS Safari**(iOS 17.1+)上运行,使用 Apple [ManagedMediaSource API](https://github.com/w3c/media-source/issues/320)
18
+
19
+ 通过使用 [MSE in Workers](https://github.com/w3c/media-source/issues/175) 来显著提升性能(适用于 Chrome 和 Safari 18,包括 iOS)
20
+
21
+ 支持 [AV1 over MPEG-TS](https://aomediacodec.github.io/av1-mpeg2-ts/)
22
+
23
+ 支持 AV1 over HTTP-FLV,定义于 [Enhanced RTMP](https://github.com/veovera/enhanced-rtmp)
24
+
25
+ 支持更平滑的直播延迟追赶(通过动态改变播放速率)
26
+
27
+ MPEG-TS 新增 ATSC EAC-3 音频支持
28
+
29
+ HTTP-FLV(Enhanced RTMP)新增 Opus 和 FLAC 音频支持
30
+
31
+ - **v1.7.3**
32
+
33
+ 支持 [Enhanced RTMP] 中关于 FLV 传输 HEVC 的规范
34
+
35
+ MPEG-TS 新增了对 Opus 和 ATSC AC-3 音频编码支持
36
+
37
+ MPEG-TS 新增了 LOAS AAC 播放支持
38
+
39
+ - **v1.7.0**
40
+
41
+ H.265/HEVC 播放支持(FLV 或 MPEG-TS 均已支持)
42
+
43
+ [Enhanced RTMP]: https://github.com/veovera/enhanced-rtmp
44
+
45
+ ## Demo
46
+ [http://xqq.github.io/mpegts.js/demo/](http://xqq.github.io/mpegts.js/demo/)
47
+
48
+ [demo with aribb24.js](http://xqq.github.io/mpegts.js/demo/arib.html)
49
+
50
+ ## Features
51
+ - 回放 http(s) 或 WebSocket 上承载的 H.264/H.265 + AAC 编码的 MPEG2-TS 流
52
+ - 回放 http(s) 或 WebSocket 上承载的 H.264/H.265 + AAC 编码的 FLV 流
53
+ - 超低延迟,最佳情况延迟可低达 1 秒以内
54
+ - 回放 TS packet 为 192 字节的 `.m2ts` 文件(BDAV/BDMV)或 204 字节的 TS 流
55
+ - 支持动态编码参数切换,如视频分辨率动态变化
56
+ - 支持 Chrome, FireFox, Safari, Edge (Old or Chromium) 或任何基于 Chromium 的浏览器
57
+ - 支持对 HTMLMediaElement 内部缓冲的自动延迟追赶
58
+ - 极低的 CPU 使用率和内存使用量(单个实例约使用 JS 堆 10MiB)
59
+ - 支持 PES private data 回调 (stream_type=0x06),如 ARIB B24 字幕 (可配合 [aribb24.js][])
60
+ - 支持 Timed ID3 Metadata (stream_type=0x15) 回调 (TIMED_ID3_METADATA_ARRIVED)
61
+
62
+ [aribb24.js]: https://github.com/monyone/aribb24.js
63
+
64
+ ## CORS
65
+ 若在与页面不同的独立的服务器串流,必须设置 CORS 的 `Access-Control-Allow-Origin` 头。
66
+
67
+ 参阅 [cors.md](docs/cors.md)。
68
+
69
+ ## Installation
70
+ ```bash
71
+ npm install --save mpegts.js
72
+ ```
73
+
74
+ ## Build
75
+ ```bash
76
+ npm install # install dev-dependencies
77
+ npm install -g webpack-cli # install build tool
78
+ npm run build # packaged & minimized js will be emitted in dist folder
79
+ ```
80
+
81
+ 若在中国大陆可尝试 [cnpm](https://github.com/cnpm/cnpm) 镜像。
82
+
83
+ ## Getting Started
84
+ ```html
85
+ <script src="mpegts.js"></script>
86
+ <video id="videoElement"></video>
87
+ <script>
88
+ if (mpegts.getFeatureList().mseLivePlayback) {
89
+ var videoElement = document.getElementById('videoElement');
90
+ var player = mpegts.createPlayer({
91
+ type: 'mse', // could also be mpegts, m2ts, flv
92
+ isLive: true,
93
+ url: 'http://example.com/live/livestream.ts'
94
+ });
95
+ player.attachMediaElement(videoElement);
96
+ player.load();
97
+ player.play();
98
+ }
99
+ </script>
100
+ ```
101
+ 可使用 [Simple Realtime Server](https://github.com/ossrs/srs/) 来测试 mpegts.js。
102
+
103
+ ## TODO
104
+ - MPEG2-TS 静态文件回放 (目前还不支持 seek)
105
+
106
+ ## Limitations
107
+ - 不支持 mpeg2video
108
+ - IE11 等旧浏览器不支持 HTTP MPEG2-TS/FLV 直播流回放
109
+ - iOS 由于屏蔽了 [Media Source Extensions][] 因而无法使用,但在 iPadOS 上可用
110
+
111
+ ## Features inherited from flv.js
112
+ - H.264 + AAC / MP3 编码的 FLV 文件回放
113
+ - 多分段 FLV 视频无缝播放
114
+ - HTTP FLV 低延迟直播流回放
115
+ - FLV over WebSocket 直播流回放
116
+ - 兼容 Chrome, FireFox, Safari 10, IE11, Edge
117
+ - 超低开销并且由你的浏览器硬件加速
118
+
119
+ ## FLV playback limitations
120
+ - MP3 编码在 IE11 和旧版 Edge 上不受支持
121
+ - HTTP FLV 直播不支持部分旧浏览器,参阅 [livestream.md](docs/livestream.md)
122
+
123
+ ## FLV Multipart playback
124
+ 多段播放需要在 `MediaDataSource` 中提供文件列表。参阅 [multipart.md](docs/multipart.md)
125
+
126
+ ## Livestream playback
127
+ 参阅 [livestream.md](docs/livestream.md)
128
+
129
+ ## API and Configuration
130
+ 参阅 [api.md](docs/api.md)
131
+
132
+ ## Debug
133
+ ```bash
134
+ npm install # install dev-dependencies
135
+ npm install -g webpack-cli # install build tool
136
+ npm run build:debug # packaged & minimized js will be emitted in dist folder
137
+ ```
138
+
139
+ ## Design
140
+ 参阅 [design.md](docs/design.md)
141
+
142
+ ## License
143
+ ```
144
+ Copyright (C) 2021 magicxqq. All Rights Reserved.
145
+
146
+ Licensed under the Apache License, Version 2.0 (the "License");
147
+ you may not use this file except in compliance with the License.
148
+ You may obtain a copy of the License at
149
+
150
+ http://www.apache.org/licenses/LICENSE-2.0
151
+
152
+ Unless required by applicable law or agreed to in writing, software
153
+ distributed under the License is distributed on an "AS IS" BASIS,
154
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
155
+ See the License for the specific language governing permissions and
156
+ limitations under the License.
157
+ ```