@remotion/media-parser 4.0.269 → 4.0.271
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/dist/aac-codecprivate.js +6 -13
- package/dist/add-avc-profile-to-track.js +5 -9
- package/dist/buffer-iterator.js +8 -13
- package/dist/combine-uint8-arrays.js +1 -5
- package/dist/containers/aac/parse-aac.js +9 -13
- package/dist/containers/aac/types.js +1 -2
- package/dist/containers/avc/codec-string.js +1 -5
- package/dist/containers/avc/color.js +3 -9
- package/dist/containers/avc/create-sps-pps-data.js +5 -9
- package/dist/containers/avc/interpret-sps.js +7 -13
- package/dist/containers/avc/key.js +1 -5
- package/dist/containers/avc/parse-avc.js +3 -7
- package/dist/containers/avc/sps-and-pps.js +1 -5
- package/dist/containers/flac/get-block-size.js +1 -5
- package/dist/containers/flac/get-channel-count.d.ts +1 -1
- package/dist/containers/flac/get-channel-count.js +1 -5
- package/dist/containers/flac/get-duration-from-flac.js +1 -5
- package/dist/containers/flac/get-metadata-from-flac.js +1 -5
- package/dist/containers/flac/get-sample-rate.js +1 -5
- package/dist/containers/flac/parse-flac-frame.js +14 -19
- package/dist/containers/flac/parse-flac.js +15 -19
- package/dist/containers/flac/parse-header.js +1 -5
- package/dist/containers/flac/parse-metadata.js +1 -5
- package/dist/containers/flac/parse-streaminfo.js +3 -7
- package/dist/containers/flac/parse-unknown-block.js +1 -5
- package/dist/containers/flac/types.d.ts +2 -2
- package/dist/containers/flac/types.js +1 -2
- package/dist/containers/iso-base-media/base-media-box.js +1 -2
- package/dist/containers/iso-base-media/base-type.js +1 -2
- package/dist/containers/iso-base-media/esds/decoder-specific-config.js +1 -5
- package/dist/containers/iso-base-media/esds/esds-descriptors.js +5 -10
- package/dist/containers/iso-base-media/esds/esds.js +3 -7
- package/dist/containers/iso-base-media/ftyp.js +1 -5
- package/dist/containers/iso-base-media/get-actual-number-of-channels.js +4 -8
- package/dist/containers/iso-base-media/get-children.js +3 -7
- package/dist/containers/iso-base-media/get-keyframes.js +7 -11
- package/dist/containers/iso-base-media/get-moov-atom.js +22 -15
- package/dist/containers/iso-base-media/get-sample-positions-from-track.js +20 -24
- package/dist/containers/iso-base-media/get-video-codec-from-iso-track.d.ts +1 -1
- package/dist/containers/iso-base-media/get-video-codec-from-iso-track.js +3 -7
- package/dist/containers/iso-base-media/make-track.js +30 -34
- package/dist/containers/iso-base-media/mdat/mdat.js +16 -20
- package/dist/containers/iso-base-media/mdhd.js +1 -5
- package/dist/containers/iso-base-media/meta/hdlr.js +1 -5
- package/dist/containers/iso-base-media/meta/ilst.js +1 -5
- package/dist/containers/iso-base-media/moov/moov.js +3 -7
- package/dist/containers/iso-base-media/mvhd.js +7 -11
- package/dist/containers/iso-base-media/parse-boxes.js +5 -9
- package/dist/containers/iso-base-media/parse-icc-profile.js +4 -8
- package/dist/containers/iso-base-media/process-box.js +63 -67
- package/dist/containers/iso-base-media/stsd/av1c.js +1 -5
- package/dist/containers/iso-base-media/stsd/avcc.js +1 -5
- package/dist/containers/iso-base-media/stsd/colr.js +3 -7
- package/dist/containers/iso-base-media/stsd/ctts.js +1 -5
- package/dist/containers/iso-base-media/stsd/hvcc.js +3 -7
- package/dist/containers/iso-base-media/stsd/keys.js +1 -5
- package/dist/containers/iso-base-media/stsd/mebx.js +3 -7
- package/dist/containers/iso-base-media/stsd/pasp.js +1 -5
- package/dist/containers/iso-base-media/stsd/samples.js +8 -13
- package/dist/containers/iso-base-media/stsd/stco.js +1 -5
- package/dist/containers/iso-base-media/stsd/stsc.js +1 -5
- package/dist/containers/iso-base-media/stsd/stsd.js +3 -7
- package/dist/containers/iso-base-media/stsd/stss.js +1 -5
- package/dist/containers/iso-base-media/stsd/stsz.js +1 -5
- package/dist/containers/iso-base-media/stsd/stts.js +1 -5
- package/dist/containers/iso-base-media/tfdt.js +1 -5
- package/dist/containers/iso-base-media/tfhd.js +1 -5
- package/dist/containers/iso-base-media/tkhd.js +4 -8
- package/dist/containers/iso-base-media/to-date.js +1 -5
- package/dist/containers/iso-base-media/trak/trak.js +3 -7
- package/dist/containers/iso-base-media/traversal.d.ts +3 -2
- package/dist/containers/iso-base-media/traversal.js +42 -57
- package/dist/containers/iso-base-media/trun.js +2 -6
- package/dist/containers/iso-base-media/void-box.js +1 -2
- package/dist/containers/m3u/after-manifest-fetch.d.ts +8 -8
- package/dist/containers/m3u/after-manifest-fetch.js +33 -51
- package/dist/containers/m3u/fetch-m3u8-stream.d.ts +5 -2
- package/dist/containers/m3u/fetch-m3u8-stream.js +4 -12
- package/dist/containers/m3u/get-chunks.d.ts +1 -0
- package/dist/containers/m3u/get-chunks.js +6 -6
- package/dist/containers/m3u/get-duration-from-m3u.d.ts +2 -2
- package/dist/containers/m3u/get-duration-from-m3u.js +9 -8
- package/dist/containers/m3u/get-playlist.d.ts +6 -1
- package/dist/containers/m3u/get-playlist.js +19 -16
- package/dist/containers/m3u/get-streams.d.ts +14 -7
- package/dist/containers/m3u/get-streams.js +15 -18
- package/dist/containers/m3u/iterate-over-segment-files.d.ts +19 -0
- package/dist/containers/m3u/iterate-over-segment-files.js +106 -0
- package/dist/containers/m3u/m3u-child-stream.d.ts +0 -0
- package/dist/containers/m3u/m3u-child-stream.js +1 -0
- package/dist/containers/m3u/parse-directive.js +37 -10
- package/dist/containers/m3u/parse-m3u-manifest.js +3 -7
- package/dist/containers/m3u/parse-m3u-media-directive.d.ts +1 -0
- package/dist/containers/m3u/parse-m3u-media-directive.js +7 -7
- package/dist/containers/m3u/parse-m3u.js +18 -11
- package/dist/containers/m3u/parse-m3u8-text.js +3 -7
- package/dist/containers/m3u/parse-stream-inf.js +2 -7
- package/dist/containers/m3u/return-packets.d.ts +3 -2
- package/dist/containers/m3u/return-packets.js +92 -54
- package/dist/containers/m3u/run-over-m3u.d.ts +9 -0
- package/dist/containers/m3u/run-over-m3u.js +85 -0
- package/dist/containers/m3u/sample-sorter.d.ts +13 -0
- package/dist/containers/m3u/sample-sorter.js +60 -0
- package/dist/containers/m3u/select-stream.d.ts +10 -1
- package/dist/containers/m3u/select-stream.js +23 -7
- package/dist/containers/m3u/types.d.ts +15 -1
- package/dist/containers/m3u/types.js +1 -2
- package/dist/containers/mp3/get-duration.js +5 -9
- package/dist/containers/mp3/get-frame-length.js +2 -7
- package/dist/containers/mp3/get-metadata-from-mp3.d.ts +2 -2
- package/dist/containers/mp3/get-metadata-from-mp3.js +1 -5
- package/dist/containers/mp3/id3-v1.js +1 -5
- package/dist/containers/mp3/id3.js +1 -5
- package/dist/containers/mp3/parse-mp3.js +7 -11
- package/dist/containers/mp3/parse-mpeg-header.js +10 -14
- package/dist/containers/mp3/samples-per-mpeg-file.js +1 -5
- package/dist/containers/riff/expect-riff-box.js +11 -15
- package/dist/containers/riff/get-duration.js +7 -12
- package/dist/containers/riff/get-tracks-from-avi.js +20 -28
- package/dist/containers/riff/is-movi.js +1 -5
- package/dist/containers/riff/parse-avih.js +1 -5
- package/dist/containers/riff/parse-isft.js +1 -5
- package/dist/containers/riff/parse-list-box.js +3 -7
- package/dist/containers/riff/parse-movi.js +13 -18
- package/dist/containers/riff/parse-riff-body.js +9 -13
- package/dist/containers/riff/parse-riff-box.js +9 -13
- package/dist/containers/riff/parse-riff-header.js +1 -5
- package/dist/containers/riff/parse-riff.js +5 -9
- package/dist/containers/riff/parse-strf.js +1 -5
- package/dist/containers/riff/parse-strh.js +3 -7
- package/dist/containers/riff/parse-video-section.js +7 -11
- package/dist/containers/riff/riff-box.js +1 -2
- package/dist/containers/riff/timescale.js +1 -4
- package/dist/containers/riff/traversal.js +7 -15
- package/dist/containers/transport-stream/adts-header.js +6 -10
- package/dist/containers/transport-stream/boxes.js +1 -2
- package/dist/containers/transport-stream/discard-rest-of-packet.js +2 -7
- package/dist/containers/transport-stream/find-separator.js +1 -4
- package/dist/containers/transport-stream/get-tracks.js +7 -12
- package/dist/containers/transport-stream/handle-aac-packet.js +12 -16
- package/dist/containers/transport-stream/handle-avc-packet.js +22 -26
- package/dist/containers/transport-stream/next-pes-header-store.js +1 -5
- package/dist/containers/transport-stream/parse-packet.js +13 -17
- package/dist/containers/transport-stream/parse-pat.js +5 -10
- package/dist/containers/transport-stream/parse-pes.js +1 -5
- package/dist/containers/transport-stream/parse-pmt.js +3 -7
- package/dist/containers/transport-stream/parse-stream-packet.js +13 -17
- package/dist/containers/transport-stream/parse-transport-stream.js +5 -9
- package/dist/containers/transport-stream/process-stream-buffers.js +10 -15
- package/dist/containers/transport-stream/traversal.js +4 -10
- package/dist/containers/wav/get-duration-from-wav.js +3 -8
- package/dist/containers/wav/get-metadata-from-wav.d.ts +2 -2
- package/dist/containers/wav/get-metadata-from-wav.js +1 -5
- package/dist/containers/wav/parse-data.js +5 -9
- package/dist/containers/wav/parse-fmt.js +3 -7
- package/dist/containers/wav/parse-header.js +1 -5
- package/dist/containers/wav/parse-id3.js +1 -5
- package/dist/containers/wav/parse-list.js +10 -6
- package/dist/containers/wav/parse-video-section.js +3 -7
- package/dist/containers/wav/parse-wav.js +15 -19
- package/dist/containers/wav/types.d.ts +2 -2
- package/dist/containers/wav/types.js +1 -2
- package/dist/containers/webm/allowed-partial-segments.js +1 -4
- package/dist/containers/webm/av1-codec-private.js +3 -7
- package/dist/containers/webm/color.js +6 -10
- package/dist/containers/webm/description.js +6 -10
- package/dist/containers/webm/get-ready-tracks.js +13 -18
- package/dist/containers/webm/get-sample-from-block.js +12 -16
- package/dist/containers/webm/make-track.js +43 -48
- package/dist/containers/webm/parse-ebml.js +14 -19
- package/dist/containers/webm/parse-webm-header.js +3 -7
- package/dist/containers/webm/segments/all-segments.js +168 -173
- package/dist/containers/webm/segments/block-simple-block-flags.js +4 -8
- package/dist/containers/webm/segments/track-entry.js +1 -5
- package/dist/containers/webm/segments.js +9 -13
- package/dist/containers/webm/traversal.js +37 -67
- package/dist/convert-audio-or-video-sample.js +1 -5
- package/dist/download-and-parse-media.js +44 -46
- package/dist/emit-available-info.js +38 -38
- package/dist/emitter.js +1 -5
- package/dist/errors.d.ts +2 -17
- package/dist/errors.js +10 -30
- package/dist/esm/fetch.mjs +93 -67
- package/dist/esm/index.mjs +1189 -355
- package/dist/esm/node.mjs +59 -36
- package/dist/esm/universal.mjs +323 -0
- package/dist/esm/web-file.mjs +55 -43
- package/dist/esm/web.mjs +257 -0
- package/dist/esm/worker-server-entry.mjs +13056 -0
- package/dist/esm/worker-server.mjs +12914 -0
- package/dist/esm/worker-web-entry.mjs +12969 -0
- package/dist/esm/worker.mjs +439 -0
- package/dist/fetch.js +1 -17
- package/dist/file-types/bmp.js +3 -7
- package/dist/file-types/detect-file-type.js +24 -38
- package/dist/file-types/index.js +22 -26
- package/dist/file-types/jpeg.js +4 -9
- package/dist/file-types/pdf.js +3 -7
- package/dist/file-types/png.js +4 -9
- package/dist/file-types/webp.js +3 -7
- package/dist/forward-controller.js +1 -5
- package/dist/get-audio-codec.js +25 -38
- package/dist/get-container.d.ts +3 -3
- package/dist/get-container.js +5 -10
- package/dist/get-dimensions.js +8 -13
- package/dist/get-duration.js +27 -34
- package/dist/get-fields-from-callbacks.js +1 -5
- package/dist/get-fps.js +24 -34
- package/dist/get-is-hdr.js +5 -10
- package/dist/get-keyframes.js +6 -11
- package/dist/get-location.js +4 -9
- package/dist/get-number-of-audio-channels.js +2 -7
- package/dist/get-sample-aspect-ratio.js +17 -30
- package/dist/get-sample-positions-from-lpcm.js +5 -9
- package/dist/get-sample-positions.js +1 -5
- package/dist/get-sample-rate.js +2 -7
- package/dist/get-tracks.d.ts +5 -0
- package/dist/get-tracks.js +37 -44
- package/dist/get-video-codec.js +26 -34
- package/dist/has-all-info.js +33 -38
- package/dist/index.d.ts +44 -36
- package/dist/index.js +34 -47
- package/dist/init-video.d.ts +1 -1
- package/dist/init-video.js +47 -20
- package/dist/internal-parse-media.js +39 -41
- package/dist/is-audio-structure.d.ts +2 -2
- package/dist/is-audio-structure.js +1 -5
- package/dist/log.js +8 -12
- package/dist/make-hvc1-codec-strings.js +1 -5
- package/dist/media-parser-controller.js +7 -11
- package/dist/metadata/get-metadata.d.ts +4 -4
- package/dist/metadata/get-metadata.js +17 -22
- package/dist/metadata/metadata-from-iso.d.ts +3 -3
- package/dist/metadata/metadata-from-iso.js +12 -17
- package/dist/metadata/metadata-from-matroska.d.ts +2 -2
- package/dist/metadata/metadata-from-matroska.js +3 -7
- package/dist/metadata/metadata-from-riff.d.ts +2 -2
- package/dist/metadata/metadata-from-riff.js +3 -7
- package/dist/node-writer.js +1 -17
- package/dist/node.js +1 -17
- package/dist/options.d.ts +32 -25
- package/dist/options.js +1 -2
- package/dist/parse-media-on-browser-worker.d.ts +2 -0
- package/dist/parse-media-on-browser-worker.js +4 -0
- package/dist/parse-media-on-server-worker.d.ts +2 -0
- package/dist/parse-media-on-server-worker.js +4 -0
- package/dist/parse-media-on-web-worker.d.ts +2 -0
- package/dist/parse-media-on-web-worker.js +4 -0
- package/dist/parse-media-on-worker-entry.d.ts +2 -0
- package/dist/parse-media-on-worker-entry.js +269 -0
- package/dist/parse-media-on-worker.d.ts +2 -0
- package/dist/parse-media-on-worker.js +4 -0
- package/dist/parse-media.js +10 -12
- package/dist/parse-result.d.ts +3 -3
- package/dist/parse-result.js +1 -2
- package/dist/pause-signal.js +1 -5
- package/dist/perform-seek.js +6 -10
- package/dist/readers/fetch/get-body-and-reader.js +1 -5
- package/dist/readers/fetch/resolve-url.d.ts +1 -1
- package/dist/readers/fetch/resolve-url.js +1 -5
- package/dist/readers/from-fetch.d.ts +4 -1
- package/dist/readers/from-fetch.js +109 -94
- package/dist/readers/from-node.d.ts +4 -1
- package/dist/readers/from-node.js +58 -41
- package/dist/readers/from-web-file.d.ts +4 -1
- package/dist/readers/from-web-file.js +55 -49
- package/dist/readers/reader.d.ts +5 -1
- package/dist/readers/reader.js +1 -2
- package/dist/readers/universal.d.ts +2 -0
- package/dist/readers/universal.js +35 -0
- package/dist/readers/web.d.ts +2 -0
- package/dist/readers/web.js +22 -0
- package/dist/register-track.js +9 -15
- package/dist/remotion-license-acknowledge.js +4 -8
- package/dist/run-parse-iteration.js +26 -25
- package/dist/samples-from-moof.js +8 -12
- package/dist/skip.js +1 -5
- package/dist/state/aac-state.js +1 -5
- package/dist/state/can-skip-tracks.d.ts +2 -2
- package/dist/state/can-skip-tracks.js +3 -8
- package/dist/state/emitted-fields.js +1 -5
- package/dist/state/flac-state.js +1 -5
- package/dist/state/has-tracks-section.js +3 -7
- package/dist/state/images.js +1 -5
- package/dist/state/iso-base-media/cached-sample-positions.js +8 -13
- package/dist/state/iso-base-media/iso-state.js +5 -9
- package/dist/state/iso-base-media/moov-box.js +1 -5
- package/dist/state/keyframes.js +1 -5
- package/dist/state/last-eventloop-break.js +3 -7
- package/dist/state/m3u-state.d.ts +37 -16
- package/dist/state/m3u-state.js +98 -29
- package/dist/state/may-skip-video-data.js +3 -7
- package/dist/state/mp3.js +1 -5
- package/dist/state/need-samples-for-fields.js +1 -5
- package/dist/state/parser-state.d.ts +39 -33
- package/dist/state/parser-state.js +37 -41
- package/dist/state/riff.js +1 -5
- package/dist/state/sample-callbacks.js +8 -12
- package/dist/state/slow-duration-fps.js +1 -5
- package/dist/state/structure.d.ts +4 -4
- package/dist/state/structure.js +1 -5
- package/dist/state/transport-stream.js +3 -7
- package/dist/state/video-section.js +1 -5
- package/dist/state/webm.js +5 -9
- package/dist/throttled-progress.js +21 -14
- package/dist/truthy.js +1 -4
- package/dist/universal.d.ts +1 -0
- package/dist/universal.js +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -4
- package/dist/web-file.js +1 -17
- package/dist/web.d.ts +1 -0
- package/dist/web.js +1 -0
- package/dist/webcodec-sample-types.d.ts +6 -4
- package/dist/webcodec-sample-types.js +1 -2
- package/dist/worker/forward-controller.d.ts +3 -0
- package/dist/worker/forward-controller.js +20 -0
- package/dist/worker/serialize-error.d.ts +4 -0
- package/dist/worker/serialize-error.js +95 -0
- package/dist/worker/worker-types.d.ts +243 -0
- package/dist/worker/worker-types.js +1 -0
- package/dist/worker-bun-entry.d.ts +1 -0
- package/dist/worker-bun-entry.js +5 -0
- package/dist/worker-entry.d.ts +1 -0
- package/dist/worker-entry.js +5 -0
- package/dist/worker-server-entry.d.ts +1 -0
- package/dist/worker-server-entry.js +5 -0
- package/dist/worker-server.d.ts +2 -0
- package/dist/worker-server.js +381 -0
- package/dist/worker-web-entry.d.ts +1 -0
- package/dist/worker-web-entry.js +5 -0
- package/dist/worker.d.ts +2 -0
- package/dist/worker.js +267 -0
- package/dist/writers/node.js +16 -23
- package/dist/writers/writer.js +1 -2
- package/package.json +40 -21
- package/fetch.js +0 -2
- package/test.json +0 -663
- package/web-file.js +0 -2
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseId3 = void 0;
|
|
4
1
|
function combine28Bits(a, b, c, d) {
|
|
5
2
|
// Mask each number to ignore first bit (& 0x7F)
|
|
6
3
|
const val1 = a & 0x7f; // 7 bits from first byte
|
|
@@ -10,7 +7,7 @@ function combine28Bits(a, b, c, d) {
|
|
|
10
7
|
// Combine all values using bitwise operations
|
|
11
8
|
return (val1 << 21) | (val2 << 14) | (val3 << 7) | val4;
|
|
12
9
|
}
|
|
13
|
-
const parseId3 = ({ state }) => {
|
|
10
|
+
export const parseId3 = ({ state }) => {
|
|
14
11
|
const { iterator } = state;
|
|
15
12
|
if (iterator.bytesRemaining() < 9) {
|
|
16
13
|
return;
|
|
@@ -80,4 +77,3 @@ const parseId3 = ({ state }) => {
|
|
|
80
77
|
metatags: entries,
|
|
81
78
|
});
|
|
82
79
|
};
|
|
83
|
-
exports.parseId3 = parseId3;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const id3_v1_1 = require("./id3-v1");
|
|
6
|
-
const parse_mpeg_header_1 = require("./parse-mpeg-header");
|
|
7
|
-
const parseMp3 = async (state) => {
|
|
1
|
+
import { parseId3 } from './id3';
|
|
2
|
+
import { parseID3V1 } from './id3-v1';
|
|
3
|
+
import { parseMpegHeader } from './parse-mpeg-header';
|
|
4
|
+
export const parseMp3 = async (state) => {
|
|
8
5
|
const { iterator } = state;
|
|
9
6
|
if (iterator.bytesRemaining() < 3) {
|
|
10
7
|
return null;
|
|
@@ -14,20 +11,19 @@ const parseMp3 = async (state) => {
|
|
|
14
11
|
returnToCheckpoint();
|
|
15
12
|
// ID3 v1
|
|
16
13
|
if (bytes[0] === 0x54 && bytes[1] === 0x41 && bytes[2] === 0x47) {
|
|
17
|
-
|
|
14
|
+
parseID3V1(iterator);
|
|
18
15
|
return null;
|
|
19
16
|
}
|
|
20
17
|
// ID3 v2 or v3
|
|
21
18
|
if (bytes[0] === 0x49 && bytes[1] === 0x44 && bytes[2] === 0x33) {
|
|
22
|
-
|
|
19
|
+
parseId3({ state });
|
|
23
20
|
return null;
|
|
24
21
|
}
|
|
25
22
|
if (bytes[0] === 0xff) {
|
|
26
|
-
await
|
|
23
|
+
await parseMpegHeader({
|
|
27
24
|
state,
|
|
28
25
|
});
|
|
29
26
|
return null;
|
|
30
27
|
}
|
|
31
28
|
throw new Error('Unknown MP3 header ' + JSON.stringify(bytes));
|
|
32
29
|
};
|
|
33
|
-
exports.parseMp3 = parseMp3;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// spec: http://www.mp3-tech.org/programmer/frame_header.html
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const get_frame_length_1 = require("./get-frame-length");
|
|
8
|
-
const samples_per_mpeg_file_1 = require("./samples-per-mpeg-file");
|
|
2
|
+
import { Log } from '../../log';
|
|
3
|
+
import { registerAudioTrack } from '../../register-track';
|
|
4
|
+
import { getAverageMpegFrameLength, getMpegFrameLength, } from './get-frame-length';
|
|
5
|
+
import { getSamplesPerMpegFrame } from './samples-per-mpeg-file';
|
|
9
6
|
function getSamplingFrequency({ bits, mpegVersion, }) {
|
|
10
7
|
const samplingTable = {
|
|
11
8
|
0b00: { MPEG1: 44100, MPEG2: 22050 },
|
|
@@ -144,7 +141,7 @@ function getBitrateKB({ bits, mpegVersion, level, }) {
|
|
|
144
141
|
// Return the corresponding bitrate
|
|
145
142
|
return bitrateTable[bits][key];
|
|
146
143
|
}
|
|
147
|
-
const parseMpegHeader = async ({ state, }) => {
|
|
144
|
+
export const parseMpegHeader = async ({ state, }) => {
|
|
148
145
|
const { iterator } = state;
|
|
149
146
|
const initialOffset = iterator.counter.getOffset();
|
|
150
147
|
if (iterator.bytesRemaining() < 32) {
|
|
@@ -208,8 +205,8 @@ const parseMpegHeader = async ({ state, }) => {
|
|
|
208
205
|
iterator.getBits(1); // original
|
|
209
206
|
iterator.getBits(2); // emphasis
|
|
210
207
|
const numberOfChannels = channelMode === 0b11 ? 1 : 2;
|
|
211
|
-
const samplesPerFrame =
|
|
212
|
-
const frameLength =
|
|
208
|
+
const samplesPerFrame = getSamplesPerMpegFrame({ mpegVersion, layer });
|
|
209
|
+
const frameLength = getMpegFrameLength({
|
|
213
210
|
bitrateKbit,
|
|
214
211
|
padding,
|
|
215
212
|
samplesPerFrame,
|
|
@@ -232,7 +229,7 @@ const parseMpegHeader = async ({ state, }) => {
|
|
|
232
229
|
const isVbr = asText.includes('Xing') || asText.includes('VBRI');
|
|
233
230
|
isInfoTag = isVbr || asText.includes('Info');
|
|
234
231
|
if (isVbr) {
|
|
235
|
-
|
|
232
|
+
Log.verbose(state.logLevel, 'MP3 has variable bit rate. Requiring whole file to be read');
|
|
236
233
|
}
|
|
237
234
|
else {
|
|
238
235
|
state.mp3Info.setCbrMp3Info({
|
|
@@ -241,7 +238,7 @@ const parseMpegHeader = async ({ state, }) => {
|
|
|
241
238
|
}
|
|
242
239
|
if (!isInfoTag) {
|
|
243
240
|
state.mp3Info.setMp3Info(info);
|
|
244
|
-
await
|
|
241
|
+
await registerAudioTrack({
|
|
245
242
|
container: 'mp3',
|
|
246
243
|
state,
|
|
247
244
|
track: {
|
|
@@ -260,7 +257,7 @@ const parseMpegHeader = async ({ state, }) => {
|
|
|
260
257
|
state.callbacks.tracks.setIsDone(state.logLevel);
|
|
261
258
|
}
|
|
262
259
|
}
|
|
263
|
-
const avgLength =
|
|
260
|
+
const avgLength = getAverageMpegFrameLength({
|
|
264
261
|
bitrateKbit,
|
|
265
262
|
layer,
|
|
266
263
|
samplesPerFrame,
|
|
@@ -289,4 +286,3 @@ const parseMpegHeader = async ({ state, }) => {
|
|
|
289
286
|
});
|
|
290
287
|
}
|
|
291
288
|
};
|
|
292
|
-
exports.parseMpegHeader = parseMpegHeader;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSamplesPerMpegFrame = void 0;
|
|
4
|
-
const getSamplesPerMpegFrame = ({ mpegVersion, layer, }) => {
|
|
1
|
+
export const getSamplesPerMpegFrame = ({ mpegVersion, layer, }) => {
|
|
5
2
|
if (mpegVersion === 1) {
|
|
6
3
|
if (layer === 1) {
|
|
7
4
|
return 384;
|
|
@@ -23,4 +20,3 @@ const getSamplesPerMpegFrame = ({ mpegVersion, layer, }) => {
|
|
|
23
20
|
}
|
|
24
21
|
throw new Error('Invalid MPEG layer');
|
|
25
22
|
};
|
|
26
|
-
exports.getSamplesPerMpegFrame = getSamplesPerMpegFrame;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const is_movi_1 = require("./is-movi");
|
|
7
|
-
const parse_riff_box_1 = require("./parse-riff-box");
|
|
8
|
-
const expectRiffBox = async (state) => {
|
|
1
|
+
import { registerAudioTrack, registerVideoTrackWhenProfileIsAvailable, } from '../../register-track';
|
|
2
|
+
import { makeAviAudioTrack, makeAviVideoTrack } from './get-tracks-from-avi';
|
|
3
|
+
import { isMoviAtom } from './is-movi';
|
|
4
|
+
import { parseRiffBox } from './parse-riff-box';
|
|
5
|
+
export const expectRiffBox = async (state) => {
|
|
9
6
|
const { iterator } = state;
|
|
10
7
|
// Need at least 16 bytes to read LIST,size,movi,size
|
|
11
8
|
if (state.iterator.bytesRemaining() < 16) {
|
|
@@ -14,7 +11,7 @@ const expectRiffBox = async (state) => {
|
|
|
14
11
|
const checkpoint = iterator.startCheckpoint();
|
|
15
12
|
const ckId = iterator.getByteString(4, false);
|
|
16
13
|
const ckSize = iterator.getUint32Le();
|
|
17
|
-
if (
|
|
14
|
+
if (isMoviAtom(iterator, ckId)) {
|
|
18
15
|
iterator.discard(4);
|
|
19
16
|
state.videoSection.setVideoSection({
|
|
20
17
|
start: iterator.counter.getOffset(),
|
|
@@ -26,30 +23,30 @@ const expectRiffBox = async (state) => {
|
|
|
26
23
|
checkpoint.returnToCheckpoint();
|
|
27
24
|
return null;
|
|
28
25
|
}
|
|
29
|
-
const box = await
|
|
26
|
+
const box = await parseRiffBox({
|
|
30
27
|
id: ckId,
|
|
31
28
|
size: ckSize,
|
|
32
29
|
state,
|
|
33
30
|
});
|
|
34
31
|
if (box.type === 'strh-box') {
|
|
35
32
|
if (box.strf.type === 'strf-box-audio' && state.onAudioTrack) {
|
|
36
|
-
const audioTrack =
|
|
33
|
+
const audioTrack = makeAviAudioTrack({
|
|
37
34
|
index: state.riff.getNextTrackIndex(),
|
|
38
35
|
strf: box.strf,
|
|
39
36
|
});
|
|
40
|
-
await
|
|
37
|
+
await registerAudioTrack({
|
|
41
38
|
state,
|
|
42
39
|
track: audioTrack,
|
|
43
40
|
container: 'avi',
|
|
44
41
|
});
|
|
45
42
|
}
|
|
46
43
|
if (state.onVideoTrack && box.strf.type === 'strf-box-video') {
|
|
47
|
-
const videoTrack =
|
|
44
|
+
const videoTrack = makeAviVideoTrack({
|
|
48
45
|
strh: box,
|
|
49
46
|
index: state.riff.getNextTrackIndex(),
|
|
50
47
|
strf: box.strf,
|
|
51
48
|
});
|
|
52
|
-
|
|
49
|
+
registerVideoTrackWhenProfileIsAvailable({
|
|
53
50
|
state,
|
|
54
51
|
track: videoTrack,
|
|
55
52
|
container: 'avi',
|
|
@@ -59,4 +56,3 @@ const expectRiffBox = async (state) => {
|
|
|
59
56
|
}
|
|
60
57
|
return box;
|
|
61
58
|
};
|
|
62
|
-
exports.expectRiffBox = expectRiffBox;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const traversal_1 = require("./traversal");
|
|
5
|
-
const getDurationFromAvi = (structure) => {
|
|
6
|
-
const strl = (0, traversal_1.getStrlBoxes)(structure);
|
|
1
|
+
import { getStrhBox, getStrlBoxes } from './traversal';
|
|
2
|
+
export const getDurationFromAvi = (structure) => {
|
|
3
|
+
const strl = getStrlBoxes(structure);
|
|
7
4
|
const lengths = [];
|
|
8
5
|
for (const s of strl) {
|
|
9
|
-
const strh =
|
|
6
|
+
const strh = getStrhBox(s.children);
|
|
10
7
|
if (!strh) {
|
|
11
8
|
throw new Error('No strh box');
|
|
12
9
|
}
|
|
@@ -16,11 +13,10 @@ const getDurationFromAvi = (structure) => {
|
|
|
16
13
|
}
|
|
17
14
|
return Math.max(...lengths);
|
|
18
15
|
};
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
const strl = (0, traversal_1.getStrlBoxes)(structure);
|
|
16
|
+
export const getSampleRateFromAvi = (structure) => {
|
|
17
|
+
const strl = getStrlBoxes(structure);
|
|
22
18
|
for (const s of strl) {
|
|
23
|
-
const strh =
|
|
19
|
+
const strh = getStrhBox(s.children);
|
|
24
20
|
if (!strh) {
|
|
25
21
|
throw new Error('No strh box');
|
|
26
22
|
}
|
|
@@ -30,4 +26,3 @@ const getSampleRateFromAvi = (structure) => {
|
|
|
30
26
|
}
|
|
31
27
|
return null;
|
|
32
28
|
};
|
|
33
|
-
exports.getSampleRateFromAvi = getSampleRateFromAvi;
|
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
exports.TO_BE_OVERRIDDEN_LATER = 'to-be-overriden-later';
|
|
8
|
-
const getNumberOfTracks = (structure) => {
|
|
9
|
-
const avihBox = (0, traversal_1.getAvihBox)(structure);
|
|
1
|
+
import { addAvcProfileToTrack } from '../../add-avc-profile-to-track';
|
|
2
|
+
import { MEDIA_PARSER_RIFF_TIMESCALE } from './timescale';
|
|
3
|
+
import { getAvihBox, getStrhBox, getStrlBoxes } from './traversal';
|
|
4
|
+
export const TO_BE_OVERRIDDEN_LATER = 'to-be-overriden-later';
|
|
5
|
+
export const getNumberOfTracks = (structure) => {
|
|
6
|
+
const avihBox = getAvihBox(structure);
|
|
10
7
|
if (avihBox) {
|
|
11
8
|
return avihBox.streams;
|
|
12
9
|
}
|
|
13
10
|
throw new Error('No avih box found');
|
|
14
11
|
};
|
|
15
|
-
|
|
16
|
-
const makeAviAudioTrack = ({ strf, index, }) => {
|
|
12
|
+
export const makeAviAudioTrack = ({ strf, index, }) => {
|
|
17
13
|
// 255 = AAC
|
|
18
14
|
if (strf.formatTag !== 255) {
|
|
19
15
|
throw new Error(`Unsupported audio format ${strf.formatTag}`);
|
|
@@ -26,19 +22,18 @@ const makeAviAudioTrack = ({ strf, index, }) => {
|
|
|
26
22
|
description: new Uint8Array([18, 16]),
|
|
27
23
|
numberOfChannels: strf.numberOfChannels,
|
|
28
24
|
sampleRate: strf.sampleRate,
|
|
29
|
-
timescale:
|
|
25
|
+
timescale: MEDIA_PARSER_RIFF_TIMESCALE,
|
|
30
26
|
trackId: index,
|
|
31
27
|
trakBox: null,
|
|
32
28
|
};
|
|
33
29
|
};
|
|
34
|
-
|
|
35
|
-
const makeAviVideoTrack = ({ strh, strf, index, }) => {
|
|
30
|
+
export const makeAviVideoTrack = ({ strh, strf, index, }) => {
|
|
36
31
|
if (strh.handler !== 'H264') {
|
|
37
32
|
throw new Error(`Unsupported video codec ${strh.handler}`);
|
|
38
33
|
}
|
|
39
34
|
return {
|
|
40
35
|
codecPrivate: null,
|
|
41
|
-
codec:
|
|
36
|
+
codec: TO_BE_OVERRIDDEN_LATER,
|
|
42
37
|
codecWithoutConfig: 'h264',
|
|
43
38
|
codedHeight: strf.height,
|
|
44
39
|
codedWidth: strf.width,
|
|
@@ -46,7 +41,7 @@ const makeAviVideoTrack = ({ strh, strf, index, }) => {
|
|
|
46
41
|
height: strf.height,
|
|
47
42
|
type: 'video',
|
|
48
43
|
displayAspectHeight: strf.height,
|
|
49
|
-
timescale:
|
|
44
|
+
timescale: MEDIA_PARSER_RIFF_TIMESCALE,
|
|
50
45
|
description: undefined,
|
|
51
46
|
trackId: index,
|
|
52
47
|
color: {
|
|
@@ -65,24 +60,23 @@ const makeAviVideoTrack = ({ strh, strf, index, }) => {
|
|
|
65
60
|
fps: strh.rate / strh.scale,
|
|
66
61
|
};
|
|
67
62
|
};
|
|
68
|
-
|
|
69
|
-
const getTracksFromAvi = (structure, state) => {
|
|
63
|
+
export const getTracksFromAvi = (structure, state) => {
|
|
70
64
|
const videoTracks = [];
|
|
71
65
|
const audioTracks = [];
|
|
72
66
|
const otherTracks = [];
|
|
73
|
-
const boxes =
|
|
67
|
+
const boxes = getStrlBoxes(structure);
|
|
74
68
|
let i = 0;
|
|
75
69
|
for (const box of boxes) {
|
|
76
|
-
const strh =
|
|
70
|
+
const strh = getStrhBox(box.children);
|
|
77
71
|
if (!strh) {
|
|
78
72
|
continue;
|
|
79
73
|
}
|
|
80
74
|
const { strf } = strh;
|
|
81
75
|
if (strf.type === 'strf-box-video') {
|
|
82
|
-
videoTracks.push(
|
|
76
|
+
videoTracks.push(addAvcProfileToTrack(makeAviVideoTrack({ strh, strf, index: i }), state.riff.getAvcProfile()));
|
|
83
77
|
}
|
|
84
78
|
else if (strh.fccType === 'auds') {
|
|
85
|
-
audioTracks.push(
|
|
79
|
+
audioTracks.push(makeAviAudioTrack({ strf, index: i }));
|
|
86
80
|
}
|
|
87
81
|
else {
|
|
88
82
|
throw new Error(`Unsupported track type ${strh.fccType}`);
|
|
@@ -91,20 +85,18 @@ const getTracksFromAvi = (structure, state) => {
|
|
|
91
85
|
}
|
|
92
86
|
return { audioTracks, otherTracks, videoTracks };
|
|
93
87
|
};
|
|
94
|
-
|
|
95
|
-
const hasAllTracksFromAvi = (state) => {
|
|
88
|
+
export const hasAllTracksFromAvi = (state) => {
|
|
96
89
|
try {
|
|
97
90
|
const structure = state.getRiffStructure();
|
|
98
|
-
const numberOfTracks =
|
|
99
|
-
const tracks =
|
|
91
|
+
const numberOfTracks = getNumberOfTracks(structure);
|
|
92
|
+
const tracks = getTracksFromAvi(structure, state);
|
|
100
93
|
return (tracks.videoTracks.length +
|
|
101
94
|
tracks.audioTracks.length +
|
|
102
95
|
tracks.otherTracks.length ===
|
|
103
96
|
numberOfTracks &&
|
|
104
|
-
!tracks.videoTracks.find((t) => t.codec ===
|
|
97
|
+
!tracks.videoTracks.find((t) => t.codec === TO_BE_OVERRIDDEN_LATER));
|
|
105
98
|
}
|
|
106
99
|
catch (_a) {
|
|
107
100
|
return false;
|
|
108
101
|
}
|
|
109
102
|
};
|
|
110
|
-
exports.hasAllTracksFromAvi = hasAllTracksFromAvi;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isMoviAtom = void 0;
|
|
4
|
-
const isMoviAtom = (iterator, ckId) => {
|
|
1
|
+
export const isMoviAtom = (iterator, ckId) => {
|
|
5
2
|
if (ckId !== 'LIST') {
|
|
6
3
|
return false;
|
|
7
4
|
}
|
|
@@ -9,4 +6,3 @@ const isMoviAtom = (iterator, ckId) => {
|
|
|
9
6
|
iterator.counter.decrement(4);
|
|
10
7
|
return listType === 'movi';
|
|
11
8
|
};
|
|
12
|
-
exports.isMoviAtom = isMoviAtom;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseAvih = void 0;
|
|
4
|
-
const parseAvih = ({ iterator, size, }) => {
|
|
1
|
+
export const parseAvih = ({ iterator, size, }) => {
|
|
5
2
|
const { expectNoMoreBytes } = iterator.startBox(size);
|
|
6
3
|
const dwMicroSecPerFrame = iterator.getUint32Le();
|
|
7
4
|
const dwMaxBytesPerSec = iterator.getUint32Le();
|
|
@@ -29,4 +26,3 @@ const parseAvih = ({ iterator, size, }) => {
|
|
|
29
26
|
width,
|
|
30
27
|
};
|
|
31
28
|
};
|
|
32
|
-
exports.parseAvih = parseAvih;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseIsft = void 0;
|
|
4
|
-
const parseIsft = ({ iterator, size, }) => {
|
|
1
|
+
export const parseIsft = ({ iterator, size, }) => {
|
|
5
2
|
const { expectNoMoreBytes } = iterator.startBox(size);
|
|
6
3
|
const software = iterator.getByteString(size - 1, false);
|
|
7
4
|
const last = iterator.getUint8();
|
|
@@ -14,4 +11,3 @@ const parseIsft = ({ iterator, size, }) => {
|
|
|
14
11
|
software,
|
|
15
12
|
};
|
|
16
13
|
};
|
|
17
|
-
exports.parseIsft = parseIsft;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.parseListBox = void 0;
|
|
4
|
-
const expect_riff_box_1 = require("./expect-riff-box");
|
|
5
|
-
const parseListBox = async ({ size, state, }) => {
|
|
1
|
+
import { expectRiffBox } from './expect-riff-box';
|
|
2
|
+
export const parseListBox = async ({ size, state, }) => {
|
|
6
3
|
const { iterator } = state;
|
|
7
4
|
const counter = iterator.counter.getOffset();
|
|
8
5
|
const listType = iterator.getByteString(4, false);
|
|
@@ -12,7 +9,7 @@ const parseListBox = async ({ size, state, }) => {
|
|
|
12
9
|
const boxes = [];
|
|
13
10
|
const maxOffset = counter + size;
|
|
14
11
|
while (iterator.counter.getOffset() < maxOffset) {
|
|
15
|
-
const box = await
|
|
12
|
+
const box = await expectRiffBox(state);
|
|
16
13
|
if (box === null) {
|
|
17
14
|
throw new Error('Unexpected result');
|
|
18
15
|
}
|
|
@@ -24,4 +21,3 @@ const parseListBox = async ({ size, state, }) => {
|
|
|
24
21
|
children: boxes,
|
|
25
22
|
};
|
|
26
23
|
};
|
|
27
|
-
exports.parseListBox = parseListBox;
|
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const key_1 = require("../avc/key");
|
|
6
|
-
const parse_avc_1 = require("../avc/parse-avc");
|
|
7
|
-
const traversal_1 = require("./traversal");
|
|
1
|
+
import { convertAudioOrVideoSampleToWebCodecsTimestamps } from '../../convert-audio-or-video-sample';
|
|
2
|
+
import { getKeyFrameOrDeltaFromAvcInfo } from '../avc/key';
|
|
3
|
+
import { parseAvc } from '../avc/parse-avc';
|
|
4
|
+
import { getStrhBox, getStrlBoxes } from './traversal';
|
|
8
5
|
const getStrhForIndex = (structure, trackId) => {
|
|
9
|
-
const boxes =
|
|
6
|
+
const boxes = getStrlBoxes(structure);
|
|
10
7
|
const box = boxes[trackId];
|
|
11
8
|
if (!box) {
|
|
12
9
|
throw new Error('Expected box');
|
|
13
10
|
}
|
|
14
|
-
const strh =
|
|
11
|
+
const strh = getStrhBox(box.children);
|
|
15
12
|
if (!strh) {
|
|
16
13
|
throw new Error('strh');
|
|
17
14
|
}
|
|
18
15
|
return strh;
|
|
19
16
|
};
|
|
20
|
-
const handleChunk = async ({ state, ckId, ckSize, }) => {
|
|
17
|
+
export const handleChunk = async ({ state, ckId, ckSize, }) => {
|
|
21
18
|
const { iterator } = state;
|
|
22
19
|
const offset = iterator.counter.getOffset();
|
|
23
20
|
const videoChunk = ckId.match(/^([0-9]{2})dc$/);
|
|
@@ -29,8 +26,8 @@ const handleChunk = async ({ state, ckId, ckSize, }) => {
|
|
|
29
26
|
const timeInSec = nthSample / samplesPerSecond;
|
|
30
27
|
const timestamp = timeInSec;
|
|
31
28
|
const data = iterator.getSlice(ckSize);
|
|
32
|
-
const infos =
|
|
33
|
-
const keyOrDelta =
|
|
29
|
+
const infos = parseAvc(data);
|
|
30
|
+
const keyOrDelta = getKeyFrameOrDeltaFromAvcInfo(infos);
|
|
34
31
|
const avcProfile = infos.find((i) => i.type === 'avc-profile');
|
|
35
32
|
const ppsProfile = infos.find((i) => i.type === 'avc-pps');
|
|
36
33
|
if (avcProfile && ppsProfile && !state.riff.getAvcProfile()) {
|
|
@@ -40,7 +37,7 @@ const handleChunk = async ({ state, ckId, ckSize, }) => {
|
|
|
40
37
|
// We must also NOT pass a duration because if the the next sample is 0,
|
|
41
38
|
// this sample would be longer. Chrome will pad it with silence.
|
|
42
39
|
// If we'd pass a duration instead, it would shift the audio and we think that audio is not finished
|
|
43
|
-
await state.callbacks.onVideoSample(trackId,
|
|
40
|
+
await state.callbacks.onVideoSample(trackId, convertAudioOrVideoSampleToWebCodecsTimestamps({
|
|
44
41
|
cts: timestamp,
|
|
45
42
|
dts: timestamp,
|
|
46
43
|
data,
|
|
@@ -67,7 +64,7 @@ const handleChunk = async ({ state, ckId, ckSize, }) => {
|
|
|
67
64
|
// We must also NOT pass a duration because if the the next sample is 0,
|
|
68
65
|
// this sample would be longer. Chrome will pad it with silence.
|
|
69
66
|
// If we'd pass a duration instead, it would shift the audio and we think that audio is not finished
|
|
70
|
-
await state.callbacks.onAudioSample(trackId,
|
|
67
|
+
await state.callbacks.onAudioSample(trackId, convertAudioOrVideoSampleToWebCodecsTimestamps({
|
|
71
68
|
cts: timestamp,
|
|
72
69
|
dts: timestamp,
|
|
73
70
|
data,
|
|
@@ -80,8 +77,7 @@ const handleChunk = async ({ state, ckId, ckSize, }) => {
|
|
|
80
77
|
}, 1));
|
|
81
78
|
}
|
|
82
79
|
};
|
|
83
|
-
|
|
84
|
-
const parseMovi = async ({ state, }) => {
|
|
80
|
+
export const parseMovi = async ({ state, }) => {
|
|
85
81
|
const { iterator } = state;
|
|
86
82
|
if (iterator.bytesRemaining() < 8) {
|
|
87
83
|
return Promise.resolve();
|
|
@@ -93,7 +89,7 @@ const parseMovi = async ({ state, }) => {
|
|
|
93
89
|
checkpoint.returnToCheckpoint();
|
|
94
90
|
return Promise.resolve();
|
|
95
91
|
}
|
|
96
|
-
await
|
|
92
|
+
await handleChunk({ state, ckId, ckSize });
|
|
97
93
|
const videoSection = state.videoSection.getVideoSection();
|
|
98
94
|
const maxOffset = videoSection.start + videoSection.size;
|
|
99
95
|
// Discard added zeroes
|
|
@@ -105,4 +101,3 @@ const parseMovi = async ({ state, }) => {
|
|
|
105
101
|
}
|
|
106
102
|
}
|
|
107
103
|
};
|
|
108
|
-
exports.parseMovi = parseMovi;
|
|
@@ -1,28 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const expect_riff_box_1 = require("./expect-riff-box");
|
|
7
|
-
const parse_video_section_1 = require("./parse-video-section");
|
|
8
|
-
const parseRiffBody = async (state) => {
|
|
1
|
+
import { makeSkip } from '../../skip';
|
|
2
|
+
import { maySkipVideoData } from '../../state/may-skip-video-data';
|
|
3
|
+
import { expectRiffBox } from './expect-riff-box';
|
|
4
|
+
import { parseVideoSection } from './parse-video-section';
|
|
5
|
+
export const parseRiffBody = async (state) => {
|
|
9
6
|
if (state.videoSection.isInVideoSectionState(state.iterator) === 'in-section') {
|
|
10
|
-
if (
|
|
7
|
+
if (maySkipVideoData({
|
|
11
8
|
state,
|
|
12
9
|
}) &&
|
|
13
10
|
state.riff.getAvcProfile()) {
|
|
14
11
|
const videoSection = state.videoSection.getVideoSection();
|
|
15
12
|
// only skipping forward in query mode
|
|
16
|
-
return Promise.resolve(
|
|
13
|
+
return Promise.resolve(makeSkip(videoSection.start + videoSection.size));
|
|
17
14
|
}
|
|
18
|
-
await
|
|
15
|
+
await parseVideoSection(state);
|
|
19
16
|
return null;
|
|
20
17
|
}
|
|
21
|
-
const box = await
|
|
18
|
+
const box = await expectRiffBox(state);
|
|
22
19
|
if (box !== null) {
|
|
23
20
|
const structure = state.getRiffStructure();
|
|
24
21
|
structure.boxes.push(box);
|
|
25
22
|
}
|
|
26
23
|
return null;
|
|
27
24
|
};
|
|
28
|
-
exports.parseRiffBody = parseRiffBody;
|
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const parse_list_box_1 = require("./parse-list-box");
|
|
7
|
-
const parse_strh_1 = require("./parse-strh");
|
|
8
|
-
const parseRiffBox = ({ size, id, state, }) => {
|
|
1
|
+
import { parseAvih } from './parse-avih';
|
|
2
|
+
import { parseIsft } from './parse-isft';
|
|
3
|
+
import { parseListBox } from './parse-list-box';
|
|
4
|
+
import { parseStrh } from './parse-strh';
|
|
5
|
+
export const parseRiffBox = ({ size, id, state, }) => {
|
|
9
6
|
const { iterator } = state;
|
|
10
7
|
if (id === 'LIST') {
|
|
11
|
-
return
|
|
8
|
+
return parseListBox({ size, state });
|
|
12
9
|
}
|
|
13
10
|
if (id === 'ISFT') {
|
|
14
|
-
return Promise.resolve(
|
|
11
|
+
return Promise.resolve(parseIsft({ iterator, size }));
|
|
15
12
|
}
|
|
16
13
|
if (id === 'avih') {
|
|
17
|
-
return Promise.resolve(
|
|
14
|
+
return Promise.resolve(parseAvih({ iterator, size }));
|
|
18
15
|
}
|
|
19
16
|
if (id === 'strh') {
|
|
20
|
-
return Promise.resolve(
|
|
17
|
+
return Promise.resolve(parseStrh({ iterator, size }));
|
|
21
18
|
}
|
|
22
19
|
iterator.discard(size);
|
|
23
20
|
const box = {
|
|
@@ -27,4 +24,3 @@ const parseRiffBox = ({ size, id, state, }) => {
|
|
|
27
24
|
};
|
|
28
25
|
return Promise.resolve(box);
|
|
29
26
|
};
|
|
30
|
-
exports.parseRiffBox = parseRiffBox;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseRiffHeader = void 0;
|
|
4
|
-
const parseRiffHeader = (state) => {
|
|
1
|
+
export const parseRiffHeader = (state) => {
|
|
5
2
|
const riff = state.iterator.getByteString(4, false);
|
|
6
3
|
if (riff !== 'RIFF') {
|
|
7
4
|
throw new Error('Not a RIFF file');
|
|
@@ -15,4 +12,3 @@ const parseRiffHeader = (state) => {
|
|
|
15
12
|
structure.boxes.push({ type: 'riff-header', fileSize: size, fileType });
|
|
16
13
|
return null;
|
|
17
14
|
};
|
|
18
|
-
exports.parseRiffHeader = parseRiffHeader;
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const parse_riff_body_1 = require("./parse-riff-body");
|
|
5
|
-
const parse_riff_header_1 = require("./parse-riff-header");
|
|
6
|
-
const parseRiff = (state) => {
|
|
1
|
+
import { parseRiffBody } from './parse-riff-body';
|
|
2
|
+
import { parseRiffHeader } from './parse-riff-header';
|
|
3
|
+
export const parseRiff = (state) => {
|
|
7
4
|
if (state.iterator.counter.getOffset() === 0) {
|
|
8
|
-
return Promise.resolve(
|
|
5
|
+
return Promise.resolve(parseRiffHeader(state));
|
|
9
6
|
}
|
|
10
|
-
return
|
|
7
|
+
return parseRiffBody(state);
|
|
11
8
|
};
|
|
12
|
-
exports.parseRiff = parseRiff;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseStrf = void 0;
|
|
4
1
|
const parseStrfAudio = ({ iterator, size, }) => {
|
|
5
2
|
const box = iterator.startBox(size);
|
|
6
3
|
const formatTag = iterator.getUint16Le();
|
|
@@ -51,7 +48,7 @@ const parseStrfVideo = ({ iterator, size, }) => {
|
|
|
51
48
|
yPelsPerMeter,
|
|
52
49
|
};
|
|
53
50
|
};
|
|
54
|
-
const parseStrf = ({ iterator, size, fccType, }) => {
|
|
51
|
+
export const parseStrf = ({ iterator, size, fccType, }) => {
|
|
55
52
|
if (fccType === 'vids') {
|
|
56
53
|
return parseStrfVideo({ iterator, size });
|
|
57
54
|
}
|
|
@@ -60,4 +57,3 @@ const parseStrf = ({ iterator, size, fccType, }) => {
|
|
|
60
57
|
}
|
|
61
58
|
throw new Error(`Unsupported fccType: ${fccType}`);
|
|
62
59
|
};
|
|
63
|
-
exports.parseStrf = parseStrf;
|