@kenzuya/mediabunny 1.26.0 → 1.28.5

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 (237) hide show
  1. package/README.md +1 -1
  2. package/dist/bundles/{mediabunny.mjs → mediabunny.js} +21963 -21388
  3. package/dist/bundles/mediabunny.min.js +490 -0
  4. package/dist/modules/shared/mp3-misc.d.ts.map +1 -1
  5. package/dist/modules/src/adts/adts-demuxer.d.ts +6 -6
  6. package/dist/modules/src/adts/adts-demuxer.d.ts.map +1 -1
  7. package/dist/modules/src/adts/adts-muxer.d.ts +4 -4
  8. package/dist/modules/src/adts/adts-muxer.d.ts.map +1 -1
  9. package/dist/modules/src/adts/adts-reader.d.ts +1 -1
  10. package/dist/modules/src/adts/adts-reader.d.ts.map +1 -1
  11. package/dist/modules/src/avi/avi-demuxer.d.ts +44 -0
  12. package/dist/modules/src/avi/avi-demuxer.d.ts.map +1 -0
  13. package/dist/modules/src/avi/avi-misc.d.ts +88 -0
  14. package/dist/modules/src/avi/avi-misc.d.ts.map +1 -0
  15. package/dist/modules/src/avi/avi-muxer.d.ts +45 -0
  16. package/dist/modules/src/avi/avi-muxer.d.ts.map +1 -0
  17. package/dist/modules/src/avi/riff-writer.d.ts +26 -0
  18. package/dist/modules/src/avi/riff-writer.d.ts.map +1 -0
  19. package/dist/modules/src/codec-data.d.ts +8 -3
  20. package/dist/modules/src/codec-data.d.ts.map +1 -1
  21. package/dist/modules/src/codec.d.ts +10 -10
  22. package/dist/modules/src/codec.d.ts.map +1 -1
  23. package/dist/modules/src/conversion.d.ts +33 -16
  24. package/dist/modules/src/conversion.d.ts.map +1 -1
  25. package/dist/modules/src/custom-coder.d.ts +8 -8
  26. package/dist/modules/src/custom-coder.d.ts.map +1 -1
  27. package/dist/modules/src/demuxer.d.ts +3 -3
  28. package/dist/modules/src/demuxer.d.ts.map +1 -1
  29. package/dist/modules/src/encode.d.ts +8 -8
  30. package/dist/modules/src/encode.d.ts.map +1 -1
  31. package/dist/modules/src/flac/flac-demuxer.d.ts +7 -7
  32. package/dist/modules/src/flac/flac-demuxer.d.ts.map +1 -1
  33. package/dist/modules/src/flac/flac-misc.d.ts +3 -3
  34. package/dist/modules/src/flac/flac-misc.d.ts.map +1 -1
  35. package/dist/modules/src/flac/flac-muxer.d.ts +5 -5
  36. package/dist/modules/src/flac/flac-muxer.d.ts.map +1 -1
  37. package/dist/modules/src/id3.d.ts +3 -3
  38. package/dist/modules/src/id3.d.ts.map +1 -1
  39. package/dist/modules/src/index.d.ts +20 -20
  40. package/dist/modules/src/index.d.ts.map +1 -1
  41. package/dist/modules/src/input-format.d.ts +22 -0
  42. package/dist/modules/src/input-format.d.ts.map +1 -1
  43. package/dist/modules/src/input-track.d.ts +8 -8
  44. package/dist/modules/src/input-track.d.ts.map +1 -1
  45. package/dist/modules/src/input.d.ts +12 -12
  46. package/dist/modules/src/isobmff/isobmff-boxes.d.ts +2 -2
  47. package/dist/modules/src/isobmff/isobmff-boxes.d.ts.map +1 -1
  48. package/dist/modules/src/isobmff/isobmff-demuxer.d.ts +12 -12
  49. package/dist/modules/src/isobmff/isobmff-demuxer.d.ts.map +1 -1
  50. package/dist/modules/src/isobmff/isobmff-misc.d.ts.map +1 -1
  51. package/dist/modules/src/isobmff/isobmff-muxer.d.ts +11 -11
  52. package/dist/modules/src/isobmff/isobmff-muxer.d.ts.map +1 -1
  53. package/dist/modules/src/isobmff/isobmff-reader.d.ts +2 -2
  54. package/dist/modules/src/isobmff/isobmff-reader.d.ts.map +1 -1
  55. package/dist/modules/src/matroska/ebml.d.ts +3 -3
  56. package/dist/modules/src/matroska/ebml.d.ts.map +1 -1
  57. package/dist/modules/src/matroska/matroska-demuxer.d.ts +13 -13
  58. package/dist/modules/src/matroska/matroska-demuxer.d.ts.map +1 -1
  59. package/dist/modules/src/matroska/matroska-input.d.ts +33 -0
  60. package/dist/modules/src/matroska/matroska-input.d.ts.map +1 -0
  61. package/dist/modules/src/matroska/matroska-misc.d.ts.map +1 -1
  62. package/dist/modules/src/matroska/matroska-muxer.d.ts +5 -5
  63. package/dist/modules/src/matroska/matroska-muxer.d.ts.map +1 -1
  64. package/dist/modules/src/media-sink.d.ts +5 -5
  65. package/dist/modules/src/media-sink.d.ts.map +1 -1
  66. package/dist/modules/src/media-source.d.ts +22 -4
  67. package/dist/modules/src/media-source.d.ts.map +1 -1
  68. package/dist/modules/src/metadata.d.ts +2 -2
  69. package/dist/modules/src/metadata.d.ts.map +1 -1
  70. package/dist/modules/src/misc.d.ts +5 -4
  71. package/dist/modules/src/misc.d.ts.map +1 -1
  72. package/dist/modules/src/mp3/mp3-demuxer.d.ts +7 -7
  73. package/dist/modules/src/mp3/mp3-demuxer.d.ts.map +1 -1
  74. package/dist/modules/src/mp3/mp3-muxer.d.ts +4 -4
  75. package/dist/modules/src/mp3/mp3-muxer.d.ts.map +1 -1
  76. package/dist/modules/src/mp3/mp3-reader.d.ts +2 -2
  77. package/dist/modules/src/mp3/mp3-reader.d.ts.map +1 -1
  78. package/dist/modules/src/mp3/mp3-writer.d.ts +1 -1
  79. package/dist/modules/src/mp3/mp3-writer.d.ts.map +1 -1
  80. package/dist/modules/src/muxer.d.ts +4 -4
  81. package/dist/modules/src/muxer.d.ts.map +1 -1
  82. package/dist/modules/src/node.d.ts +1 -1
  83. package/dist/modules/src/ogg/ogg-demuxer.d.ts +7 -7
  84. package/dist/modules/src/ogg/ogg-demuxer.d.ts.map +1 -1
  85. package/dist/modules/src/ogg/ogg-misc.d.ts +1 -1
  86. package/dist/modules/src/ogg/ogg-misc.d.ts.map +1 -1
  87. package/dist/modules/src/ogg/ogg-muxer.d.ts +5 -5
  88. package/dist/modules/src/ogg/ogg-muxer.d.ts.map +1 -1
  89. package/dist/modules/src/ogg/ogg-reader.d.ts +1 -1
  90. package/dist/modules/src/ogg/ogg-reader.d.ts.map +1 -1
  91. package/dist/modules/src/output-format.d.ts +51 -6
  92. package/dist/modules/src/output-format.d.ts.map +1 -1
  93. package/dist/modules/src/output.d.ts +13 -13
  94. package/dist/modules/src/output.d.ts.map +1 -1
  95. package/dist/modules/src/packet.d.ts +1 -1
  96. package/dist/modules/src/packet.d.ts.map +1 -1
  97. package/dist/modules/src/pcm.d.ts.map +1 -1
  98. package/dist/modules/src/reader.d.ts +2 -2
  99. package/dist/modules/src/reader.d.ts.map +1 -1
  100. package/dist/modules/src/sample.d.ts +57 -15
  101. package/dist/modules/src/sample.d.ts.map +1 -1
  102. package/dist/modules/src/source.d.ts +3 -3
  103. package/dist/modules/src/source.d.ts.map +1 -1
  104. package/dist/modules/src/subtitles.d.ts +1 -1
  105. package/dist/modules/src/subtitles.d.ts.map +1 -1
  106. package/dist/modules/src/target.d.ts +2 -2
  107. package/dist/modules/src/target.d.ts.map +1 -1
  108. package/dist/modules/src/tsconfig.tsbuildinfo +1 -1
  109. package/dist/modules/src/wave/riff-writer.d.ts +1 -1
  110. package/dist/modules/src/wave/riff-writer.d.ts.map +1 -1
  111. package/dist/modules/src/wave/wave-demuxer.d.ts +6 -6
  112. package/dist/modules/src/wave/wave-demuxer.d.ts.map +1 -1
  113. package/dist/modules/src/wave/wave-muxer.d.ts +4 -4
  114. package/dist/modules/src/wave/wave-muxer.d.ts.map +1 -1
  115. package/dist/modules/src/writer.d.ts +1 -1
  116. package/dist/modules/src/writer.d.ts.map +1 -1
  117. package/dist/packages/eac3/eac3.wasm +0 -0
  118. package/dist/packages/eac3/mediabunny-eac3.js +1058 -0
  119. package/dist/packages/eac3/mediabunny-eac3.min.js +44 -0
  120. package/dist/packages/mp3-encoder/mediabunny-mp3-encoder.js +694 -0
  121. package/dist/packages/mp3-encoder/mediabunny-mp3-encoder.min.js +58 -0
  122. package/dist/packages/mpeg4/mediabunny-mpeg4.js +1198 -0
  123. package/dist/packages/mpeg4/mediabunny-mpeg4.min.js +44 -0
  124. package/dist/packages/mpeg4/xvid.wasm +0 -0
  125. package/package.json +18 -57
  126. package/dist/bundles/mediabunny.cjs +0 -26140
  127. package/dist/bundles/mediabunny.min.cjs +0 -147
  128. package/dist/bundles/mediabunny.min.mjs +0 -146
  129. package/dist/mediabunny.d.ts +0 -3319
  130. package/dist/modules/shared/mp3-misc.js +0 -147
  131. package/dist/modules/src/adts/adts-demuxer.js +0 -239
  132. package/dist/modules/src/adts/adts-muxer.js +0 -80
  133. package/dist/modules/src/adts/adts-reader.js +0 -63
  134. package/dist/modules/src/codec-data.js +0 -1730
  135. package/dist/modules/src/codec.js +0 -869
  136. package/dist/modules/src/conversion.js +0 -1459
  137. package/dist/modules/src/custom-coder.js +0 -117
  138. package/dist/modules/src/demuxer.js +0 -12
  139. package/dist/modules/src/encode.js +0 -442
  140. package/dist/modules/src/flac/flac-demuxer.js +0 -504
  141. package/dist/modules/src/flac/flac-misc.js +0 -135
  142. package/dist/modules/src/flac/flac-muxer.js +0 -222
  143. package/dist/modules/src/id3.js +0 -848
  144. package/dist/modules/src/index.js +0 -28
  145. package/dist/modules/src/input-format.js +0 -480
  146. package/dist/modules/src/input-track.js +0 -372
  147. package/dist/modules/src/input.js +0 -188
  148. package/dist/modules/src/isobmff/isobmff-boxes.js +0 -1480
  149. package/dist/modules/src/isobmff/isobmff-demuxer.js +0 -2618
  150. package/dist/modules/src/isobmff/isobmff-misc.js +0 -20
  151. package/dist/modules/src/isobmff/isobmff-muxer.js +0 -966
  152. package/dist/modules/src/isobmff/isobmff-reader.js +0 -72
  153. package/dist/modules/src/matroska/ebml.js +0 -653
  154. package/dist/modules/src/matroska/matroska-demuxer.js +0 -2133
  155. package/dist/modules/src/matroska/matroska-misc.js +0 -20
  156. package/dist/modules/src/matroska/matroska-muxer.js +0 -1017
  157. package/dist/modules/src/media-sink.js +0 -1736
  158. package/dist/modules/src/media-source.js +0 -1825
  159. package/dist/modules/src/metadata.js +0 -193
  160. package/dist/modules/src/misc.js +0 -623
  161. package/dist/modules/src/mp3/mp3-demuxer.js +0 -285
  162. package/dist/modules/src/mp3/mp3-muxer.js +0 -123
  163. package/dist/modules/src/mp3/mp3-reader.js +0 -26
  164. package/dist/modules/src/mp3/mp3-writer.js +0 -78
  165. package/dist/modules/src/muxer.js +0 -50
  166. package/dist/modules/src/node.js +0 -9
  167. package/dist/modules/src/ogg/ogg-demuxer.js +0 -763
  168. package/dist/modules/src/ogg/ogg-misc.js +0 -78
  169. package/dist/modules/src/ogg/ogg-muxer.js +0 -353
  170. package/dist/modules/src/ogg/ogg-reader.js +0 -65
  171. package/dist/modules/src/output-format.js +0 -527
  172. package/dist/modules/src/output.js +0 -300
  173. package/dist/modules/src/packet.js +0 -182
  174. package/dist/modules/src/pcm.js +0 -85
  175. package/dist/modules/src/reader.js +0 -236
  176. package/dist/modules/src/sample.js +0 -1056
  177. package/dist/modules/src/source.js +0 -1182
  178. package/dist/modules/src/subtitles.js +0 -575
  179. package/dist/modules/src/target.js +0 -140
  180. package/dist/modules/src/wave/riff-writer.js +0 -30
  181. package/dist/modules/src/wave/wave-demuxer.js +0 -447
  182. package/dist/modules/src/wave/wave-muxer.js +0 -318
  183. package/dist/modules/src/writer.js +0 -370
  184. package/src/adts/adts-demuxer.ts +0 -331
  185. package/src/adts/adts-muxer.ts +0 -111
  186. package/src/adts/adts-reader.ts +0 -85
  187. package/src/codec-data.ts +0 -2078
  188. package/src/codec.ts +0 -1092
  189. package/src/conversion.ts +0 -2112
  190. package/src/custom-coder.ts +0 -197
  191. package/src/demuxer.ts +0 -24
  192. package/src/encode.ts +0 -739
  193. package/src/flac/flac-demuxer.ts +0 -730
  194. package/src/flac/flac-misc.ts +0 -164
  195. package/src/flac/flac-muxer.ts +0 -320
  196. package/src/id3.ts +0 -925
  197. package/src/index.ts +0 -221
  198. package/src/input-format.ts +0 -541
  199. package/src/input-track.ts +0 -529
  200. package/src/input.ts +0 -235
  201. package/src/isobmff/isobmff-boxes.ts +0 -1719
  202. package/src/isobmff/isobmff-demuxer.ts +0 -3190
  203. package/src/isobmff/isobmff-misc.ts +0 -29
  204. package/src/isobmff/isobmff-muxer.ts +0 -1348
  205. package/src/isobmff/isobmff-reader.ts +0 -91
  206. package/src/matroska/ebml.ts +0 -730
  207. package/src/matroska/matroska-demuxer.ts +0 -2481
  208. package/src/matroska/matroska-misc.ts +0 -29
  209. package/src/matroska/matroska-muxer.ts +0 -1276
  210. package/src/media-sink.ts +0 -2179
  211. package/src/media-source.ts +0 -2243
  212. package/src/metadata.ts +0 -320
  213. package/src/misc.ts +0 -798
  214. package/src/mp3/mp3-demuxer.ts +0 -383
  215. package/src/mp3/mp3-muxer.ts +0 -166
  216. package/src/mp3/mp3-reader.ts +0 -34
  217. package/src/mp3/mp3-writer.ts +0 -120
  218. package/src/muxer.ts +0 -88
  219. package/src/node.ts +0 -11
  220. package/src/ogg/ogg-demuxer.ts +0 -1053
  221. package/src/ogg/ogg-misc.ts +0 -116
  222. package/src/ogg/ogg-muxer.ts +0 -497
  223. package/src/ogg/ogg-reader.ts +0 -93
  224. package/src/output-format.ts +0 -945
  225. package/src/output.ts +0 -488
  226. package/src/packet.ts +0 -263
  227. package/src/pcm.ts +0 -112
  228. package/src/reader.ts +0 -323
  229. package/src/sample.ts +0 -1461
  230. package/src/source.ts +0 -1688
  231. package/src/subtitles.ts +0 -711
  232. package/src/target.ts +0 -204
  233. package/src/tsconfig.json +0 -16
  234. package/src/wave/riff-writer.ts +0 -36
  235. package/src/wave/wave-demuxer.ts +0 -529
  236. package/src/wave/wave-muxer.ts +0 -371
  237. package/src/writer.ts +0 -490
@@ -1,527 +0,0 @@
1
- /*!
2
- * Copyright (c) 2025-present, Vanilagy and contributors
3
- *
4
- * This Source Code Form is subject to the terms of the Mozilla Public
5
- * License, v. 2.0. If a copy of the MPL was not distributed with this
6
- * file, You can obtain one at https://mozilla.org/MPL/2.0/.
7
- */
8
- import { AdtsMuxer } from './adts/adts-muxer.js';
9
- import { AUDIO_CODECS, NON_PCM_AUDIO_CODECS, PCM_AUDIO_CODECS, SUBTITLE_CODECS, VIDEO_CODECS, } from './codec.js';
10
- import { FlacMuxer } from './flac/flac-muxer.js';
11
- import { IsobmffMuxer } from './isobmff/isobmff-muxer.js';
12
- import { MatroskaMuxer } from './matroska/matroska-muxer.js';
13
- import { Mp3Muxer } from './mp3/mp3-muxer.js';
14
- import { OggMuxer } from './ogg/ogg-muxer.js';
15
- import { WaveMuxer } from './wave/wave-muxer.js';
16
- /**
17
- * Base class representing an output media file format.
18
- * @group Output formats
19
- * @public
20
- */
21
- export class OutputFormat {
22
- /** Returns a list of video codecs that this output format can contain. */
23
- getSupportedVideoCodecs() {
24
- return this.getSupportedCodecs()
25
- .filter(codec => VIDEO_CODECS.includes(codec));
26
- }
27
- /** Returns a list of audio codecs that this output format can contain. */
28
- getSupportedAudioCodecs() {
29
- return this.getSupportedCodecs()
30
- .filter(codec => AUDIO_CODECS.includes(codec));
31
- }
32
- /** Returns a list of subtitle codecs that this output format can contain. */
33
- getSupportedSubtitleCodecs() {
34
- return this.getSupportedCodecs()
35
- .filter(codec => SUBTITLE_CODECS.includes(codec));
36
- }
37
- /** @internal */
38
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
39
- _codecUnsupportedHint(codec) {
40
- return '';
41
- }
42
- }
43
- /**
44
- * Format representing files compatible with the ISO base media file format (ISOBMFF), like MP4 or MOV files.
45
- * @group Output formats
46
- * @public
47
- */
48
- export class IsobmffOutputFormat extends OutputFormat {
49
- /** Internal constructor. */
50
- constructor(options = {}) {
51
- if (!options || typeof options !== 'object') {
52
- throw new TypeError('options must be an object.');
53
- }
54
- if (options.fastStart !== undefined
55
- && ![false, 'in-memory', 'reserve', 'fragmented'].includes(options.fastStart)) {
56
- throw new TypeError('options.fastStart, when provided, must be false, \'in-memory\', \'reserve\', or \'fragmented\'.');
57
- }
58
- if (options.minimumFragmentDuration !== undefined
59
- && (!Number.isFinite(options.minimumFragmentDuration) || options.minimumFragmentDuration < 0)) {
60
- throw new TypeError('options.minimumFragmentDuration, when provided, must be a non-negative number.');
61
- }
62
- if (options.onFtyp !== undefined && typeof options.onFtyp !== 'function') {
63
- throw new TypeError('options.onFtyp, when provided, must be a function.');
64
- }
65
- if (options.onMoov !== undefined && typeof options.onMoov !== 'function') {
66
- throw new TypeError('options.onMoov, when provided, must be a function.');
67
- }
68
- if (options.onMdat !== undefined && typeof options.onMdat !== 'function') {
69
- throw new TypeError('options.onMdat, when provided, must be a function.');
70
- }
71
- if (options.onMoof !== undefined && typeof options.onMoof !== 'function') {
72
- throw new TypeError('options.onMoof, when provided, must be a function.');
73
- }
74
- if (options.metadataFormat !== undefined
75
- && !['mdir', 'mdta', 'udta', 'auto'].includes(options.metadataFormat)) {
76
- throw new TypeError('options.metadataFormat, when provided, must be either \'auto\', \'mdir\', \'mdta\', or \'udta\'.');
77
- }
78
- super();
79
- this._options = options;
80
- }
81
- getSupportedTrackCounts() {
82
- return {
83
- video: { min: 0, max: Infinity },
84
- audio: { min: 0, max: Infinity },
85
- subtitle: { min: 0, max: Infinity },
86
- total: { min: 1, max: 2 ** 32 - 1 }, // Have fun reaching this one
87
- };
88
- }
89
- get supportsVideoRotationMetadata() {
90
- return true;
91
- }
92
- /** @internal */
93
- _createMuxer(output) {
94
- return new IsobmffMuxer(output, this);
95
- }
96
- }
97
- /**
98
- * MPEG-4 Part 14 (MP4) file format. Supports most codecs.
99
- * @group Output formats
100
- * @public
101
- */
102
- export class Mp4OutputFormat extends IsobmffOutputFormat {
103
- /** Creates a new {@link Mp4OutputFormat} configured with the specified `options`. */
104
- constructor(options) {
105
- super(options);
106
- }
107
- /** @internal */
108
- get _name() {
109
- return 'MP4';
110
- }
111
- get fileExtension() {
112
- return '.mp4';
113
- }
114
- get mimeType() {
115
- return 'video/mp4';
116
- }
117
- getSupportedCodecs() {
118
- return [
119
- ...VIDEO_CODECS,
120
- ...NON_PCM_AUDIO_CODECS,
121
- // These are supported via ISO/IEC 23003-5
122
- 'pcm-s16',
123
- 'pcm-s16be',
124
- 'pcm-s24',
125
- 'pcm-s24be',
126
- 'pcm-s32',
127
- 'pcm-s32be',
128
- 'pcm-f32',
129
- 'pcm-f32be',
130
- 'pcm-f64',
131
- 'pcm-f64be',
132
- // Only WebVTT subtitles are supported in MP4
133
- 'webvtt',
134
- ];
135
- }
136
- /** @internal */
137
- _codecUnsupportedHint(codec) {
138
- if (new MovOutputFormat().getSupportedCodecs().includes(codec)) {
139
- return ' Switching to MOV will grant support for this codec.';
140
- }
141
- return '';
142
- }
143
- }
144
- /**
145
- * QuickTime File Format (QTFF), often called MOV. Supports all video and audio codecs, but not subtitle codecs.
146
- * @group Output formats
147
- * @public
148
- */
149
- export class MovOutputFormat extends IsobmffOutputFormat {
150
- /** Creates a new {@link MovOutputFormat} configured with the specified `options`. */
151
- constructor(options) {
152
- super(options);
153
- }
154
- /** @internal */
155
- get _name() {
156
- return 'MOV';
157
- }
158
- get fileExtension() {
159
- return '.mov';
160
- }
161
- get mimeType() {
162
- return 'video/quicktime';
163
- }
164
- getSupportedCodecs() {
165
- return [
166
- ...VIDEO_CODECS,
167
- ...AUDIO_CODECS,
168
- // Only WebVTT subtitles are supported in MOV
169
- 'webvtt',
170
- ];
171
- }
172
- /** @internal */
173
- _codecUnsupportedHint(codec) {
174
- if (new Mp4OutputFormat().getSupportedCodecs().includes(codec)) {
175
- return ' Switching to MP4 will grant support for this codec.';
176
- }
177
- return '';
178
- }
179
- }
180
- /**
181
- * Matroska file format.
182
- *
183
- * Supports writing transparent video. For a video track to be marked as transparent, the first packet added must
184
- * contain alpha side data.
185
- *
186
- * @group Output formats
187
- * @public
188
- */
189
- export class MkvOutputFormat extends OutputFormat {
190
- /** Creates a new {@link MkvOutputFormat} configured with the specified `options`. */
191
- constructor(options = {}) {
192
- if (!options || typeof options !== 'object') {
193
- throw new TypeError('options must be an object.');
194
- }
195
- if (options.appendOnly !== undefined && typeof options.appendOnly !== 'boolean') {
196
- throw new TypeError('options.appendOnly, when provided, must be a boolean.');
197
- }
198
- if (options.minimumClusterDuration !== undefined
199
- && (!Number.isFinite(options.minimumClusterDuration) || options.minimumClusterDuration < 0)) {
200
- throw new TypeError('options.minimumClusterDuration, when provided, must be a non-negative number.');
201
- }
202
- if (options.onEbmlHeader !== undefined && typeof options.onEbmlHeader !== 'function') {
203
- throw new TypeError('options.onEbmlHeader, when provided, must be a function.');
204
- }
205
- if (options.onSegmentHeader !== undefined && typeof options.onSegmentHeader !== 'function') {
206
- throw new TypeError('options.onHeader, when provided, must be a function.');
207
- }
208
- if (options.onCluster !== undefined && typeof options.onCluster !== 'function') {
209
- throw new TypeError('options.onCluster, when provided, must be a function.');
210
- }
211
- super();
212
- this._options = options;
213
- }
214
- /** @internal */
215
- _createMuxer(output) {
216
- return new MatroskaMuxer(output, this);
217
- }
218
- /** @internal */
219
- get _name() {
220
- return 'Matroska';
221
- }
222
- getSupportedTrackCounts() {
223
- return {
224
- video: { min: 0, max: Infinity },
225
- audio: { min: 0, max: Infinity },
226
- subtitle: { min: 0, max: Infinity },
227
- total: { min: 1, max: 127 },
228
- };
229
- }
230
- get fileExtension() {
231
- return '.mkv';
232
- }
233
- get mimeType() {
234
- return 'video/x-matroska';
235
- }
236
- getSupportedCodecs() {
237
- return [
238
- ...VIDEO_CODECS,
239
- ...NON_PCM_AUDIO_CODECS,
240
- ...PCM_AUDIO_CODECS.filter(codec => !['pcm-s8', 'pcm-f32be', 'pcm-f64be', 'ulaw', 'alaw'].includes(codec)),
241
- ...SUBTITLE_CODECS,
242
- ];
243
- }
244
- get supportsVideoRotationMetadata() {
245
- // While it technically does support it with ProjectionPoseRoll, many players appear to ignore this value
246
- return false;
247
- }
248
- }
249
- /**
250
- * WebM file format, based on Matroska.
251
- *
252
- * Supports writing transparent video. For a video track to be marked as transparent, the first packet added must
253
- * contain alpha side data.
254
- *
255
- * @group Output formats
256
- * @public
257
- */
258
- export class WebMOutputFormat extends MkvOutputFormat {
259
- /** Creates a new {@link WebMOutputFormat} configured with the specified `options`. */
260
- constructor(options) {
261
- super(options);
262
- }
263
- getSupportedCodecs() {
264
- return [
265
- ...VIDEO_CODECS.filter(codec => ['vp8', 'vp9', 'av1'].includes(codec)),
266
- ...AUDIO_CODECS.filter(codec => ['opus', 'vorbis'].includes(codec)),
267
- ...SUBTITLE_CODECS,
268
- ];
269
- }
270
- /** @internal */
271
- get _name() {
272
- return 'WebM';
273
- }
274
- get fileExtension() {
275
- return '.webm';
276
- }
277
- get mimeType() {
278
- return 'video/webm';
279
- }
280
- /** @internal */
281
- _codecUnsupportedHint(codec) {
282
- if (new MkvOutputFormat().getSupportedCodecs().includes(codec)) {
283
- return ' Switching to MKV will grant support for this codec.';
284
- }
285
- return '';
286
- }
287
- }
288
- /**
289
- * MP3 file format.
290
- * @group Output formats
291
- * @public
292
- */
293
- export class Mp3OutputFormat extends OutputFormat {
294
- /** Creates a new {@link Mp3OutputFormat} configured with the specified `options`. */
295
- constructor(options = {}) {
296
- if (!options || typeof options !== 'object') {
297
- throw new TypeError('options must be an object.');
298
- }
299
- if (options.xingHeader !== undefined && typeof options.xingHeader !== 'boolean') {
300
- throw new TypeError('options.xingHeader, when provided, must be a boolean.');
301
- }
302
- if (options.onXingFrame !== undefined && typeof options.onXingFrame !== 'function') {
303
- throw new TypeError('options.onXingFrame, when provided, must be a function.');
304
- }
305
- super();
306
- this._options = options;
307
- }
308
- /** @internal */
309
- _createMuxer(output) {
310
- return new Mp3Muxer(output, this);
311
- }
312
- /** @internal */
313
- get _name() {
314
- return 'MP3';
315
- }
316
- getSupportedTrackCounts() {
317
- return {
318
- video: { min: 0, max: 0 },
319
- audio: { min: 1, max: 1 },
320
- subtitle: { min: 0, max: 0 },
321
- total: { min: 1, max: 1 },
322
- };
323
- }
324
- get fileExtension() {
325
- return '.mp3';
326
- }
327
- get mimeType() {
328
- return 'audio/mpeg';
329
- }
330
- getSupportedCodecs() {
331
- return ['mp3'];
332
- }
333
- get supportsVideoRotationMetadata() {
334
- return false;
335
- }
336
- }
337
- /**
338
- * WAVE file format, based on RIFF.
339
- * @group Output formats
340
- * @public
341
- */
342
- export class WavOutputFormat extends OutputFormat {
343
- /** Creates a new {@link WavOutputFormat} configured with the specified `options`. */
344
- constructor(options = {}) {
345
- if (!options || typeof options !== 'object') {
346
- throw new TypeError('options must be an object.');
347
- }
348
- if (options.large !== undefined && typeof options.large !== 'boolean') {
349
- throw new TypeError('options.large, when provided, must be a boolean.');
350
- }
351
- if (options.metadataFormat !== undefined && !['info', 'id3'].includes(options.metadataFormat)) {
352
- throw new TypeError('options.metadataFormat, when provided, must be either \'info\' or \'id3\'.');
353
- }
354
- if (options.onHeader !== undefined && typeof options.onHeader !== 'function') {
355
- throw new TypeError('options.onHeader, when provided, must be a function.');
356
- }
357
- super();
358
- this._options = options;
359
- }
360
- /** @internal */
361
- _createMuxer(output) {
362
- return new WaveMuxer(output, this);
363
- }
364
- /** @internal */
365
- get _name() {
366
- return 'WAVE';
367
- }
368
- getSupportedTrackCounts() {
369
- return {
370
- video: { min: 0, max: 0 },
371
- audio: { min: 1, max: 1 },
372
- subtitle: { min: 0, max: 0 },
373
- total: { min: 1, max: 1 },
374
- };
375
- }
376
- get fileExtension() {
377
- return '.wav';
378
- }
379
- get mimeType() {
380
- return 'audio/wav';
381
- }
382
- getSupportedCodecs() {
383
- return [
384
- ...PCM_AUDIO_CODECS.filter(codec => ['pcm-s16', 'pcm-s24', 'pcm-s32', 'pcm-f32', 'pcm-u8', 'ulaw', 'alaw'].includes(codec)),
385
- ];
386
- }
387
- get supportsVideoRotationMetadata() {
388
- return false;
389
- }
390
- }
391
- /**
392
- * Ogg file format.
393
- * @group Output formats
394
- * @public
395
- */
396
- export class OggOutputFormat extends OutputFormat {
397
- /** Creates a new {@link OggOutputFormat} configured with the specified `options`. */
398
- constructor(options = {}) {
399
- if (!options || typeof options !== 'object') {
400
- throw new TypeError('options must be an object.');
401
- }
402
- if (options.onPage !== undefined && typeof options.onPage !== 'function') {
403
- throw new TypeError('options.onPage, when provided, must be a function.');
404
- }
405
- super();
406
- this._options = options;
407
- }
408
- /** @internal */
409
- _createMuxer(output) {
410
- return new OggMuxer(output, this);
411
- }
412
- /** @internal */
413
- get _name() {
414
- return 'Ogg';
415
- }
416
- getSupportedTrackCounts() {
417
- return {
418
- video: { min: 0, max: 0 },
419
- audio: { min: 0, max: Infinity },
420
- subtitle: { min: 0, max: 0 },
421
- total: { min: 1, max: 2 ** 32 },
422
- };
423
- }
424
- get fileExtension() {
425
- return '.ogg';
426
- }
427
- get mimeType() {
428
- return 'application/ogg';
429
- }
430
- getSupportedCodecs() {
431
- return [
432
- ...AUDIO_CODECS.filter(codec => ['vorbis', 'opus'].includes(codec)),
433
- ];
434
- }
435
- get supportsVideoRotationMetadata() {
436
- return false;
437
- }
438
- }
439
- /**
440
- * ADTS file format.
441
- * @group Output formats
442
- * @public
443
- */
444
- export class AdtsOutputFormat extends OutputFormat {
445
- /** Creates a new {@link AdtsOutputFormat} configured with the specified `options`. */
446
- constructor(options = {}) {
447
- if (!options || typeof options !== 'object') {
448
- throw new TypeError('options must be an object.');
449
- }
450
- if (options.onFrame !== undefined && typeof options.onFrame !== 'function') {
451
- throw new TypeError('options.onFrame, when provided, must be a function.');
452
- }
453
- super();
454
- this._options = options;
455
- }
456
- /** @internal */
457
- _createMuxer(output) {
458
- return new AdtsMuxer(output, this);
459
- }
460
- /** @internal */
461
- get _name() {
462
- return 'ADTS';
463
- }
464
- getSupportedTrackCounts() {
465
- return {
466
- video: { min: 0, max: 0 },
467
- audio: { min: 1, max: 1 },
468
- subtitle: { min: 0, max: 0 },
469
- total: { min: 1, max: 1 },
470
- };
471
- }
472
- get fileExtension() {
473
- return '.aac';
474
- }
475
- get mimeType() {
476
- return 'audio/aac';
477
- }
478
- getSupportedCodecs() {
479
- return ['aac'];
480
- }
481
- get supportsVideoRotationMetadata() {
482
- return false;
483
- }
484
- }
485
- /**
486
- * FLAC file format.
487
- * @group Output formats
488
- * @public
489
- */
490
- export class FlacOutputFormat extends OutputFormat {
491
- /** Creates a new {@link FlacOutputFormat} configured with the specified `options`. */
492
- constructor(options = {}) {
493
- if (!options || typeof options !== 'object') {
494
- throw new TypeError('options must be an object.');
495
- }
496
- super();
497
- this._options = options;
498
- }
499
- /** @internal */
500
- _createMuxer(output) {
501
- return new FlacMuxer(output, this);
502
- }
503
- /** @internal */
504
- get _name() {
505
- return 'FLAC';
506
- }
507
- getSupportedTrackCounts() {
508
- return {
509
- video: { min: 0, max: 0 },
510
- audio: { min: 1, max: 1 },
511
- subtitle: { min: 0, max: 0 },
512
- total: { min: 1, max: 1 },
513
- };
514
- }
515
- get fileExtension() {
516
- return '.flac';
517
- }
518
- get mimeType() {
519
- return 'audio/flac';
520
- }
521
- getSupportedCodecs() {
522
- return ['flac'];
523
- }
524
- get supportsVideoRotationMetadata() {
525
- return false;
526
- }
527
- }