@remotion/media-parser 4.0.277 → 4.0.279
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 +13 -6
- package/dist/add-avc-profile-to-track.js +9 -5
- package/dist/check-if-done.d.ts +2 -0
- package/dist/check-if-done.js +34 -0
- package/dist/combine-uint8-arrays.js +5 -1
- package/dist/containers/aac/parse-aac.js +27 -18
- package/dist/containers/aac/types.js +2 -1
- package/dist/containers/avc/codec-string.js +5 -1
- package/dist/containers/avc/color.js +9 -3
- package/dist/containers/avc/create-sps-pps-data.js +9 -5
- package/dist/containers/avc/interpret-sps.js +13 -7
- package/dist/containers/avc/key.js +5 -1
- package/dist/containers/avc/parse-avc.js +7 -3
- package/dist/containers/avc/sps-and-pps.js +5 -1
- package/dist/containers/flac/get-block-size.d.ts +1 -1
- package/dist/containers/flac/get-block-size.js +5 -1
- package/dist/containers/flac/get-channel-count.d.ts +2 -2
- package/dist/containers/flac/get-channel-count.js +5 -1
- package/dist/containers/flac/get-duration-from-flac.js +5 -1
- package/dist/containers/flac/get-metadata-from-flac.js +5 -1
- package/dist/containers/flac/get-sample-rate.d.ts +1 -1
- package/dist/containers/flac/get-sample-rate.js +5 -1
- package/dist/containers/flac/parse-flac-frame.d.ts +1 -1
- package/dist/containers/flac/parse-flac-frame.js +33 -23
- package/dist/containers/flac/parse-flac.d.ts +1 -1
- package/dist/containers/flac/parse-flac.js +19 -15
- package/dist/containers/flac/parse-header.d.ts +1 -1
- package/dist/containers/flac/parse-header.js +5 -1
- package/dist/containers/flac/parse-metadata.d.ts +1 -1
- package/dist/containers/flac/parse-metadata.js +5 -1
- package/dist/containers/flac/parse-streaminfo.d.ts +1 -1
- package/dist/containers/flac/parse-streaminfo.js +7 -3
- package/dist/containers/flac/parse-unknown-block.d.ts +1 -1
- package/dist/containers/flac/parse-unknown-block.js +5 -1
- package/dist/containers/flac/types.js +2 -1
- package/dist/containers/iso-base-media/base-media-box.js +2 -1
- package/dist/containers/iso-base-media/base-type.js +2 -1
- package/dist/containers/iso-base-media/esds/decoder-specific-config.d.ts +1 -1
- package/dist/containers/iso-base-media/esds/decoder-specific-config.js +5 -1
- package/dist/containers/iso-base-media/esds/esds-descriptors.d.ts +1 -1
- package/dist/containers/iso-base-media/esds/esds-descriptors.js +10 -5
- package/dist/containers/iso-base-media/esds/esds.d.ts +1 -1
- package/dist/containers/iso-base-media/esds/esds.js +7 -3
- package/dist/containers/iso-base-media/ftyp.d.ts +1 -1
- package/dist/containers/iso-base-media/ftyp.js +5 -1
- package/dist/containers/iso-base-media/get-actual-number-of-channels.js +8 -4
- package/dist/containers/iso-base-media/get-children.js +7 -3
- package/dist/containers/iso-base-media/get-keyframes.js +11 -7
- package/dist/containers/iso-base-media/get-moov-atom.js +26 -16
- package/dist/containers/iso-base-media/get-sample-positions-from-track.js +24 -20
- package/dist/containers/iso-base-media/get-seeking-from-mp4.d.ts +5 -0
- package/dist/containers/iso-base-media/get-seeking-from-mp4.js +56 -0
- package/dist/containers/iso-base-media/get-video-codec-from-iso-track.js +7 -3
- package/dist/containers/iso-base-media/make-track.js +34 -30
- package/dist/containers/iso-base-media/mdat/mdat.js +47 -34
- package/dist/containers/iso-base-media/mdhd.d.ts +1 -1
- package/dist/containers/iso-base-media/mdhd.js +5 -1
- package/dist/containers/iso-base-media/meta/hdlr.d.ts +1 -1
- package/dist/containers/iso-base-media/meta/hdlr.js +5 -1
- package/dist/containers/iso-base-media/meta/ilst.d.ts +1 -1
- package/dist/containers/iso-base-media/meta/ilst.js +5 -1
- package/dist/containers/iso-base-media/moov/moov.js +7 -3
- package/dist/containers/iso-base-media/mvhd.d.ts +1 -1
- package/dist/containers/iso-base-media/mvhd.js +11 -7
- package/dist/containers/iso-base-media/parse-boxes.js +9 -5
- package/dist/containers/iso-base-media/parse-icc-profile.js +8 -4
- package/dist/containers/iso-base-media/process-box.js +67 -63
- package/dist/containers/iso-base-media/stsd/av1c.d.ts +1 -1
- package/dist/containers/iso-base-media/stsd/av1c.js +5 -1
- package/dist/containers/iso-base-media/stsd/avcc.d.ts +1 -1
- package/dist/containers/iso-base-media/stsd/avcc.js +5 -1
- package/dist/containers/iso-base-media/stsd/colr.d.ts +1 -1
- package/dist/containers/iso-base-media/stsd/colr.js +7 -3
- package/dist/containers/iso-base-media/stsd/ctts.d.ts +1 -1
- package/dist/containers/iso-base-media/stsd/ctts.js +5 -1
- package/dist/containers/iso-base-media/stsd/hvcc.d.ts +1 -1
- package/dist/containers/iso-base-media/stsd/hvcc.js +7 -3
- package/dist/containers/iso-base-media/stsd/keys.d.ts +1 -1
- package/dist/containers/iso-base-media/stsd/keys.js +5 -1
- package/dist/containers/iso-base-media/stsd/mebx.js +7 -3
- package/dist/containers/iso-base-media/stsd/pasp.d.ts +1 -1
- package/dist/containers/iso-base-media/stsd/pasp.js +5 -1
- package/dist/containers/iso-base-media/stsd/samples.js +13 -8
- package/dist/containers/iso-base-media/stsd/stco.d.ts +1 -1
- package/dist/containers/iso-base-media/stsd/stco.js +5 -1
- package/dist/containers/iso-base-media/stsd/stsc.d.ts +1 -1
- package/dist/containers/iso-base-media/stsd/stsc.js +5 -1
- package/dist/containers/iso-base-media/stsd/stsd.js +7 -3
- package/dist/containers/iso-base-media/stsd/stss.d.ts +1 -1
- package/dist/containers/iso-base-media/stsd/stss.js +5 -1
- package/dist/containers/iso-base-media/stsd/stsz.d.ts +1 -1
- package/dist/containers/iso-base-media/stsd/stsz.js +5 -1
- package/dist/containers/iso-base-media/stsd/stts.d.ts +1 -1
- package/dist/containers/iso-base-media/stsd/stts.js +5 -1
- package/dist/containers/iso-base-media/tfdt.d.ts +1 -1
- package/dist/containers/iso-base-media/tfdt.js +5 -1
- package/dist/containers/iso-base-media/tfhd.d.ts +1 -1
- package/dist/containers/iso-base-media/tfhd.js +5 -1
- package/dist/containers/iso-base-media/tkhd.d.ts +1 -1
- package/dist/containers/iso-base-media/tkhd.js +8 -4
- package/dist/containers/iso-base-media/to-date.js +5 -1
- package/dist/containers/iso-base-media/trak/trak.js +7 -3
- package/dist/containers/iso-base-media/traversal.js +57 -33
- package/dist/containers/iso-base-media/trun.d.ts +1 -1
- package/dist/containers/iso-base-media/trun.js +5 -1
- package/dist/containers/iso-base-media/void-box.js +2 -1
- package/dist/containers/m3u/after-manifest-fetch.js +15 -11
- package/dist/containers/m3u/fetch-m3u8-stream.js +7 -3
- package/dist/containers/m3u/get-chunks.js +5 -1
- package/dist/containers/m3u/get-duration-from-m3u.js +8 -4
- package/dist/containers/m3u/get-playlist.js +12 -6
- package/dist/containers/m3u/get-streams.js +9 -3
- package/dist/containers/m3u/iterate-over-segment-files.js +15 -11
- package/dist/containers/m3u/parse-directive.js +10 -6
- package/dist/containers/m3u/parse-m3u-manifest.d.ts +1 -1
- package/dist/containers/m3u/parse-m3u-manifest.js +7 -3
- package/dist/containers/m3u/parse-m3u-media-directive.js +10 -5
- package/dist/containers/m3u/parse-m3u.js +11 -7
- package/dist/containers/m3u/parse-m3u8-text.js +7 -3
- package/dist/containers/m3u/parse-stream-inf.js +7 -2
- package/dist/containers/m3u/run-over-m3u.js +13 -9
- package/dist/containers/m3u/sample-sorter.js +8 -4
- package/dist/containers/m3u/select-stream.js +11 -4
- package/dist/containers/m3u/types.js +2 -1
- package/dist/containers/mp3/get-duration.js +9 -5
- package/dist/containers/mp3/get-frame-length.js +7 -2
- package/dist/containers/mp3/get-metadata-from-mp3.js +5 -1
- package/dist/containers/mp3/id3-v1.d.ts +1 -1
- package/dist/containers/mp3/id3-v1.js +5 -1
- package/dist/containers/mp3/id3.js +5 -1
- package/dist/containers/mp3/parse-mp3.js +11 -7
- package/dist/containers/mp3/parse-mpeg-header.js +28 -19
- package/dist/containers/mp3/samples-per-mpeg-file.js +5 -1
- package/dist/containers/riff/expect-riff-box.js +15 -11
- package/dist/containers/riff/get-duration.js +12 -7
- package/dist/containers/riff/get-tracks-from-avi.js +28 -20
- package/dist/containers/riff/is-movi.d.ts +1 -1
- package/dist/containers/riff/is-movi.js +5 -1
- package/dist/containers/riff/parse-avih.d.ts +1 -1
- package/dist/containers/riff/parse-avih.js +5 -1
- package/dist/containers/riff/parse-isft.d.ts +1 -1
- package/dist/containers/riff/parse-isft.js +5 -1
- package/dist/containers/riff/parse-list-box.js +7 -3
- package/dist/containers/riff/parse-movi.js +45 -31
- package/dist/containers/riff/parse-riff-body.js +13 -9
- package/dist/containers/riff/parse-riff-box.js +13 -9
- package/dist/containers/riff/parse-riff-header.js +5 -1
- package/dist/containers/riff/parse-riff.js +9 -5
- package/dist/containers/riff/parse-strf.d.ts +1 -1
- package/dist/containers/riff/parse-strf.js +5 -1
- package/dist/containers/riff/parse-strh.d.ts +1 -1
- package/dist/containers/riff/parse-strh.js +7 -3
- package/dist/containers/riff/parse-video-section.js +11 -7
- package/dist/containers/riff/riff-box.js +2 -1
- package/dist/containers/riff/timescale.js +4 -1
- package/dist/containers/riff/traversal.js +15 -7
- package/dist/containers/transport-stream/adts-header.js +10 -6
- package/dist/containers/transport-stream/boxes.js +2 -1
- package/dist/containers/transport-stream/discard-rest-of-packet.d.ts +1 -1
- package/dist/containers/transport-stream/discard-rest-of-packet.js +7 -2
- package/dist/containers/transport-stream/find-separator.js +4 -1
- package/dist/containers/transport-stream/get-tracks.js +16 -10
- package/dist/containers/transport-stream/handle-aac-packet.js +21 -12
- package/dist/containers/transport-stream/handle-avc-packet.js +31 -22
- package/dist/containers/transport-stream/next-pes-header-store.js +5 -1
- package/dist/containers/transport-stream/parse-packet.js +17 -13
- package/dist/containers/transport-stream/parse-pat.d.ts +1 -1
- package/dist/containers/transport-stream/parse-pat.js +10 -5
- package/dist/containers/transport-stream/parse-pes.d.ts +1 -1
- package/dist/containers/transport-stream/parse-pes.js +5 -1
- package/dist/containers/transport-stream/parse-pmt.d.ts +1 -1
- package/dist/containers/transport-stream/parse-pmt.js +7 -3
- package/dist/containers/transport-stream/parse-stream-packet.js +17 -13
- package/dist/containers/transport-stream/parse-transport-stream.js +9 -5
- package/dist/containers/transport-stream/process-stream-buffers.js +17 -12
- package/dist/containers/transport-stream/traversal.js +10 -4
- package/dist/containers/wav/get-duration-from-wav.js +8 -3
- package/dist/containers/wav/get-metadata-from-wav.js +5 -1
- package/dist/containers/wav/parse-data.js +9 -5
- package/dist/containers/wav/parse-fmt.js +7 -3
- package/dist/containers/wav/parse-header.js +5 -1
- package/dist/containers/wav/parse-id3.js +5 -1
- package/dist/containers/wav/parse-list.js +5 -1
- package/dist/containers/wav/parse-video-section.js +21 -12
- package/dist/containers/wav/parse-wav.js +19 -15
- package/dist/containers/wav/types.js +2 -1
- package/dist/containers/webm/allowed-partial-segments.js +4 -1
- package/dist/containers/webm/av1-codec-private.js +7 -3
- package/dist/containers/webm/color.js +10 -6
- package/dist/containers/webm/description.js +10 -6
- package/dist/containers/webm/get-ready-tracks.js +18 -13
- package/dist/containers/webm/get-sample-from-block.js +16 -12
- package/dist/containers/webm/make-track.js +48 -43
- package/dist/containers/webm/parse-ebml.js +35 -17
- package/dist/containers/webm/parse-webm-header.js +7 -3
- package/dist/containers/webm/segments/all-segments.js +173 -168
- package/dist/containers/webm/segments/block-simple-block-flags.d.ts +1 -1
- package/dist/containers/webm/segments/block-simple-block-flags.js +8 -4
- package/dist/containers/webm/segments/track-entry.js +5 -1
- package/dist/containers/webm/segments.js +13 -9
- package/dist/containers/webm/traversal.js +67 -37
- package/dist/convert-audio-or-video-sample.js +5 -1
- package/dist/download-and-parse-media.js +14 -10
- package/dist/emit-all-info.d.ts +3 -0
- package/dist/emit-all-info.js +30 -0
- package/dist/emit-audio-sample.d.ts +12 -0
- package/dist/emit-audio-sample.js +14 -0
- package/dist/emit-available-info.d.ts +2 -7
- package/dist/emit-available-info.js +70 -63
- package/dist/emitter.js +5 -1
- package/dist/errors.js +15 -6
- package/dist/esm/index.mjs +1921 -1618
- package/dist/esm/worker-server-entry.mjs +840 -537
- package/dist/esm/worker-web-entry.mjs +840 -537
- package/dist/esm/worker.mjs +4 -5
- package/dist/fetch.js +17 -1
- package/dist/fields.d.ts +61 -0
- package/dist/fields.js +2 -0
- package/dist/file-types/bmp.js +7 -3
- package/dist/file-types/detect-file-type.js +38 -24
- package/dist/file-types/index.js +26 -22
- package/dist/file-types/jpeg.js +9 -4
- package/dist/file-types/pdf.js +7 -3
- package/dist/file-types/png.js +9 -4
- package/dist/file-types/webp.js +7 -3
- package/dist/forward-controller.js +5 -1
- package/dist/get-audio-codec.js +38 -25
- package/dist/get-container.js +10 -5
- package/dist/get-dimensions.js +13 -8
- package/dist/get-duration.js +34 -27
- package/dist/get-fields-from-callbacks.d.ts +2 -1
- package/dist/get-fields-from-callbacks.js +5 -1
- package/dist/get-fps.js +34 -24
- package/dist/get-is-hdr.js +10 -5
- package/dist/get-keyframes.js +11 -6
- package/dist/get-location.js +9 -4
- package/dist/get-number-of-audio-channels.js +7 -2
- package/dist/get-sample-aspect-ratio.js +30 -17
- package/dist/get-sample-positions-from-lpcm.js +9 -5
- package/dist/get-sample-positions.js +5 -1
- package/dist/get-sample-rate.js +7 -2
- package/dist/get-seeking-info.d.ts +4 -0
- package/dist/get-seeking-info.js +22 -0
- package/dist/get-tracks.js +40 -29
- package/dist/get-video-codec.js +34 -26
- package/dist/has-all-info.d.ts +3 -5
- package/dist/has-all-info.js +39 -35
- package/dist/index.d.ts +53 -14
- package/dist/index.js +47 -32
- package/dist/init-video.d.ts +1 -4
- package/dist/init-video.js +29 -24
- package/dist/internal-parse-media.js +40 -199
- package/dist/is-audio-structure.js +5 -1
- package/dist/{buffer-iterator.d.ts → iterator/buffer-iterator.d.ts} +12 -15
- package/dist/{buffer-iterator.js → iterator/buffer-iterator.js} +16 -119
- package/dist/iterator/buffer-manager.d.ts +18 -0
- package/dist/iterator/buffer-manager.js +87 -0
- package/dist/iterator/offset-counter.d.ts +10 -0
- package/dist/iterator/offset-counter.js +31 -0
- package/dist/log.js +12 -8
- package/dist/make-hvc1-codec-strings.d.ts +1 -1
- package/dist/make-hvc1-codec-strings.js +5 -1
- package/dist/make-progress-object.d.ts +6 -0
- package/dist/make-progress-object.js +13 -0
- package/dist/media-parser-controller.d.ts +3 -0
- package/dist/media-parser-controller.js +15 -7
- package/dist/metadata/get-metadata.js +22 -17
- package/dist/metadata/metadata-from-iso.js +17 -12
- package/dist/metadata/metadata-from-matroska.js +7 -3
- package/dist/metadata/metadata-from-riff.js +7 -3
- package/dist/node-writer.js +17 -1
- package/dist/node.js +17 -1
- package/dist/options.d.ts +1 -61
- package/dist/options.js +2 -1
- package/dist/parse-loop.d.ts +8 -0
- package/dist/parse-loop.js +93 -0
- package/dist/parse-media-on-worker-entry.d.ts +2 -1
- package/dist/parse-media-on-worker-entry.js +7 -3
- package/dist/parse-media.js +12 -8
- package/dist/parse-result.js +2 -1
- package/dist/pause-signal.js +5 -1
- package/dist/perform-seek.d.ts +2 -7
- package/dist/perform-seek.js +29 -26
- package/dist/print-timings.d.ts +2 -0
- package/dist/print-timings.js +12 -0
- package/dist/readers/fetch/get-body-and-reader.js +5 -1
- package/dist/readers/fetch/resolve-url.js +5 -1
- package/dist/readers/from-fetch.js +21 -14
- package/dist/readers/from-node.js +23 -17
- package/dist/readers/from-web-file.js +13 -7
- package/dist/readers/reader.js +2 -1
- package/dist/readers/universal.js +16 -13
- package/dist/readers/web.js +12 -9
- package/dist/register-track.js +18 -9
- package/dist/remotion-license-acknowledge.js +8 -4
- package/dist/run-parse-iteration.d.ts +1 -4
- package/dist/run-parse-iteration.js +25 -24
- package/dist/samples-from-moof.js +10 -6
- package/dist/seek-backwards.d.ts +2 -0
- package/dist/seek-backwards.js +26 -0
- package/dist/seek-forwards.d.ts +2 -0
- package/dist/seek-forwards.js +28 -0
- package/dist/seek-signal.d.ts +22 -0
- package/dist/seek-signal.js +26 -0
- package/dist/seeking-info.d.ts +8 -0
- package/dist/seeking-info.js +2 -0
- package/dist/skip.js +5 -1
- package/dist/state/aac-state.js +5 -1
- package/dist/state/can-skip-tracks.d.ts +2 -2
- package/dist/state/can-skip-tracks.js +12 -4
- package/dist/state/emitted-fields.d.ts +1 -1
- package/dist/state/emitted-fields.js +5 -1
- package/dist/state/flac-state.js +5 -1
- package/dist/state/has-tracks-section.d.ts +2 -1
- package/dist/state/has-tracks-section.js +7 -3
- package/dist/state/images.js +5 -1
- package/dist/state/iso-base-media/cached-sample-positions.js +13 -8
- package/dist/state/iso-base-media/iso-state.js +9 -5
- package/dist/state/iso-base-media/moov-box.js +5 -1
- package/dist/state/keyframes.js +5 -1
- package/dist/state/m3u-state.js +9 -5
- package/dist/state/may-skip-video-data.js +7 -3
- package/dist/state/mp3.js +5 -1
- package/dist/state/need-samples-for-fields.d.ts +1 -1
- package/dist/state/need-samples-for-fields.js +5 -1
- package/dist/state/parser-state.d.ts +38 -8
- package/dist/state/parser-state.js +59 -35
- package/dist/state/riff.js +5 -1
- package/dist/state/sample-callbacks.d.ts +8 -3
- package/dist/state/sample-callbacks.js +27 -10
- package/dist/state/slow-duration-fps.js +5 -1
- package/dist/state/structure.js +5 -1
- package/dist/state/timings.d.ts +8 -0
- package/dist/state/timings.js +13 -0
- package/dist/state/transport-stream.js +7 -3
- package/dist/state/video-section.d.ts +1 -1
- package/dist/state/video-section.js +5 -1
- package/dist/state/webm.d.ts +1 -1
- package/dist/state/webm.js +9 -5
- package/dist/throttled-progress.d.ts +2 -3
- package/dist/throttled-progress.js +5 -1
- package/dist/truthy.js +4 -1
- package/dist/universal.js +5 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +4 -1
- package/dist/web.js +5 -1
- package/dist/webcodec-sample-types.js +2 -1
- package/dist/work-on-seek-request.d.ts +2 -0
- package/dist/work-on-seek-request.js +43 -0
- package/dist/worker/forward-controller.js +7 -3
- package/dist/worker/serialize-error.js +19 -14
- package/dist/worker/worker-types.d.ts +2 -1
- package/dist/worker/worker-types.js +2 -1
- package/dist/worker-server-entry.js +5 -3
- package/dist/worker-server.js +16 -12
- package/dist/worker-web-entry.js +5 -3
- package/dist/worker.d.ts +3 -2
- package/dist/worker.js +11 -2
- package/dist/writers/node.js +23 -16
- package/dist/writers/writer.js +2 -1
- package/package.json +10 -10
- package/dist/parse-media-on-server-worker.d.ts +0 -2
- package/dist/parse-media-on-server-worker.js +0 -4
- package/dist/parse-media-on-web-worker.d.ts +0 -2
- package/dist/parse-media-on-web-worker.js +0 -4
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseM3uDirective = void 0;
|
|
4
|
+
const parse_m3u_media_directive_1 = require("./parse-m3u-media-directive");
|
|
5
|
+
const parse_stream_inf_1 = require("./parse-stream-inf");
|
|
6
|
+
const parseM3uDirective = (str) => {
|
|
4
7
|
const firstColon = str.indexOf(':');
|
|
5
8
|
const directive = (firstColon === -1 ? str : str.slice(0, firstColon)).trim();
|
|
6
9
|
const value = firstColon === -1 ? null : str.slice(firstColon + 1);
|
|
@@ -22,7 +25,7 @@ export const parseM3uDirective = (str) => {
|
|
|
22
25
|
if (!value) {
|
|
23
26
|
throw new Error('EXT-X-MEDIA directive must have a value');
|
|
24
27
|
}
|
|
25
|
-
const parsed = parseM3uMediaDirective(value);
|
|
28
|
+
const parsed = (0, parse_m3u_media_directive_1.parseM3uMediaDirective)(value);
|
|
26
29
|
return parsed;
|
|
27
30
|
}
|
|
28
31
|
if (directive === '#EXT-X-TARGETDURATION') {
|
|
@@ -79,7 +82,7 @@ export const parseM3uDirective = (str) => {
|
|
|
79
82
|
if (!value) {
|
|
80
83
|
throw new Error('EXT-X-STREAM-INF directive must have a value');
|
|
81
84
|
}
|
|
82
|
-
const res = parseStreamInf(value);
|
|
85
|
+
const res = (0, parse_stream_inf_1.parseStreamInf)(value);
|
|
83
86
|
return res;
|
|
84
87
|
}
|
|
85
88
|
if (directive === '#EXT-X-I-FRAME-STREAM-INF') {
|
|
@@ -100,7 +103,7 @@ export const parseM3uDirective = (str) => {
|
|
|
100
103
|
if (!value) {
|
|
101
104
|
throw new Error('#EXT-X-MAP directive must have a value');
|
|
102
105
|
}
|
|
103
|
-
const p = parseM3uKeyValue(value);
|
|
106
|
+
const p = (0, parse_m3u_media_directive_1.parseM3uKeyValue)(value);
|
|
104
107
|
if (!p.URI) {
|
|
105
108
|
throw new Error('EXT-X-MAP directive must have a URI');
|
|
106
109
|
}
|
|
@@ -111,3 +114,4 @@ export const parseM3uDirective = (str) => {
|
|
|
111
114
|
}
|
|
112
115
|
throw new Error(`Unknown directive ${directive}. Value: ${value}`);
|
|
113
116
|
};
|
|
117
|
+
exports.parseM3uDirective = parseM3uDirective;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BufferIterator } from '../../buffer-iterator';
|
|
1
|
+
import type { BufferIterator } from '../../iterator/buffer-iterator';
|
|
2
2
|
import type { ParseResult } from '../../parse-result';
|
|
3
3
|
import type { M3uStructure } from './types';
|
|
4
4
|
export declare const parseM3uManifest: ({ iterator, structure, contentLength, }: {
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseM3uManifest = void 0;
|
|
4
|
+
const parse_m3u8_text_1 = require("./parse-m3u8-text");
|
|
5
|
+
const parseM3uManifest = ({ iterator, structure, contentLength, }) => {
|
|
3
6
|
const start = iterator.startCheckpoint();
|
|
4
7
|
const line = iterator.readUntilLineEnd();
|
|
5
8
|
if (iterator.counter.getOffset() > contentLength) {
|
|
@@ -9,6 +12,7 @@ export const parseM3uManifest = ({ iterator, structure, contentLength, }) => {
|
|
|
9
12
|
start.returnToCheckpoint();
|
|
10
13
|
return Promise.resolve(null);
|
|
11
14
|
}
|
|
12
|
-
parseM3u8Text(line.trim(), structure.boxes);
|
|
15
|
+
(0, parse_m3u8_text_1.parseM3u8Text)(line.trim(), structure.boxes);
|
|
13
16
|
return Promise.resolve(null);
|
|
14
17
|
};
|
|
18
|
+
exports.parseM3uManifest = parseM3uManifest;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseM3uMediaDirective = exports.parseM3uKeyValue = void 0;
|
|
4
|
+
const parse_stream_inf_1 = require("./parse-stream-inf");
|
|
5
|
+
const parseM3uKeyValue = (str) => {
|
|
6
|
+
const quotes = (0, parse_stream_inf_1.splitRespectingQuotes)(str);
|
|
4
7
|
const map = {};
|
|
5
8
|
for (const quote of quotes) {
|
|
6
9
|
const firstColon = quote.indexOf('=');
|
|
@@ -16,8 +19,9 @@ export const parseM3uKeyValue = (str) => {
|
|
|
16
19
|
}
|
|
17
20
|
return map;
|
|
18
21
|
};
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
exports.parseM3uKeyValue = parseM3uKeyValue;
|
|
23
|
+
const parseM3uMediaDirective = (str) => {
|
|
24
|
+
const map = (0, exports.parseM3uKeyValue)(str);
|
|
21
25
|
return {
|
|
22
26
|
type: 'm3u-media-info',
|
|
23
27
|
autoselect: map.AUTOSELECT === 'YES',
|
|
@@ -29,3 +33,4 @@ export const parseM3uMediaDirective = (str) => {
|
|
|
29
33
|
uri: map.URI,
|
|
30
34
|
};
|
|
31
35
|
};
|
|
36
|
+
exports.parseM3uMediaDirective = parseM3uMediaDirective;
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseM3u = void 0;
|
|
4
|
+
const after_manifest_fetch_1 = require("./after-manifest-fetch");
|
|
5
|
+
const parse_m3u_manifest_1 = require("./parse-m3u-manifest");
|
|
6
|
+
const run_over_m3u_1 = require("./run-over-m3u");
|
|
7
|
+
const parseM3u = async ({ state }) => {
|
|
5
8
|
const structure = state.getM3uStructure();
|
|
6
9
|
if (state.m3u.isReadyToIterateOverM3u()) {
|
|
7
10
|
const selectedPlaylists = state.m3u.getSelectedPlaylists();
|
|
8
11
|
const whichPlaylistToRunOver = state.m3u.sampleSorter.getNextStreamToRun(selectedPlaylists);
|
|
9
|
-
await runOverM3u({
|
|
12
|
+
await (0, run_over_m3u_1.runOverM3u)({
|
|
10
13
|
state,
|
|
11
14
|
structure,
|
|
12
15
|
playlistUrl: whichPlaylistToRunOver,
|
|
@@ -18,7 +21,7 @@ export const parseM3u = async ({ state }) => {
|
|
|
18
21
|
if (typeof state.src !== 'string' && !(state.src instanceof URL)) {
|
|
19
22
|
throw new Error('Expected src to be a string');
|
|
20
23
|
}
|
|
21
|
-
await afterManifestFetch({
|
|
24
|
+
await (0, after_manifest_fetch_1.afterManifestFetch)({
|
|
22
25
|
structure,
|
|
23
26
|
m3uState: state.m3u,
|
|
24
27
|
src: state.src.toString(),
|
|
@@ -29,7 +32,7 @@ export const parseM3u = async ({ state }) => {
|
|
|
29
32
|
});
|
|
30
33
|
return null;
|
|
31
34
|
}
|
|
32
|
-
const box = await parseM3uManifest({
|
|
35
|
+
const box = await (0, parse_m3u_manifest_1.parseM3uManifest)({
|
|
33
36
|
iterator: state.iterator,
|
|
34
37
|
structure,
|
|
35
38
|
contentLength: state.contentLength,
|
|
@@ -40,3 +43,4 @@ export const parseM3u = async ({ state }) => {
|
|
|
40
43
|
}
|
|
41
44
|
return box;
|
|
42
45
|
};
|
|
46
|
+
exports.parseM3u = parseM3u;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseM3u8Text = void 0;
|
|
4
|
+
const parse_directive_1 = require("./parse-directive");
|
|
5
|
+
const parseM3u8Text = (line, boxes) => {
|
|
3
6
|
if (line === '#EXTM3U') {
|
|
4
7
|
boxes.push({
|
|
5
8
|
type: 'm3u-header',
|
|
@@ -7,7 +10,7 @@ export const parseM3u8Text = (line, boxes) => {
|
|
|
7
10
|
return;
|
|
8
11
|
}
|
|
9
12
|
if (line.startsWith('#')) {
|
|
10
|
-
boxes.push(parseM3uDirective(line));
|
|
13
|
+
boxes.push((0, parse_directive_1.parseM3uDirective)(line));
|
|
11
14
|
return;
|
|
12
15
|
}
|
|
13
16
|
if (line.trim()) {
|
|
@@ -17,3 +20,4 @@ export const parseM3u8Text = (line, boxes) => {
|
|
|
17
20
|
});
|
|
18
21
|
}
|
|
19
22
|
};
|
|
23
|
+
exports.parseM3u8Text = parseM3u8Text;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseStreamInf = void 0;
|
|
4
|
+
exports.splitRespectingQuotes = splitRespectingQuotes;
|
|
5
|
+
function splitRespectingQuotes(input) {
|
|
2
6
|
const result = [];
|
|
3
7
|
let currentPart = '';
|
|
4
8
|
let insideQuote = false;
|
|
@@ -24,7 +28,7 @@ export function splitRespectingQuotes(input) {
|
|
|
24
28
|
}
|
|
25
29
|
return result;
|
|
26
30
|
}
|
|
27
|
-
|
|
31
|
+
const parseStreamInf = (str) => {
|
|
28
32
|
const quotes = splitRespectingQuotes(str);
|
|
29
33
|
const map = {};
|
|
30
34
|
for (const quote of quotes) {
|
|
@@ -55,3 +59,4 @@ export const parseStreamInf = (str) => {
|
|
|
55
59
|
audio: map.AUDIO || null,
|
|
56
60
|
};
|
|
57
61
|
};
|
|
62
|
+
exports.parseStreamInf = parseStreamInf;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runOverM3u = void 0;
|
|
4
|
+
const log_1 = require("../../log");
|
|
5
|
+
const register_track_1 = require("../../register-track");
|
|
6
|
+
const iterate_over_segment_files_1 = require("./iterate-over-segment-files");
|
|
7
|
+
const runOverM3u = async ({ state, structure, playlistUrl, logLevel, }) => {
|
|
5
8
|
const tracksDone = state.m3u.getTrackDone(playlistUrl);
|
|
6
9
|
const hasAudioStreamToConsider = state.m3u.sampleSorter.hasAudioStreamToConsider(playlistUrl);
|
|
7
10
|
const hasVideoStreamToConsider = state.m3u.sampleSorter.hasVideoStreamToConsider(playlistUrl);
|
|
@@ -14,7 +17,7 @@ export const runOverM3u = async ({ state, structure, playlistUrl, logLevel, }) =
|
|
|
14
17
|
}
|
|
15
18
|
const existingRun = state.m3u.getM3uStreamRun(playlistUrl);
|
|
16
19
|
if (existingRun) {
|
|
17
|
-
Log.trace(logLevel, 'Existing M3U parsing process found for', playlistUrl);
|
|
20
|
+
log_1.Log.trace(logLevel, 'Existing M3U parsing process found for', playlistUrl);
|
|
18
21
|
const run = await existingRun.continue();
|
|
19
22
|
state.m3u.setM3uStreamRun(playlistUrl, run);
|
|
20
23
|
if (!run) {
|
|
@@ -22,9 +25,9 @@ export const runOverM3u = async ({ state, structure, playlistUrl, logLevel, }) =
|
|
|
22
25
|
}
|
|
23
26
|
return;
|
|
24
27
|
}
|
|
25
|
-
Log.trace(logLevel, 'Starting new M3U parsing process for', playlistUrl);
|
|
28
|
+
log_1.Log.trace(logLevel, 'Starting new M3U parsing process for', playlistUrl);
|
|
26
29
|
return new Promise((resolve, reject) => {
|
|
27
|
-
const run = iteratorOverSegmentFiles({
|
|
30
|
+
const run = (0, iterate_over_segment_files_1.iteratorOverSegmentFiles)({
|
|
28
31
|
playlistUrl,
|
|
29
32
|
structure,
|
|
30
33
|
onInitialProgress: (newRun) => {
|
|
@@ -46,7 +49,7 @@ export const runOverM3u = async ({ state, structure, playlistUrl, logLevel, }) =
|
|
|
46
49
|
while (existingTracks.find((t) => t.trackId === trackId)) {
|
|
47
50
|
trackId++;
|
|
48
51
|
}
|
|
49
|
-
const onAudioSample = await registerAudioTrack({
|
|
52
|
+
const onAudioSample = await (0, register_track_1.registerAudioTrack)({
|
|
50
53
|
container: 'm3u8',
|
|
51
54
|
state,
|
|
52
55
|
track: {
|
|
@@ -71,7 +74,7 @@ export const runOverM3u = async ({ state, structure, playlistUrl, logLevel, }) =
|
|
|
71
74
|
while (existingTracks.find((t) => t.trackId === trackId)) {
|
|
72
75
|
trackId++;
|
|
73
76
|
}
|
|
74
|
-
const onVideoSample = await registerVideoTrack({
|
|
77
|
+
const onVideoSample = await (0, register_track_1.registerVideoTrack)({
|
|
75
78
|
container: 'm3u8',
|
|
76
79
|
state,
|
|
77
80
|
track: {
|
|
@@ -97,3 +100,4 @@ export const runOverM3u = async ({ state, structure, playlistUrl, logLevel, }) =
|
|
|
97
100
|
});
|
|
98
101
|
});
|
|
99
102
|
};
|
|
103
|
+
exports.runOverM3u = runOverM3u;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sampleSorter = void 0;
|
|
4
|
+
const log_1 = require("../../log");
|
|
5
|
+
const sampleSorter = ({ logLevel, getAllChunksProcessedForPlaylist, }) => {
|
|
3
6
|
const streamsWithTracks = [];
|
|
4
7
|
const audioCallbacks = {};
|
|
5
8
|
const videoCallbacks = {};
|
|
@@ -44,7 +47,7 @@ export const sampleSorter = ({ logLevel, getAllChunksProcessedForPlaylist, }) =>
|
|
|
44
47
|
}
|
|
45
48
|
// If a stream does not have a track yet, work on that
|
|
46
49
|
if (!streamsWithTracks.includes(stream)) {
|
|
47
|
-
Log.trace(logLevel, `Did not yet detect track of ${stream}, working on that`);
|
|
50
|
+
log_1.Log.trace(logLevel, `Did not yet detect track of ${stream}, working on that`);
|
|
48
51
|
return stream;
|
|
49
52
|
}
|
|
50
53
|
}
|
|
@@ -62,7 +65,7 @@ export const sampleSorter = ({ logLevel, getAllChunksProcessedForPlaylist, }) =>
|
|
|
62
65
|
continue;
|
|
63
66
|
}
|
|
64
67
|
if (((_c = latestSample[stream]) !== null && _c !== void 0 ? _c : 0) === smallestDts) {
|
|
65
|
-
Log.trace(logLevel, `Working on ${stream} because it has the smallest DTS`);
|
|
68
|
+
log_1.Log.trace(logLevel, `Working on ${stream} because it has the smallest DTS`);
|
|
66
69
|
return stream;
|
|
67
70
|
}
|
|
68
71
|
}
|
|
@@ -70,3 +73,4 @@ export const sampleSorter = ({ logLevel, getAllChunksProcessedForPlaylist, }) =>
|
|
|
70
73
|
},
|
|
71
74
|
};
|
|
72
75
|
};
|
|
76
|
+
exports.sampleSorter = sampleSorter;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defaultSelectM3uStreamFn = exports.selectStream = exports.defaultSelectM3uAssociatedPlaylists = exports.selectAssociatedPlaylists = void 0;
|
|
4
|
+
const selectAssociatedPlaylists = async ({ playlists, fn, }) => {
|
|
2
5
|
if (playlists.length < 1) {
|
|
3
6
|
return Promise.resolve([]);
|
|
4
7
|
}
|
|
@@ -13,13 +16,15 @@ export const selectAssociatedPlaylists = async ({ playlists, fn, }) => {
|
|
|
13
16
|
}
|
|
14
17
|
return streams;
|
|
15
18
|
};
|
|
16
|
-
|
|
19
|
+
exports.selectAssociatedPlaylists = selectAssociatedPlaylists;
|
|
20
|
+
const defaultSelectM3uAssociatedPlaylists = ({ associatedPlaylists }) => {
|
|
17
21
|
if (associatedPlaylists.length === 1) {
|
|
18
22
|
return associatedPlaylists;
|
|
19
23
|
}
|
|
20
24
|
return associatedPlaylists.filter((playlist) => playlist.default);
|
|
21
25
|
};
|
|
22
|
-
|
|
26
|
+
exports.defaultSelectM3uAssociatedPlaylists = defaultSelectM3uAssociatedPlaylists;
|
|
27
|
+
const selectStream = async ({ streams, fn, }) => {
|
|
23
28
|
if (streams.length < 1) {
|
|
24
29
|
throw new Error('No streams found');
|
|
25
30
|
}
|
|
@@ -30,6 +35,8 @@ export const selectStream = async ({ streams, fn, }) => {
|
|
|
30
35
|
}
|
|
31
36
|
return Promise.resolve(selectedStream);
|
|
32
37
|
};
|
|
33
|
-
|
|
38
|
+
exports.selectStream = selectStream;
|
|
39
|
+
const defaultSelectM3uStreamFn = ({ streams }) => {
|
|
34
40
|
return Promise.resolve(streams[0].id);
|
|
35
41
|
};
|
|
42
|
+
exports.defaultSelectM3uStreamFn = defaultSelectM3uStreamFn;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDurationFromMp3 = void 0;
|
|
4
|
+
const get_frame_length_1 = require("./get-frame-length");
|
|
5
|
+
const samples_per_mpeg_file_1 = require("./samples-per-mpeg-file");
|
|
6
|
+
const getDurationFromMp3 = (state) => {
|
|
4
7
|
const mp3Info = state.mp3Info.getMp3Info();
|
|
5
8
|
const mp3CbrInfo = state.mp3Info.getCbrMp3Info();
|
|
6
9
|
if (!mp3Info || !mp3CbrInfo) {
|
|
7
10
|
return null;
|
|
8
11
|
}
|
|
9
|
-
const samplesPerFrame = getSamplesPerMpegFrame({
|
|
12
|
+
const samplesPerFrame = (0, samples_per_mpeg_file_1.getSamplesPerMpegFrame)({
|
|
10
13
|
layer: mp3Info.layer,
|
|
11
14
|
mpegVersion: mp3Info.mpegVersion,
|
|
12
15
|
});
|
|
13
|
-
const frameLengthInBytes = getMpegFrameLength({
|
|
16
|
+
const frameLengthInBytes = (0, get_frame_length_1.getMpegFrameLength)({
|
|
14
17
|
bitrateKbit: mp3CbrInfo.bitrateKbit,
|
|
15
18
|
padding: false,
|
|
16
19
|
samplesPerFrame,
|
|
@@ -22,3 +25,4 @@ export const getDurationFromMp3 = (state) => {
|
|
|
22
25
|
const durationInSeconds = samples / mp3Info.sampleRate;
|
|
23
26
|
return durationInSeconds;
|
|
24
27
|
};
|
|
28
|
+
exports.getDurationFromMp3 = getDurationFromMp3;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMpegFrameLength = exports.getAverageMpegFrameLength = void 0;
|
|
1
4
|
const getUnroundedMpegFrameLength = ({ samplesPerFrame, bitrateKbit, samplingFrequency, padding, layer, }) => {
|
|
2
5
|
if (layer === 1) {
|
|
3
6
|
throw new Error('MPEG Layer I is not supported');
|
|
@@ -5,7 +8,7 @@ const getUnroundedMpegFrameLength = ({ samplesPerFrame, bitrateKbit, samplingFre
|
|
|
5
8
|
return ((((samplesPerFrame / 8) * bitrateKbit) / samplingFrequency) * 1000 +
|
|
6
9
|
(padding ? (layer === 1 ? 4 : 1) : 0));
|
|
7
10
|
};
|
|
8
|
-
|
|
11
|
+
const getAverageMpegFrameLength = ({ samplesPerFrame, bitrateKbit, samplingFrequency, layer, }) => {
|
|
9
12
|
const withoutPadding = getUnroundedMpegFrameLength({
|
|
10
13
|
bitrateKbit,
|
|
11
14
|
layer,
|
|
@@ -17,7 +20,8 @@ export const getAverageMpegFrameLength = ({ samplesPerFrame, bitrateKbit, sampli
|
|
|
17
20
|
const rest = withoutPadding % 1;
|
|
18
21
|
return rest * (rounded + 1) + (1 - rest) * rounded;
|
|
19
22
|
};
|
|
20
|
-
|
|
23
|
+
exports.getAverageMpegFrameLength = getAverageMpegFrameLength;
|
|
24
|
+
const getMpegFrameLength = ({ samplesPerFrame, bitrateKbit, samplingFrequency, padding, layer, }) => {
|
|
21
25
|
return Math.floor(getUnroundedMpegFrameLength({
|
|
22
26
|
bitrateKbit,
|
|
23
27
|
layer,
|
|
@@ -26,3 +30,4 @@ export const getMpegFrameLength = ({ samplesPerFrame, bitrateKbit, samplingFrequ
|
|
|
26
30
|
samplingFrequency,
|
|
27
31
|
}));
|
|
28
32
|
};
|
|
33
|
+
exports.getMpegFrameLength = getMpegFrameLength;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMetadataFromMp3 = void 0;
|
|
4
|
+
const getMetadataFromMp3 = (mp3Structure) => {
|
|
2
5
|
const findHeader = mp3Structure.boxes.find((b) => b.type === 'id3-header');
|
|
3
6
|
return findHeader ? findHeader.metatags : null;
|
|
4
7
|
};
|
|
8
|
+
exports.getMetadataFromMp3 = getMetadataFromMp3;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { BufferIterator } from '../../buffer-iterator';
|
|
1
|
+
import type { BufferIterator } from '../../iterator/buffer-iterator';
|
|
2
2
|
export declare const parseID3V1: (iterator: BufferIterator) => void;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseID3V1 = void 0;
|
|
4
|
+
const parseID3V1 = (iterator) => {
|
|
2
5
|
if (iterator.bytesRemaining() < 128) {
|
|
3
6
|
return;
|
|
4
7
|
}
|
|
@@ -6,3 +9,4 @@ export const parseID3V1 = (iterator) => {
|
|
|
6
9
|
// Better than have duplicated data.
|
|
7
10
|
iterator.discard(128);
|
|
8
11
|
};
|
|
12
|
+
exports.parseID3V1 = parseID3V1;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseId3 = void 0;
|
|
1
4
|
function combine28Bits(a, b, c, d) {
|
|
2
5
|
// Mask each number to ignore first bit (& 0x7F)
|
|
3
6
|
const val1 = a & 0x7f; // 7 bits from first byte
|
|
@@ -7,7 +10,7 @@ function combine28Bits(a, b, c, d) {
|
|
|
7
10
|
// Combine all values using bitwise operations
|
|
8
11
|
return (val1 << 21) | (val2 << 14) | (val3 << 7) | val4;
|
|
9
12
|
}
|
|
10
|
-
|
|
13
|
+
const parseId3 = ({ state }) => {
|
|
11
14
|
const { iterator } = state;
|
|
12
15
|
if (iterator.bytesRemaining() < 9) {
|
|
13
16
|
return;
|
|
@@ -77,3 +80,4 @@ export const parseId3 = ({ state }) => {
|
|
|
77
80
|
metatags: entries,
|
|
78
81
|
});
|
|
79
82
|
};
|
|
83
|
+
exports.parseId3 = parseId3;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseMp3 = void 0;
|
|
4
|
+
const id3_1 = require("./id3");
|
|
5
|
+
const id3_v1_1 = require("./id3-v1");
|
|
6
|
+
const parse_mpeg_header_1 = require("./parse-mpeg-header");
|
|
7
|
+
const parseMp3 = async (state) => {
|
|
5
8
|
const { iterator } = state;
|
|
6
9
|
if (iterator.bytesRemaining() < 3) {
|
|
7
10
|
return null;
|
|
@@ -11,19 +14,20 @@ export const parseMp3 = async (state) => {
|
|
|
11
14
|
returnToCheckpoint();
|
|
12
15
|
// ID3 v1
|
|
13
16
|
if (bytes[0] === 0x54 && bytes[1] === 0x41 && bytes[2] === 0x47) {
|
|
14
|
-
parseID3V1(iterator);
|
|
17
|
+
(0, id3_v1_1.parseID3V1)(iterator);
|
|
15
18
|
return null;
|
|
16
19
|
}
|
|
17
20
|
// ID3 v2 or v3
|
|
18
21
|
if (bytes[0] === 0x49 && bytes[1] === 0x44 && bytes[2] === 0x33) {
|
|
19
|
-
parseId3({ state });
|
|
22
|
+
(0, id3_1.parseId3)({ state });
|
|
20
23
|
return null;
|
|
21
24
|
}
|
|
22
25
|
if (bytes[0] === 0xff) {
|
|
23
|
-
await parseMpegHeader({
|
|
26
|
+
await (0, parse_mpeg_header_1.parseMpegHeader)({
|
|
24
27
|
state,
|
|
25
28
|
});
|
|
26
29
|
return null;
|
|
27
30
|
}
|
|
28
31
|
throw new Error('Unknown MP3 header ' + JSON.stringify(bytes));
|
|
29
32
|
};
|
|
33
|
+
exports.parseMp3 = parseMp3;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// spec: http://www.mp3-tech.org/programmer/frame_header.html
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.parseMpegHeader = void 0;
|
|
5
|
+
const emit_audio_sample_1 = require("../../emit-audio-sample");
|
|
6
|
+
const log_1 = require("../../log");
|
|
7
|
+
const register_track_1 = require("../../register-track");
|
|
8
|
+
const get_frame_length_1 = require("./get-frame-length");
|
|
9
|
+
const samples_per_mpeg_file_1 = require("./samples-per-mpeg-file");
|
|
6
10
|
function getSamplingFrequency({ bits, mpegVersion, }) {
|
|
7
11
|
const samplingTable = {
|
|
8
12
|
0b00: { MPEG1: 44100, MPEG2: 22050 },
|
|
@@ -141,7 +145,7 @@ function getBitrateKB({ bits, mpegVersion, level, }) {
|
|
|
141
145
|
// Return the corresponding bitrate
|
|
142
146
|
return bitrateTable[bits][key];
|
|
143
147
|
}
|
|
144
|
-
|
|
148
|
+
const parseMpegHeader = async ({ state, }) => {
|
|
145
149
|
const { iterator } = state;
|
|
146
150
|
const initialOffset = iterator.counter.getOffset();
|
|
147
151
|
if (iterator.bytesRemaining() < 32) {
|
|
@@ -205,8 +209,8 @@ export const parseMpegHeader = async ({ state, }) => {
|
|
|
205
209
|
iterator.getBits(1); // original
|
|
206
210
|
iterator.getBits(2); // emphasis
|
|
207
211
|
const numberOfChannels = channelMode === 0b11 ? 1 : 2;
|
|
208
|
-
const samplesPerFrame = getSamplesPerMpegFrame({ mpegVersion, layer });
|
|
209
|
-
const frameLength = getMpegFrameLength({
|
|
212
|
+
const samplesPerFrame = (0, samples_per_mpeg_file_1.getSamplesPerMpegFrame)({ mpegVersion, layer });
|
|
213
|
+
const frameLength = (0, get_frame_length_1.getMpegFrameLength)({
|
|
210
214
|
bitrateKbit,
|
|
211
215
|
padding,
|
|
212
216
|
samplesPerFrame,
|
|
@@ -229,7 +233,7 @@ export const parseMpegHeader = async ({ state, }) => {
|
|
|
229
233
|
const isVbr = asText.includes('Xing') || asText.includes('VBRI');
|
|
230
234
|
isInfoTag = isVbr || asText.includes('Info');
|
|
231
235
|
if (isVbr) {
|
|
232
|
-
Log.verbose(state.logLevel, 'MP3 has variable bit rate. Requiring whole file to be read');
|
|
236
|
+
log_1.Log.verbose(state.logLevel, 'MP3 has variable bit rate. Requiring whole file to be read');
|
|
233
237
|
}
|
|
234
238
|
else {
|
|
235
239
|
state.mp3Info.setCbrMp3Info({
|
|
@@ -238,7 +242,7 @@ export const parseMpegHeader = async ({ state, }) => {
|
|
|
238
242
|
}
|
|
239
243
|
if (!isInfoTag) {
|
|
240
244
|
state.mp3Info.setMp3Info(info);
|
|
241
|
-
await registerAudioTrack({
|
|
245
|
+
await (0, register_track_1.registerAudioTrack)({
|
|
242
246
|
container: 'mp3',
|
|
243
247
|
state,
|
|
244
248
|
track: {
|
|
@@ -257,7 +261,7 @@ export const parseMpegHeader = async ({ state, }) => {
|
|
|
257
261
|
state.callbacks.tracks.setIsDone(state.logLevel);
|
|
258
262
|
}
|
|
259
263
|
}
|
|
260
|
-
const avgLength = getAverageMpegFrameLength({
|
|
264
|
+
const avgLength = (0, get_frame_length_1.getAverageMpegFrameLength)({
|
|
261
265
|
bitrateKbit,
|
|
262
266
|
layer,
|
|
263
267
|
samplesPerFrame,
|
|
@@ -273,16 +277,21 @@ export const parseMpegHeader = async ({ state, }) => {
|
|
|
273
277
|
const timeInSeconds = (nthFrame * samplesPerFrame) / sampleRate;
|
|
274
278
|
const timestamp = Math.round(timeInSeconds * 1000000);
|
|
275
279
|
const duration = Math.round(durationInSeconds * 1000000);
|
|
276
|
-
await
|
|
277
|
-
data,
|
|
278
|
-
cts: timestamp,
|
|
279
|
-
dts: timestamp,
|
|
280
|
-
duration,
|
|
281
|
-
offset: initialOffset,
|
|
282
|
-
timescale: 1000000,
|
|
283
|
-
timestamp,
|
|
280
|
+
await (0, emit_audio_sample_1.emitAudioSample)({
|
|
284
281
|
trackId: 0,
|
|
285
|
-
|
|
282
|
+
audioSample: {
|
|
283
|
+
data,
|
|
284
|
+
cts: timestamp,
|
|
285
|
+
dts: timestamp,
|
|
286
|
+
duration,
|
|
287
|
+
offset: initialOffset,
|
|
288
|
+
timescale: 1000000,
|
|
289
|
+
timestamp,
|
|
290
|
+
trackId: 0,
|
|
291
|
+
type: 'key',
|
|
292
|
+
},
|
|
293
|
+
state,
|
|
286
294
|
});
|
|
287
295
|
}
|
|
288
296
|
};
|
|
297
|
+
exports.parseMpegHeader = parseMpegHeader;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSamplesPerMpegFrame = void 0;
|
|
4
|
+
const getSamplesPerMpegFrame = ({ mpegVersion, layer, }) => {
|
|
2
5
|
if (mpegVersion === 1) {
|
|
3
6
|
if (layer === 1) {
|
|
4
7
|
return 384;
|
|
@@ -20,3 +23,4 @@ export const getSamplesPerMpegFrame = ({ mpegVersion, layer, }) => {
|
|
|
20
23
|
}
|
|
21
24
|
throw new Error('Invalid MPEG layer');
|
|
22
25
|
};
|
|
26
|
+
exports.getSamplesPerMpegFrame = getSamplesPerMpegFrame;
|