@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.
- package/README.md +1 -1
- package/dist/bundles/{mediabunny.mjs → mediabunny.js} +21963 -21388
- package/dist/bundles/mediabunny.min.js +490 -0
- package/dist/modules/shared/mp3-misc.d.ts.map +1 -1
- package/dist/modules/src/adts/adts-demuxer.d.ts +6 -6
- package/dist/modules/src/adts/adts-demuxer.d.ts.map +1 -1
- package/dist/modules/src/adts/adts-muxer.d.ts +4 -4
- package/dist/modules/src/adts/adts-muxer.d.ts.map +1 -1
- package/dist/modules/src/adts/adts-reader.d.ts +1 -1
- package/dist/modules/src/adts/adts-reader.d.ts.map +1 -1
- package/dist/modules/src/avi/avi-demuxer.d.ts +44 -0
- package/dist/modules/src/avi/avi-demuxer.d.ts.map +1 -0
- package/dist/modules/src/avi/avi-misc.d.ts +88 -0
- package/dist/modules/src/avi/avi-misc.d.ts.map +1 -0
- package/dist/modules/src/avi/avi-muxer.d.ts +45 -0
- package/dist/modules/src/avi/avi-muxer.d.ts.map +1 -0
- package/dist/modules/src/avi/riff-writer.d.ts +26 -0
- package/dist/modules/src/avi/riff-writer.d.ts.map +1 -0
- package/dist/modules/src/codec-data.d.ts +8 -3
- package/dist/modules/src/codec-data.d.ts.map +1 -1
- package/dist/modules/src/codec.d.ts +10 -10
- package/dist/modules/src/codec.d.ts.map +1 -1
- package/dist/modules/src/conversion.d.ts +33 -16
- package/dist/modules/src/conversion.d.ts.map +1 -1
- package/dist/modules/src/custom-coder.d.ts +8 -8
- package/dist/modules/src/custom-coder.d.ts.map +1 -1
- package/dist/modules/src/demuxer.d.ts +3 -3
- package/dist/modules/src/demuxer.d.ts.map +1 -1
- package/dist/modules/src/encode.d.ts +8 -8
- package/dist/modules/src/encode.d.ts.map +1 -1
- package/dist/modules/src/flac/flac-demuxer.d.ts +7 -7
- package/dist/modules/src/flac/flac-demuxer.d.ts.map +1 -1
- package/dist/modules/src/flac/flac-misc.d.ts +3 -3
- package/dist/modules/src/flac/flac-misc.d.ts.map +1 -1
- package/dist/modules/src/flac/flac-muxer.d.ts +5 -5
- package/dist/modules/src/flac/flac-muxer.d.ts.map +1 -1
- package/dist/modules/src/id3.d.ts +3 -3
- package/dist/modules/src/id3.d.ts.map +1 -1
- package/dist/modules/src/index.d.ts +20 -20
- package/dist/modules/src/index.d.ts.map +1 -1
- package/dist/modules/src/input-format.d.ts +22 -0
- package/dist/modules/src/input-format.d.ts.map +1 -1
- package/dist/modules/src/input-track.d.ts +8 -8
- package/dist/modules/src/input-track.d.ts.map +1 -1
- package/dist/modules/src/input.d.ts +12 -12
- package/dist/modules/src/isobmff/isobmff-boxes.d.ts +2 -2
- package/dist/modules/src/isobmff/isobmff-boxes.d.ts.map +1 -1
- package/dist/modules/src/isobmff/isobmff-demuxer.d.ts +12 -12
- package/dist/modules/src/isobmff/isobmff-demuxer.d.ts.map +1 -1
- package/dist/modules/src/isobmff/isobmff-misc.d.ts.map +1 -1
- package/dist/modules/src/isobmff/isobmff-muxer.d.ts +11 -11
- package/dist/modules/src/isobmff/isobmff-muxer.d.ts.map +1 -1
- package/dist/modules/src/isobmff/isobmff-reader.d.ts +2 -2
- package/dist/modules/src/isobmff/isobmff-reader.d.ts.map +1 -1
- package/dist/modules/src/matroska/ebml.d.ts +3 -3
- package/dist/modules/src/matroska/ebml.d.ts.map +1 -1
- package/dist/modules/src/matroska/matroska-demuxer.d.ts +13 -13
- package/dist/modules/src/matroska/matroska-demuxer.d.ts.map +1 -1
- package/dist/modules/src/matroska/matroska-input.d.ts +33 -0
- package/dist/modules/src/matroska/matroska-input.d.ts.map +1 -0
- package/dist/modules/src/matroska/matroska-misc.d.ts.map +1 -1
- package/dist/modules/src/matroska/matroska-muxer.d.ts +5 -5
- package/dist/modules/src/matroska/matroska-muxer.d.ts.map +1 -1
- package/dist/modules/src/media-sink.d.ts +5 -5
- package/dist/modules/src/media-sink.d.ts.map +1 -1
- package/dist/modules/src/media-source.d.ts +22 -4
- package/dist/modules/src/media-source.d.ts.map +1 -1
- package/dist/modules/src/metadata.d.ts +2 -2
- package/dist/modules/src/metadata.d.ts.map +1 -1
- package/dist/modules/src/misc.d.ts +5 -4
- package/dist/modules/src/misc.d.ts.map +1 -1
- package/dist/modules/src/mp3/mp3-demuxer.d.ts +7 -7
- package/dist/modules/src/mp3/mp3-demuxer.d.ts.map +1 -1
- package/dist/modules/src/mp3/mp3-muxer.d.ts +4 -4
- package/dist/modules/src/mp3/mp3-muxer.d.ts.map +1 -1
- package/dist/modules/src/mp3/mp3-reader.d.ts +2 -2
- package/dist/modules/src/mp3/mp3-reader.d.ts.map +1 -1
- package/dist/modules/src/mp3/mp3-writer.d.ts +1 -1
- package/dist/modules/src/mp3/mp3-writer.d.ts.map +1 -1
- package/dist/modules/src/muxer.d.ts +4 -4
- package/dist/modules/src/muxer.d.ts.map +1 -1
- package/dist/modules/src/node.d.ts +1 -1
- package/dist/modules/src/ogg/ogg-demuxer.d.ts +7 -7
- package/dist/modules/src/ogg/ogg-demuxer.d.ts.map +1 -1
- package/dist/modules/src/ogg/ogg-misc.d.ts +1 -1
- package/dist/modules/src/ogg/ogg-misc.d.ts.map +1 -1
- package/dist/modules/src/ogg/ogg-muxer.d.ts +5 -5
- package/dist/modules/src/ogg/ogg-muxer.d.ts.map +1 -1
- package/dist/modules/src/ogg/ogg-reader.d.ts +1 -1
- package/dist/modules/src/ogg/ogg-reader.d.ts.map +1 -1
- package/dist/modules/src/output-format.d.ts +51 -6
- package/dist/modules/src/output-format.d.ts.map +1 -1
- package/dist/modules/src/output.d.ts +13 -13
- package/dist/modules/src/output.d.ts.map +1 -1
- package/dist/modules/src/packet.d.ts +1 -1
- package/dist/modules/src/packet.d.ts.map +1 -1
- package/dist/modules/src/pcm.d.ts.map +1 -1
- package/dist/modules/src/reader.d.ts +2 -2
- package/dist/modules/src/reader.d.ts.map +1 -1
- package/dist/modules/src/sample.d.ts +57 -15
- package/dist/modules/src/sample.d.ts.map +1 -1
- package/dist/modules/src/source.d.ts +3 -3
- package/dist/modules/src/source.d.ts.map +1 -1
- package/dist/modules/src/subtitles.d.ts +1 -1
- package/dist/modules/src/subtitles.d.ts.map +1 -1
- package/dist/modules/src/target.d.ts +2 -2
- package/dist/modules/src/target.d.ts.map +1 -1
- package/dist/modules/src/tsconfig.tsbuildinfo +1 -1
- package/dist/modules/src/wave/riff-writer.d.ts +1 -1
- package/dist/modules/src/wave/riff-writer.d.ts.map +1 -1
- package/dist/modules/src/wave/wave-demuxer.d.ts +6 -6
- package/dist/modules/src/wave/wave-demuxer.d.ts.map +1 -1
- package/dist/modules/src/wave/wave-muxer.d.ts +4 -4
- package/dist/modules/src/wave/wave-muxer.d.ts.map +1 -1
- package/dist/modules/src/writer.d.ts +1 -1
- package/dist/modules/src/writer.d.ts.map +1 -1
- package/dist/packages/eac3/eac3.wasm +0 -0
- package/dist/packages/eac3/mediabunny-eac3.js +1058 -0
- package/dist/packages/eac3/mediabunny-eac3.min.js +44 -0
- package/dist/packages/mp3-encoder/mediabunny-mp3-encoder.js +694 -0
- package/dist/packages/mp3-encoder/mediabunny-mp3-encoder.min.js +58 -0
- package/dist/packages/mpeg4/mediabunny-mpeg4.js +1198 -0
- package/dist/packages/mpeg4/mediabunny-mpeg4.min.js +44 -0
- package/dist/packages/mpeg4/xvid.wasm +0 -0
- package/package.json +18 -57
- package/dist/bundles/mediabunny.cjs +0 -26140
- package/dist/bundles/mediabunny.min.cjs +0 -147
- package/dist/bundles/mediabunny.min.mjs +0 -146
- package/dist/mediabunny.d.ts +0 -3319
- package/dist/modules/shared/mp3-misc.js +0 -147
- package/dist/modules/src/adts/adts-demuxer.js +0 -239
- package/dist/modules/src/adts/adts-muxer.js +0 -80
- package/dist/modules/src/adts/adts-reader.js +0 -63
- package/dist/modules/src/codec-data.js +0 -1730
- package/dist/modules/src/codec.js +0 -869
- package/dist/modules/src/conversion.js +0 -1459
- package/dist/modules/src/custom-coder.js +0 -117
- package/dist/modules/src/demuxer.js +0 -12
- package/dist/modules/src/encode.js +0 -442
- package/dist/modules/src/flac/flac-demuxer.js +0 -504
- package/dist/modules/src/flac/flac-misc.js +0 -135
- package/dist/modules/src/flac/flac-muxer.js +0 -222
- package/dist/modules/src/id3.js +0 -848
- package/dist/modules/src/index.js +0 -28
- package/dist/modules/src/input-format.js +0 -480
- package/dist/modules/src/input-track.js +0 -372
- package/dist/modules/src/input.js +0 -188
- package/dist/modules/src/isobmff/isobmff-boxes.js +0 -1480
- package/dist/modules/src/isobmff/isobmff-demuxer.js +0 -2618
- package/dist/modules/src/isobmff/isobmff-misc.js +0 -20
- package/dist/modules/src/isobmff/isobmff-muxer.js +0 -966
- package/dist/modules/src/isobmff/isobmff-reader.js +0 -72
- package/dist/modules/src/matroska/ebml.js +0 -653
- package/dist/modules/src/matroska/matroska-demuxer.js +0 -2133
- package/dist/modules/src/matroska/matroska-misc.js +0 -20
- package/dist/modules/src/matroska/matroska-muxer.js +0 -1017
- package/dist/modules/src/media-sink.js +0 -1736
- package/dist/modules/src/media-source.js +0 -1825
- package/dist/modules/src/metadata.js +0 -193
- package/dist/modules/src/misc.js +0 -623
- package/dist/modules/src/mp3/mp3-demuxer.js +0 -285
- package/dist/modules/src/mp3/mp3-muxer.js +0 -123
- package/dist/modules/src/mp3/mp3-reader.js +0 -26
- package/dist/modules/src/mp3/mp3-writer.js +0 -78
- package/dist/modules/src/muxer.js +0 -50
- package/dist/modules/src/node.js +0 -9
- package/dist/modules/src/ogg/ogg-demuxer.js +0 -763
- package/dist/modules/src/ogg/ogg-misc.js +0 -78
- package/dist/modules/src/ogg/ogg-muxer.js +0 -353
- package/dist/modules/src/ogg/ogg-reader.js +0 -65
- package/dist/modules/src/output-format.js +0 -527
- package/dist/modules/src/output.js +0 -300
- package/dist/modules/src/packet.js +0 -182
- package/dist/modules/src/pcm.js +0 -85
- package/dist/modules/src/reader.js +0 -236
- package/dist/modules/src/sample.js +0 -1056
- package/dist/modules/src/source.js +0 -1182
- package/dist/modules/src/subtitles.js +0 -575
- package/dist/modules/src/target.js +0 -140
- package/dist/modules/src/wave/riff-writer.js +0 -30
- package/dist/modules/src/wave/wave-demuxer.js +0 -447
- package/dist/modules/src/wave/wave-muxer.js +0 -318
- package/dist/modules/src/writer.js +0 -370
- package/src/adts/adts-demuxer.ts +0 -331
- package/src/adts/adts-muxer.ts +0 -111
- package/src/adts/adts-reader.ts +0 -85
- package/src/codec-data.ts +0 -2078
- package/src/codec.ts +0 -1092
- package/src/conversion.ts +0 -2112
- package/src/custom-coder.ts +0 -197
- package/src/demuxer.ts +0 -24
- package/src/encode.ts +0 -739
- package/src/flac/flac-demuxer.ts +0 -730
- package/src/flac/flac-misc.ts +0 -164
- package/src/flac/flac-muxer.ts +0 -320
- package/src/id3.ts +0 -925
- package/src/index.ts +0 -221
- package/src/input-format.ts +0 -541
- package/src/input-track.ts +0 -529
- package/src/input.ts +0 -235
- package/src/isobmff/isobmff-boxes.ts +0 -1719
- package/src/isobmff/isobmff-demuxer.ts +0 -3190
- package/src/isobmff/isobmff-misc.ts +0 -29
- package/src/isobmff/isobmff-muxer.ts +0 -1348
- package/src/isobmff/isobmff-reader.ts +0 -91
- package/src/matroska/ebml.ts +0 -730
- package/src/matroska/matroska-demuxer.ts +0 -2481
- package/src/matroska/matroska-misc.ts +0 -29
- package/src/matroska/matroska-muxer.ts +0 -1276
- package/src/media-sink.ts +0 -2179
- package/src/media-source.ts +0 -2243
- package/src/metadata.ts +0 -320
- package/src/misc.ts +0 -798
- package/src/mp3/mp3-demuxer.ts +0 -383
- package/src/mp3/mp3-muxer.ts +0 -166
- package/src/mp3/mp3-reader.ts +0 -34
- package/src/mp3/mp3-writer.ts +0 -120
- package/src/muxer.ts +0 -88
- package/src/node.ts +0 -11
- package/src/ogg/ogg-demuxer.ts +0 -1053
- package/src/ogg/ogg-misc.ts +0 -116
- package/src/ogg/ogg-muxer.ts +0 -497
- package/src/ogg/ogg-reader.ts +0 -93
- package/src/output-format.ts +0 -945
- package/src/output.ts +0 -488
- package/src/packet.ts +0 -263
- package/src/pcm.ts +0 -112
- package/src/reader.ts +0 -323
- package/src/sample.ts +0 -1461
- package/src/source.ts +0 -1688
- package/src/subtitles.ts +0 -711
- package/src/target.ts +0 -204
- package/src/tsconfig.json +0 -16
- package/src/wave/riff-writer.ts +0 -36
- package/src/wave/wave-demuxer.ts +0 -529
- package/src/wave/wave-muxer.ts +0 -371
- package/src/writer.ts +0 -490
|
@@ -1,28 +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
|
-
/// <reference types="dom-mediacapture-transform" preserve="true" />
|
|
9
|
-
/// <reference types="dom-webcodecs" preserve="true" />
|
|
10
|
-
export { Output, } from './output.js';
|
|
11
|
-
export { OutputFormat, AdtsOutputFormat, FlacOutputFormat, IsobmffOutputFormat, MkvOutputFormat, MovOutputFormat, Mp3OutputFormat, Mp4OutputFormat, OggOutputFormat, WavOutputFormat, WebMOutputFormat, } from './output-format.js';
|
|
12
|
-
export { MediaSource, VideoSource, AudioSource, SubtitleSource, AudioBufferSource, AudioSampleSource, CanvasSource, EncodedAudioPacketSource, EncodedVideoPacketSource, MediaStreamAudioTrackSource, MediaStreamVideoTrackSource, TextSubtitleSource, VideoSampleSource, } from './media-source.js';
|
|
13
|
-
export { VIDEO_CODECS, AUDIO_CODECS, PCM_AUDIO_CODECS, NON_PCM_AUDIO_CODECS, SUBTITLE_CODECS, } from './codec.js';
|
|
14
|
-
export { canEncode, canEncodeVideo, canEncodeAudio, canEncodeSubtitles, getEncodableCodecs, getEncodableVideoCodecs, getEncodableAudioCodecs, getEncodableSubtitleCodecs, getFirstEncodableVideoCodec, getFirstEncodableAudioCodec, getFirstEncodableSubtitleCodec, Quality, QUALITY_VERY_LOW, QUALITY_LOW, QUALITY_MEDIUM, QUALITY_HIGH, QUALITY_VERY_HIGH, } from './encode.js';
|
|
15
|
-
export { Target, BufferTarget, FilePathTarget, NullTarget, StreamTarget, } from './target.js';
|
|
16
|
-
export { ALL_TRACK_TYPES, } from './output.js';
|
|
17
|
-
export { Source, BlobSource, BufferSource, FilePathSource, StreamSource, ReadableStreamSource, UrlSource, } from './source.js';
|
|
18
|
-
export { InputFormat, AdtsInputFormat, IsobmffInputFormat, MatroskaInputFormat, Mp3InputFormat, Mp4InputFormat, OggInputFormat, QuickTimeInputFormat, WaveInputFormat, WebMInputFormat, FlacInputFormat, ALL_FORMATS, ADTS, MATROSKA, MP3, MP4, OGG, QTFF, WAVE, WEBM, FLAC, } from './input-format.js';
|
|
19
|
-
export { Input, InputDisposedError, } from './input.js';
|
|
20
|
-
export { InputTrack, InputVideoTrack, InputAudioTrack, InputSubtitleTrack, } from './input-track.js';
|
|
21
|
-
export { EncodedPacket, } from './packet.js';
|
|
22
|
-
export { AudioSample, VideoSample, } from './sample.js';
|
|
23
|
-
export { AudioBufferSink, AudioSampleSink, BaseMediaSampleSink, CanvasSink, EncodedPacketSink, VideoSampleSink, } from './media-sink.js';
|
|
24
|
-
export { Conversion, } from './conversion.js';
|
|
25
|
-
export { CustomVideoDecoder, CustomVideoEncoder, CustomAudioDecoder, CustomAudioEncoder, registerDecoder, registerEncoder, } from './custom-coder.js';
|
|
26
|
-
export { RichImageData, AttachedFile } from './metadata.js';
|
|
27
|
-
export { parseSrtTimestamp, formatSrtTimestamp, splitSrtIntoCues, formatCuesToSrt, formatCuesToWebVTT, parseAssTimestamp, formatAssTimestamp, splitAssIntoCues, formatCuesToAss, } from './subtitles.js';
|
|
28
|
-
// 🐡🦔
|
|
@@ -1,480 +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 { IsobmffDemuxer } from './isobmff/isobmff-demuxer.js';
|
|
9
|
-
import { EBMLId, MAX_HEADER_SIZE, MIN_HEADER_SIZE, readAsciiString, readElementHeader, readElementSize, readUnsignedInt, readVarIntSize, } from './matroska/ebml.js';
|
|
10
|
-
import { MatroskaDemuxer } from './matroska/matroska-demuxer.js';
|
|
11
|
-
import { Mp3Demuxer } from './mp3/mp3-demuxer.js';
|
|
12
|
-
import { FRAME_HEADER_SIZE } from '../shared/mp3-misc.js';
|
|
13
|
-
import { ID3_V2_HEADER_SIZE, readId3V2Header } from './id3.js';
|
|
14
|
-
import { readNextFrameHeader } from './mp3/mp3-reader.js';
|
|
15
|
-
import { OggDemuxer } from './ogg/ogg-demuxer.js';
|
|
16
|
-
import { WaveDemuxer } from './wave/wave-demuxer.js';
|
|
17
|
-
import { MAX_FRAME_HEADER_SIZE, MIN_FRAME_HEADER_SIZE, readFrameHeader } from './adts/adts-reader.js';
|
|
18
|
-
import { AdtsDemuxer } from './adts/adts-demuxer.js';
|
|
19
|
-
import { readAscii } from './reader.js';
|
|
20
|
-
import { FlacDemuxer } from './flac/flac-demuxer.js';
|
|
21
|
-
/**
|
|
22
|
-
* Base class representing an input media file format.
|
|
23
|
-
* @group Input formats
|
|
24
|
-
* @public
|
|
25
|
-
*/
|
|
26
|
-
export class InputFormat {
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Format representing files compatible with the ISO base media file format (ISOBMFF), like MP4 or MOV files.
|
|
30
|
-
* @group Input formats
|
|
31
|
-
* @public
|
|
32
|
-
*/
|
|
33
|
-
export class IsobmffInputFormat extends InputFormat {
|
|
34
|
-
/** @internal */
|
|
35
|
-
async _getMajorBrand(input) {
|
|
36
|
-
let slice = input._reader.requestSlice(0, 12);
|
|
37
|
-
if (slice instanceof Promise)
|
|
38
|
-
slice = await slice;
|
|
39
|
-
if (!slice)
|
|
40
|
-
return null;
|
|
41
|
-
slice.skip(4);
|
|
42
|
-
const fourCc = readAscii(slice, 4);
|
|
43
|
-
if (fourCc !== 'ftyp') {
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
return readAscii(slice, 4);
|
|
47
|
-
}
|
|
48
|
-
/** @internal */
|
|
49
|
-
_createDemuxer(input) {
|
|
50
|
-
return new IsobmffDemuxer(input);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* MPEG-4 Part 14 (MP4) file format.
|
|
55
|
-
*
|
|
56
|
-
* Do not instantiate this class; use the {@link MP4} singleton instead.
|
|
57
|
-
*
|
|
58
|
-
* @group Input formats
|
|
59
|
-
* @public
|
|
60
|
-
*/
|
|
61
|
-
export class Mp4InputFormat extends IsobmffInputFormat {
|
|
62
|
-
/** @internal */
|
|
63
|
-
async _canReadInput(input) {
|
|
64
|
-
const majorBrand = await this._getMajorBrand(input);
|
|
65
|
-
return !!majorBrand && majorBrand !== 'qt ';
|
|
66
|
-
}
|
|
67
|
-
get name() {
|
|
68
|
-
return 'MP4';
|
|
69
|
-
}
|
|
70
|
-
get mimeType() {
|
|
71
|
-
return 'video/mp4';
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* QuickTime File Format (QTFF), often called MOV.
|
|
76
|
-
*
|
|
77
|
-
* Do not instantiate this class; use the {@link QTFF} singleton instead.
|
|
78
|
-
*
|
|
79
|
-
* @group Input formats
|
|
80
|
-
* @public
|
|
81
|
-
*/
|
|
82
|
-
export class QuickTimeInputFormat extends IsobmffInputFormat {
|
|
83
|
-
/** @internal */
|
|
84
|
-
async _canReadInput(input) {
|
|
85
|
-
const majorBrand = await this._getMajorBrand(input);
|
|
86
|
-
return majorBrand === 'qt ';
|
|
87
|
-
}
|
|
88
|
-
get name() {
|
|
89
|
-
return 'QuickTime File Format';
|
|
90
|
-
}
|
|
91
|
-
get mimeType() {
|
|
92
|
-
return 'video/quicktime';
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Matroska file format.
|
|
97
|
-
*
|
|
98
|
-
* Do not instantiate this class; use the {@link MATROSKA} singleton instead.
|
|
99
|
-
*
|
|
100
|
-
* @group Input formats
|
|
101
|
-
* @public
|
|
102
|
-
*/
|
|
103
|
-
export class MatroskaInputFormat extends InputFormat {
|
|
104
|
-
/** @internal */
|
|
105
|
-
async isSupportedEBMLOfDocType(input, desiredDocType) {
|
|
106
|
-
let headerSlice = input._reader.requestSlice(0, MAX_HEADER_SIZE);
|
|
107
|
-
if (headerSlice instanceof Promise)
|
|
108
|
-
headerSlice = await headerSlice;
|
|
109
|
-
if (!headerSlice)
|
|
110
|
-
return false;
|
|
111
|
-
const varIntSize = readVarIntSize(headerSlice);
|
|
112
|
-
if (varIntSize === null) {
|
|
113
|
-
return false;
|
|
114
|
-
}
|
|
115
|
-
if (varIntSize < 1 || varIntSize > 8) {
|
|
116
|
-
return false;
|
|
117
|
-
}
|
|
118
|
-
const id = readUnsignedInt(headerSlice, varIntSize);
|
|
119
|
-
if (id !== EBMLId.EBML) {
|
|
120
|
-
return false;
|
|
121
|
-
}
|
|
122
|
-
const dataSize = readElementSize(headerSlice);
|
|
123
|
-
if (dataSize === null) {
|
|
124
|
-
return false; // Miss me with that shit
|
|
125
|
-
}
|
|
126
|
-
let dataSlice = input._reader.requestSlice(headerSlice.filePos, dataSize);
|
|
127
|
-
if (dataSlice instanceof Promise)
|
|
128
|
-
dataSlice = await dataSlice;
|
|
129
|
-
if (!dataSlice)
|
|
130
|
-
return false;
|
|
131
|
-
const startPos = headerSlice.filePos;
|
|
132
|
-
while (dataSlice.filePos <= startPos + dataSize - MIN_HEADER_SIZE) {
|
|
133
|
-
const header = readElementHeader(dataSlice);
|
|
134
|
-
if (!header)
|
|
135
|
-
break;
|
|
136
|
-
const { id, size } = header;
|
|
137
|
-
const dataStartPos = dataSlice.filePos;
|
|
138
|
-
if (size === null)
|
|
139
|
-
return false;
|
|
140
|
-
switch (id) {
|
|
141
|
-
case EBMLId.EBMLVersion:
|
|
142
|
-
{
|
|
143
|
-
const ebmlVersion = readUnsignedInt(dataSlice, size);
|
|
144
|
-
if (ebmlVersion !== 1) {
|
|
145
|
-
return false;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
;
|
|
149
|
-
break;
|
|
150
|
-
case EBMLId.EBMLReadVersion:
|
|
151
|
-
{
|
|
152
|
-
const ebmlReadVersion = readUnsignedInt(dataSlice, size);
|
|
153
|
-
if (ebmlReadVersion !== 1) {
|
|
154
|
-
return false;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
;
|
|
158
|
-
break;
|
|
159
|
-
case EBMLId.DocType:
|
|
160
|
-
{
|
|
161
|
-
const docType = readAsciiString(dataSlice, size);
|
|
162
|
-
if (docType !== desiredDocType) {
|
|
163
|
-
return false;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
;
|
|
167
|
-
break;
|
|
168
|
-
case EBMLId.DocTypeVersion:
|
|
169
|
-
{
|
|
170
|
-
const docTypeVersion = readUnsignedInt(dataSlice, size);
|
|
171
|
-
if (docTypeVersion > 4) { // Support up to Matroska v4
|
|
172
|
-
return false;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
;
|
|
176
|
-
break;
|
|
177
|
-
}
|
|
178
|
-
dataSlice.filePos = dataStartPos + size;
|
|
179
|
-
}
|
|
180
|
-
return true;
|
|
181
|
-
}
|
|
182
|
-
/** @internal */
|
|
183
|
-
_canReadInput(input) {
|
|
184
|
-
return this.isSupportedEBMLOfDocType(input, 'matroska');
|
|
185
|
-
}
|
|
186
|
-
/** @internal */
|
|
187
|
-
_createDemuxer(input) {
|
|
188
|
-
return new MatroskaDemuxer(input);
|
|
189
|
-
}
|
|
190
|
-
get name() {
|
|
191
|
-
return 'Matroska';
|
|
192
|
-
}
|
|
193
|
-
get mimeType() {
|
|
194
|
-
return 'video/x-matroska';
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* WebM file format, based on Matroska.
|
|
199
|
-
*
|
|
200
|
-
* Do not instantiate this class; use the {@link WEBM} singleton instead.
|
|
201
|
-
*
|
|
202
|
-
* @group Input formats
|
|
203
|
-
* @public
|
|
204
|
-
*/
|
|
205
|
-
export class WebMInputFormat extends MatroskaInputFormat {
|
|
206
|
-
/** @internal */
|
|
207
|
-
_canReadInput(input) {
|
|
208
|
-
return this.isSupportedEBMLOfDocType(input, 'webm');
|
|
209
|
-
}
|
|
210
|
-
get name() {
|
|
211
|
-
return 'WebM';
|
|
212
|
-
}
|
|
213
|
-
get mimeType() {
|
|
214
|
-
return 'video/webm';
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* MP3 file format.
|
|
219
|
-
*
|
|
220
|
-
* Do not instantiate this class; use the {@link MP3} singleton instead.
|
|
221
|
-
*
|
|
222
|
-
* @group Input formats
|
|
223
|
-
* @public
|
|
224
|
-
*/
|
|
225
|
-
export class Mp3InputFormat extends InputFormat {
|
|
226
|
-
/** @internal */
|
|
227
|
-
async _canReadInput(input) {
|
|
228
|
-
let slice = input._reader.requestSlice(0, 10);
|
|
229
|
-
if (slice instanceof Promise)
|
|
230
|
-
slice = await slice;
|
|
231
|
-
if (!slice)
|
|
232
|
-
return false;
|
|
233
|
-
let currentPos = 0;
|
|
234
|
-
let id3V2HeaderFound = false;
|
|
235
|
-
while (true) {
|
|
236
|
-
let slice = input._reader.requestSlice(currentPos, ID3_V2_HEADER_SIZE);
|
|
237
|
-
if (slice instanceof Promise)
|
|
238
|
-
slice = await slice;
|
|
239
|
-
if (!slice)
|
|
240
|
-
break;
|
|
241
|
-
const id3V2Header = readId3V2Header(slice);
|
|
242
|
-
if (!id3V2Header) {
|
|
243
|
-
break;
|
|
244
|
-
}
|
|
245
|
-
id3V2HeaderFound = true;
|
|
246
|
-
currentPos = slice.filePos + id3V2Header.size;
|
|
247
|
-
}
|
|
248
|
-
const firstResult = await readNextFrameHeader(input._reader, currentPos, currentPos + 4096);
|
|
249
|
-
if (!firstResult) {
|
|
250
|
-
return false;
|
|
251
|
-
}
|
|
252
|
-
if (id3V2HeaderFound) {
|
|
253
|
-
// If there was an ID3v2 tag at the start, we can be pretty sure this is MP3 by now
|
|
254
|
-
return true;
|
|
255
|
-
}
|
|
256
|
-
currentPos = firstResult.startPos + firstResult.header.totalSize;
|
|
257
|
-
// Fine, we found one frame header, but we're still not entirely sure this is MP3. Let's check if we can find
|
|
258
|
-
// another header right after it:
|
|
259
|
-
const secondResult = await readNextFrameHeader(input._reader, currentPos, currentPos + FRAME_HEADER_SIZE);
|
|
260
|
-
if (!secondResult) {
|
|
261
|
-
return false;
|
|
262
|
-
}
|
|
263
|
-
const firstHeader = firstResult.header;
|
|
264
|
-
const secondHeader = secondResult.header;
|
|
265
|
-
// In a well-formed MP3 file, we'd expect these two frames to share some similarities:
|
|
266
|
-
if (firstHeader.channel !== secondHeader.channel || firstHeader.sampleRate !== secondHeader.sampleRate) {
|
|
267
|
-
return false;
|
|
268
|
-
}
|
|
269
|
-
// We have found two matching consecutive MP3 frames, a strong indicator that this is an MP3 file
|
|
270
|
-
return true;
|
|
271
|
-
}
|
|
272
|
-
/** @internal */
|
|
273
|
-
_createDemuxer(input) {
|
|
274
|
-
return new Mp3Demuxer(input);
|
|
275
|
-
}
|
|
276
|
-
get name() {
|
|
277
|
-
return 'MP3';
|
|
278
|
-
}
|
|
279
|
-
get mimeType() {
|
|
280
|
-
return 'audio/mpeg';
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
/**
|
|
284
|
-
* WAVE file format, based on RIFF.
|
|
285
|
-
*
|
|
286
|
-
* Do not instantiate this class; use the {@link WAVE} singleton instead.
|
|
287
|
-
*
|
|
288
|
-
* @group Input formats
|
|
289
|
-
* @public
|
|
290
|
-
*/
|
|
291
|
-
export class WaveInputFormat extends InputFormat {
|
|
292
|
-
/** @internal */
|
|
293
|
-
async _canReadInput(input) {
|
|
294
|
-
let slice = input._reader.requestSlice(0, 12);
|
|
295
|
-
if (slice instanceof Promise)
|
|
296
|
-
slice = await slice;
|
|
297
|
-
if (!slice)
|
|
298
|
-
return false;
|
|
299
|
-
const riffType = readAscii(slice, 4);
|
|
300
|
-
if (riffType !== 'RIFF' && riffType !== 'RIFX' && riffType !== 'RF64') {
|
|
301
|
-
return false;
|
|
302
|
-
}
|
|
303
|
-
slice.skip(4);
|
|
304
|
-
const format = readAscii(slice, 4);
|
|
305
|
-
return format === 'WAVE';
|
|
306
|
-
}
|
|
307
|
-
/** @internal */
|
|
308
|
-
_createDemuxer(input) {
|
|
309
|
-
return new WaveDemuxer(input);
|
|
310
|
-
}
|
|
311
|
-
get name() {
|
|
312
|
-
return 'WAVE';
|
|
313
|
-
}
|
|
314
|
-
get mimeType() {
|
|
315
|
-
return 'audio/wav';
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
/**
|
|
319
|
-
* Ogg file format.
|
|
320
|
-
*
|
|
321
|
-
* Do not instantiate this class; use the {@link OGG} singleton instead.
|
|
322
|
-
*
|
|
323
|
-
* @group Input formats
|
|
324
|
-
* @public
|
|
325
|
-
*/
|
|
326
|
-
export class OggInputFormat extends InputFormat {
|
|
327
|
-
/** @internal */
|
|
328
|
-
async _canReadInput(input) {
|
|
329
|
-
let slice = input._reader.requestSlice(0, 4);
|
|
330
|
-
if (slice instanceof Promise)
|
|
331
|
-
slice = await slice;
|
|
332
|
-
if (!slice)
|
|
333
|
-
return false;
|
|
334
|
-
return readAscii(slice, 4) === 'OggS';
|
|
335
|
-
}
|
|
336
|
-
/** @internal */
|
|
337
|
-
_createDemuxer(input) {
|
|
338
|
-
return new OggDemuxer(input);
|
|
339
|
-
}
|
|
340
|
-
get name() {
|
|
341
|
-
return 'Ogg';
|
|
342
|
-
}
|
|
343
|
-
get mimeType() {
|
|
344
|
-
return 'application/ogg';
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
/**
|
|
348
|
-
* FLAC file format.
|
|
349
|
-
*
|
|
350
|
-
* Do not instantiate this class; use the {@link FLAC} singleton instead.
|
|
351
|
-
*
|
|
352
|
-
* @group Input formats
|
|
353
|
-
* @public
|
|
354
|
-
*/
|
|
355
|
-
export class FlacInputFormat extends InputFormat {
|
|
356
|
-
/** @internal */
|
|
357
|
-
async _canReadInput(input) {
|
|
358
|
-
let slice = input._reader.requestSlice(0, 4);
|
|
359
|
-
if (slice instanceof Promise)
|
|
360
|
-
slice = await slice;
|
|
361
|
-
if (!slice)
|
|
362
|
-
return false;
|
|
363
|
-
return readAscii(slice, 4) === 'fLaC';
|
|
364
|
-
}
|
|
365
|
-
get name() {
|
|
366
|
-
return 'FLAC';
|
|
367
|
-
}
|
|
368
|
-
get mimeType() {
|
|
369
|
-
return 'audio/flac';
|
|
370
|
-
}
|
|
371
|
-
/** @internal */
|
|
372
|
-
_createDemuxer(input) {
|
|
373
|
-
return new FlacDemuxer(input);
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
/**
|
|
377
|
-
* ADTS file format.
|
|
378
|
-
*
|
|
379
|
-
* Do not instantiate this class; use the {@link ADTS} singleton instead.
|
|
380
|
-
*
|
|
381
|
-
* @group Input formats
|
|
382
|
-
* @public
|
|
383
|
-
*/
|
|
384
|
-
export class AdtsInputFormat extends InputFormat {
|
|
385
|
-
/** @internal */
|
|
386
|
-
async _canReadInput(input) {
|
|
387
|
-
let slice = input._reader.requestSliceRange(0, MIN_FRAME_HEADER_SIZE, MAX_FRAME_HEADER_SIZE);
|
|
388
|
-
if (slice instanceof Promise)
|
|
389
|
-
slice = await slice;
|
|
390
|
-
if (!slice)
|
|
391
|
-
return false;
|
|
392
|
-
const firstHeader = readFrameHeader(slice);
|
|
393
|
-
if (!firstHeader) {
|
|
394
|
-
return false;
|
|
395
|
-
}
|
|
396
|
-
slice = input._reader.requestSliceRange(firstHeader.frameLength, MIN_FRAME_HEADER_SIZE, MAX_FRAME_HEADER_SIZE);
|
|
397
|
-
if (slice instanceof Promise)
|
|
398
|
-
slice = await slice;
|
|
399
|
-
if (!slice)
|
|
400
|
-
return false;
|
|
401
|
-
const secondHeader = readFrameHeader(slice);
|
|
402
|
-
if (!secondHeader) {
|
|
403
|
-
return false;
|
|
404
|
-
}
|
|
405
|
-
return firstHeader.objectType === secondHeader.objectType
|
|
406
|
-
&& firstHeader.samplingFrequencyIndex === secondHeader.samplingFrequencyIndex
|
|
407
|
-
&& firstHeader.channelConfiguration === secondHeader.channelConfiguration;
|
|
408
|
-
}
|
|
409
|
-
/** @internal */
|
|
410
|
-
_createDemuxer(input) {
|
|
411
|
-
return new AdtsDemuxer(input);
|
|
412
|
-
}
|
|
413
|
-
get name() {
|
|
414
|
-
return 'ADTS';
|
|
415
|
-
}
|
|
416
|
-
get mimeType() {
|
|
417
|
-
return 'audio/aac';
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
/**
|
|
421
|
-
* MP4 input format singleton.
|
|
422
|
-
* @group Input formats
|
|
423
|
-
* @public
|
|
424
|
-
*/
|
|
425
|
-
export const MP4 = /* #__PURE__ */ new Mp4InputFormat();
|
|
426
|
-
/**
|
|
427
|
-
* QuickTime File Format input format singleton.
|
|
428
|
-
* @group Input formats
|
|
429
|
-
* @public
|
|
430
|
-
*/
|
|
431
|
-
export const QTFF = /* #__PURE__ */ new QuickTimeInputFormat();
|
|
432
|
-
/**
|
|
433
|
-
* Matroska input format singleton.
|
|
434
|
-
* @group Input formats
|
|
435
|
-
* @public
|
|
436
|
-
*/
|
|
437
|
-
export const MATROSKA = /* #__PURE__ */ new MatroskaInputFormat();
|
|
438
|
-
/**
|
|
439
|
-
* WebM input format singleton.
|
|
440
|
-
* @group Input formats
|
|
441
|
-
* @public
|
|
442
|
-
*/
|
|
443
|
-
export const WEBM = /* #__PURE__ */ new WebMInputFormat();
|
|
444
|
-
/**
|
|
445
|
-
* MP3 input format singleton.
|
|
446
|
-
* @group Input formats
|
|
447
|
-
* @public
|
|
448
|
-
*/
|
|
449
|
-
export const MP3 = /* #__PURE__ */ new Mp3InputFormat();
|
|
450
|
-
/**
|
|
451
|
-
* WAVE input format singleton.
|
|
452
|
-
* @group Input formats
|
|
453
|
-
* @public
|
|
454
|
-
*/
|
|
455
|
-
export const WAVE = /* #__PURE__ */ new WaveInputFormat();
|
|
456
|
-
/**
|
|
457
|
-
* Ogg input format singleton.
|
|
458
|
-
* @group Input formats
|
|
459
|
-
* @public
|
|
460
|
-
*/
|
|
461
|
-
export const OGG = /* #__PURE__ */ new OggInputFormat();
|
|
462
|
-
/**
|
|
463
|
-
* ADTS input format singleton.
|
|
464
|
-
* @group Input formats
|
|
465
|
-
* @public
|
|
466
|
-
*/
|
|
467
|
-
export const ADTS = /* #__PURE__ */ new AdtsInputFormat();
|
|
468
|
-
/**
|
|
469
|
-
* FLAC input format singleton.
|
|
470
|
-
* @group Input formats
|
|
471
|
-
* @public
|
|
472
|
-
*/
|
|
473
|
-
export const FLAC = /* #__PURE__ */ new FlacInputFormat();
|
|
474
|
-
/**
|
|
475
|
-
* List of all input format singletons. If you don't need to support all input formats, you should specify the
|
|
476
|
-
* formats individually for better tree shaking.
|
|
477
|
-
* @group Input formats
|
|
478
|
-
* @public
|
|
479
|
-
*/
|
|
480
|
-
export const ALL_FORMATS = [MP4, QTFF, MATROSKA, WEBM, WAVE, OGG, FLAC, MP3, ADTS];
|