@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
package/dist/aac-codecprivate.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapAudioObjectTypeToCodecString = exports.parseAacCodecPrivate = exports.createAacCodecPrivate = exports.getSampleRateFromSampleFrequencyIndex = void 0;
|
|
4
|
+
const getSampleRateFromSampleFrequencyIndex = (samplingFrequencyIndex) => {
|
|
2
5
|
switch (samplingFrequencyIndex) {
|
|
3
6
|
case 0:
|
|
4
7
|
return 96000;
|
|
@@ -30,6 +33,7 @@ export const getSampleRateFromSampleFrequencyIndex = (samplingFrequencyIndex) =>
|
|
|
30
33
|
throw new Error(`Unexpected sampling frequency index ${samplingFrequencyIndex}`);
|
|
31
34
|
}
|
|
32
35
|
};
|
|
36
|
+
exports.getSampleRateFromSampleFrequencyIndex = getSampleRateFromSampleFrequencyIndex;
|
|
33
37
|
// codec private, for example [17, 144]
|
|
34
38
|
// audioObjectType = 2 = 'AAC LC'
|
|
35
39
|
// samplingFrequencyIndex = 3 = '48000 Hz'
|
|
@@ -86,7 +90,7 @@ const getConfigForSampleRate = (sampleRate) => {
|
|
|
86
90
|
}
|
|
87
91
|
throw new Error(`Unexpected sample rate ${sampleRate}`);
|
|
88
92
|
};
|
|
89
|
-
|
|
93
|
+
const createAacCodecPrivate = ({ audioObjectType, sampleRate, channelConfiguration, codecPrivate, }) => {
|
|
90
94
|
if (codecPrivate !== null && codecPrivate.length > 2) {
|
|
91
95
|
// Video submitted
|
|
92
96
|
// submitted by Yossi Elkrief
|
|
@@ -104,7 +108,8 @@ export const createAacCodecPrivate = ({ audioObjectType, sampleRate, channelConf
|
|
|
104
108
|
const secondByte = parseInt(bits.slice(8, 16), 2);
|
|
105
109
|
return new Uint8Array([firstByte, secondByte]);
|
|
106
110
|
};
|
|
107
|
-
|
|
111
|
+
exports.createAacCodecPrivate = createAacCodecPrivate;
|
|
112
|
+
const parseAacCodecPrivate = (bytes) => {
|
|
108
113
|
if (bytes.length < 2) {
|
|
109
114
|
throw new Error('Invalid AAC codec private length');
|
|
110
115
|
}
|
|
@@ -126,18 +131,19 @@ export const parseAacCodecPrivate = (bytes) => {
|
|
|
126
131
|
offset += 5;
|
|
127
132
|
return {
|
|
128
133
|
audioObjectType: newAudioObjectType,
|
|
129
|
-
sampleRate: getSampleRateFromSampleFrequencyIndex(extensionSamplingFrequencyIndex),
|
|
134
|
+
sampleRate: (0, exports.getSampleRateFromSampleFrequencyIndex)(extensionSamplingFrequencyIndex),
|
|
130
135
|
channelConfiguration,
|
|
131
136
|
};
|
|
132
137
|
}
|
|
133
|
-
const sampleRate = getSampleRateFromSampleFrequencyIndex(samplingFrequencyIndex);
|
|
138
|
+
const sampleRate = (0, exports.getSampleRateFromSampleFrequencyIndex)(samplingFrequencyIndex);
|
|
134
139
|
return {
|
|
135
140
|
audioObjectType,
|
|
136
141
|
sampleRate,
|
|
137
142
|
channelConfiguration,
|
|
138
143
|
};
|
|
139
144
|
};
|
|
140
|
-
|
|
145
|
+
exports.parseAacCodecPrivate = parseAacCodecPrivate;
|
|
146
|
+
const mapAudioObjectTypeToCodecString = (audioObjectType) => {
|
|
141
147
|
/**
|
|
142
148
|
* 1. 1 - mp4a.40.2: MPEG-4 AAC LC (Low Complexity)
|
|
143
149
|
2. 2 - mp4a.40.5: MPEG-4 AAC HE (High Efficiency)
|
|
@@ -169,3 +175,4 @@ export const mapAudioObjectTypeToCodecString = (audioObjectType) => {
|
|
|
169
175
|
throw new Error(`Unexpected audio object type ${audioObjectType}`);
|
|
170
176
|
}
|
|
171
177
|
};
|
|
178
|
+
exports.mapAudioObjectTypeToCodecString = mapAudioObjectTypeToCodecString;
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addAvcProfileToTrack = void 0;
|
|
4
|
+
const codec_string_1 = require("./containers/avc/codec-string");
|
|
5
|
+
const create_sps_pps_data_1 = require("./containers/avc/create-sps-pps-data");
|
|
6
|
+
const addAvcProfileToTrack = (track, avc1Profile) => {
|
|
4
7
|
if (avc1Profile === null) {
|
|
5
8
|
return track;
|
|
6
9
|
}
|
|
7
10
|
return {
|
|
8
11
|
...track,
|
|
9
|
-
codec: getCodecStringFromSpsAndPps(avc1Profile.sps),
|
|
10
|
-
codecPrivate: createSpsPpsData(avc1Profile),
|
|
12
|
+
codec: (0, codec_string_1.getCodecStringFromSpsAndPps)(avc1Profile.sps),
|
|
13
|
+
codecPrivate: (0, create_sps_pps_data_1.createSpsPpsData)(avc1Profile),
|
|
11
14
|
};
|
|
12
15
|
};
|
|
16
|
+
exports.addAvcProfileToTrack = addAvcProfileToTrack;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkIfDone = void 0;
|
|
4
|
+
const has_all_info_1 = require("./has-all-info");
|
|
5
|
+
const log_1 = require("./log");
|
|
6
|
+
const checkIfDone = async (state) => {
|
|
7
|
+
const startCheck = Date.now();
|
|
8
|
+
const hasAll = (0, has_all_info_1.hasAllInfo)({
|
|
9
|
+
state,
|
|
10
|
+
});
|
|
11
|
+
state.timings.timeCheckingIfDone += Date.now() - startCheck;
|
|
12
|
+
if (hasAll && state.mode === 'query') {
|
|
13
|
+
log_1.Log.verbose(state.logLevel, 'Got all info, skipping to the end.');
|
|
14
|
+
state.increaseSkippedBytes(state.contentLength - state.iterator.counter.getOffset());
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
if (state.iterator.counter.getOffset() === state.contentLength) {
|
|
18
|
+
if (state.getStructure().type === 'm3u' &&
|
|
19
|
+
!state.m3u.getAllChunksProcessedOverall()) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
log_1.Log.verbose(state.logLevel, 'Reached end of file');
|
|
23
|
+
await state.discardReadBytes(true);
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
if (state.iterator.counter.getOffset() + state.iterator.bytesRemaining() ===
|
|
27
|
+
state.contentLength &&
|
|
28
|
+
state.errored) {
|
|
29
|
+
log_1.Log.verbose(state.logLevel, 'Reached end of file and errorred');
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
return false;
|
|
33
|
+
};
|
|
34
|
+
exports.checkIfDone = checkIfDone;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.combineUint8Arrays = void 0;
|
|
4
|
+
const combineUint8Arrays = (arrays) => {
|
|
2
5
|
if (arrays.length === 0) {
|
|
3
6
|
return new Uint8Array([]);
|
|
4
7
|
}
|
|
@@ -17,3 +20,4 @@ export const combineUint8Arrays = (arrays) => {
|
|
|
17
20
|
}
|
|
18
21
|
return result;
|
|
19
22
|
};
|
|
23
|
+
exports.combineUint8Arrays = combineUint8Arrays;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseAac = void 0;
|
|
4
|
+
const aac_codecprivate_1 = require("../../aac-codecprivate");
|
|
5
|
+
const convert_audio_or_video_sample_1 = require("../../convert-audio-or-video-sample");
|
|
6
|
+
const emit_audio_sample_1 = require("../../emit-audio-sample");
|
|
7
|
+
const register_track_1 = require("../../register-track");
|
|
8
|
+
const parseAac = async (state) => {
|
|
5
9
|
const { iterator } = state;
|
|
6
10
|
const startOffset = iterator.counter.getOffset();
|
|
7
11
|
iterator.startReadingBits();
|
|
@@ -20,10 +24,10 @@ export const parseAac = async (state) => {
|
|
|
20
24
|
const protectionAbsent = iterator.getBits(1); // protection absent
|
|
21
25
|
const audioObjectType = iterator.getBits(2); // 1 = 'AAC-LC'
|
|
22
26
|
const samplingFrequencyIndex = iterator.getBits(4);
|
|
23
|
-
const sampleRate = getSampleRateFromSampleFrequencyIndex(samplingFrequencyIndex);
|
|
27
|
+
const sampleRate = (0, aac_codecprivate_1.getSampleRateFromSampleFrequencyIndex)(samplingFrequencyIndex);
|
|
24
28
|
iterator.getBits(1); // private bit
|
|
25
29
|
const channelConfiguration = iterator.getBits(3);
|
|
26
|
-
const codecPrivate = createAacCodecPrivate({
|
|
30
|
+
const codecPrivate = (0, aac_codecprivate_1.createAacCodecPrivate)({
|
|
27
31
|
audioObjectType,
|
|
28
32
|
sampleRate,
|
|
29
33
|
channelConfiguration,
|
|
@@ -43,11 +47,11 @@ export const parseAac = async (state) => {
|
|
|
43
47
|
iterator.counter.decrement(iterator.counter.getOffset() - startOffset);
|
|
44
48
|
const data = iterator.getSlice(frameLength);
|
|
45
49
|
if (state.callbacks.tracks.getTracks().length === 0) {
|
|
46
|
-
await registerAudioTrack({
|
|
50
|
+
await (0, register_track_1.registerAudioTrack)({
|
|
47
51
|
state,
|
|
48
52
|
container: 'aac',
|
|
49
53
|
track: {
|
|
50
|
-
codec: mapAudioObjectTypeToCodecString(audioObjectType),
|
|
54
|
+
codec: (0, aac_codecprivate_1.mapAudioObjectTypeToCodecString)(audioObjectType),
|
|
51
55
|
codecWithoutConfig: 'aac',
|
|
52
56
|
codecPrivate,
|
|
53
57
|
description: codecPrivate,
|
|
@@ -65,16 +69,21 @@ export const parseAac = async (state) => {
|
|
|
65
69
|
const { index } = state.aac.addSample({ offset: startOffset, size: frameLength });
|
|
66
70
|
const timestamp = (1024 / sampleRate) * index;
|
|
67
71
|
// One ADTS frame contains 1024 samples
|
|
68
|
-
await
|
|
69
|
-
duration,
|
|
70
|
-
type: 'key',
|
|
71
|
-
data,
|
|
72
|
-
offset: startOffset,
|
|
73
|
-
timescale: 1000000,
|
|
72
|
+
await (0, emit_audio_sample_1.emitAudioSample)({
|
|
74
73
|
trackId: 0,
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
audioSample: (0, convert_audio_or_video_sample_1.convertAudioOrVideoSampleToWebCodecsTimestamps)({
|
|
75
|
+
duration,
|
|
76
|
+
type: 'key',
|
|
77
|
+
data,
|
|
78
|
+
offset: startOffset,
|
|
79
|
+
timescale: 1000000,
|
|
80
|
+
trackId: 0,
|
|
81
|
+
cts: timestamp,
|
|
82
|
+
dts: timestamp,
|
|
83
|
+
timestamp,
|
|
84
|
+
}, 1),
|
|
85
|
+
state,
|
|
86
|
+
});
|
|
79
87
|
return Promise.resolve(null);
|
|
80
88
|
};
|
|
89
|
+
exports.parseAac = parseAac;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCodecStringFromSpsAndPps = void 0;
|
|
4
|
+
const getCodecStringFromSpsAndPps = (sps) => {
|
|
2
5
|
return `avc1.${sps.spsData.profile.toString(16).padStart(2, '0')}${sps.spsData.compatibility.toString(16).padStart(2, '0')}${sps.spsData.level.toString(16).padStart(2, '0')}`;
|
|
3
6
|
};
|
|
7
|
+
exports.getCodecStringFromSpsAndPps = getCodecStringFromSpsAndPps;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPrimariesFromIndex = exports.getTransferCharacteristicsFromIndex = exports.getMatrixCoefficientsFromIndex = void 0;
|
|
4
|
+
const getMatrixCoefficientsFromIndex = (index) => {
|
|
2
5
|
return index === 1
|
|
3
6
|
? 'bt709'
|
|
4
7
|
: index === 5
|
|
@@ -9,7 +12,8 @@ export const getMatrixCoefficientsFromIndex = (index) => {
|
|
|
9
12
|
? 'bt2020'
|
|
10
13
|
: null;
|
|
11
14
|
};
|
|
12
|
-
|
|
15
|
+
exports.getMatrixCoefficientsFromIndex = getMatrixCoefficientsFromIndex;
|
|
16
|
+
const getTransferCharacteristicsFromIndex = (index) => {
|
|
13
17
|
return index === 1
|
|
14
18
|
? 'bt709'
|
|
15
19
|
: index === 6
|
|
@@ -20,7 +24,8 @@ export const getTransferCharacteristicsFromIndex = (index) => {
|
|
|
20
24
|
? 'arib-std-b67'
|
|
21
25
|
: null;
|
|
22
26
|
};
|
|
23
|
-
|
|
27
|
+
exports.getTransferCharacteristicsFromIndex = getTransferCharacteristicsFromIndex;
|
|
28
|
+
const getPrimariesFromIndex = (index) => {
|
|
24
29
|
return index === 1
|
|
25
30
|
? 'bt709'
|
|
26
31
|
: index === 5
|
|
@@ -31,3 +36,4 @@ export const getPrimariesFromIndex = (index) => {
|
|
|
31
36
|
? 'bt2020'
|
|
32
37
|
: null;
|
|
33
38
|
};
|
|
39
|
+
exports.getPrimariesFromIndex = getPrimariesFromIndex;
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSpsPpsData = void 0;
|
|
4
|
+
const combine_uint8_arrays_1 = require("../../combine-uint8-arrays");
|
|
5
|
+
const truthy_1 = require("../../truthy");
|
|
3
6
|
function serializeUint16(value) {
|
|
4
7
|
const buffer = new ArrayBuffer(2);
|
|
5
8
|
const view = new DataView(buffer);
|
|
6
9
|
view.setUint16(0, value);
|
|
7
10
|
return new Uint8Array(buffer);
|
|
8
11
|
}
|
|
9
|
-
|
|
10
|
-
return combineUint8Arrays([
|
|
12
|
+
const createSpsPpsData = (avc1Profile) => {
|
|
13
|
+
return (0, combine_uint8_arrays_1.combineUint8Arrays)([
|
|
11
14
|
new Uint8Array([
|
|
12
15
|
// https://gist.github.com/uupaa/8493378ec15f644a3d2b
|
|
13
16
|
1, // version
|
|
@@ -40,5 +43,6 @@ export const createSpsPpsData = (avc1Profile) => {
|
|
|
40
43
|
numOfSequenceParameterSetExt 0
|
|
41
44
|
*/
|
|
42
45
|
new Uint8Array([0xfd, 0xf8, 0xf8, 0]),
|
|
43
|
-
].filter(truthy));
|
|
46
|
+
].filter(truthy_1.truthy));
|
|
44
47
|
};
|
|
48
|
+
exports.createSpsPpsData = createSpsPpsData;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getVideoColorFromSps = exports.getSampleAspectRatioFromSps = exports.getDimensionsFromSps = void 0;
|
|
4
|
+
const color_1 = require("./color");
|
|
5
|
+
const getDimensionsFromSps = (sps) => {
|
|
3
6
|
var _a, _b, _c, _d;
|
|
4
7
|
const height = sps.pic_height_in_map_units_minus1;
|
|
5
8
|
const width = sps.pic_width_in_mbs_minus1;
|
|
@@ -13,7 +16,8 @@ export const getDimensionsFromSps = (sps) => {
|
|
|
13
16
|
((_d = sps.frame_crop_left_offset) !== null && _d !== void 0 ? _d : 0) * 2,
|
|
14
17
|
};
|
|
15
18
|
};
|
|
16
|
-
|
|
19
|
+
exports.getDimensionsFromSps = getDimensionsFromSps;
|
|
20
|
+
const getSampleAspectRatioFromSps = (sps) => {
|
|
17
21
|
var _a;
|
|
18
22
|
if (((_a = sps.vui_parameters) === null || _a === void 0 ? void 0 : _a.sar_height) && sps.vui_parameters.sar_width) {
|
|
19
23
|
return {
|
|
@@ -26,19 +30,21 @@ export const getSampleAspectRatioFromSps = (sps) => {
|
|
|
26
30
|
height: 1,
|
|
27
31
|
};
|
|
28
32
|
};
|
|
29
|
-
|
|
33
|
+
exports.getSampleAspectRatioFromSps = getSampleAspectRatioFromSps;
|
|
34
|
+
const getVideoColorFromSps = (sps) => {
|
|
30
35
|
var _a, _b, _c, _d, _e;
|
|
31
36
|
const matrixCoefficients = (_a = sps.vui_parameters) === null || _a === void 0 ? void 0 : _a.matrix_coefficients;
|
|
32
37
|
const transferCharacteristics = (_b = sps.vui_parameters) === null || _b === void 0 ? void 0 : _b.transfer_characteristics;
|
|
33
38
|
const colorPrimaries = (_c = sps.vui_parameters) === null || _c === void 0 ? void 0 : _c.colour_primaries;
|
|
34
39
|
return {
|
|
35
40
|
matrixCoefficients: matrixCoefficients
|
|
36
|
-
? getMatrixCoefficientsFromIndex(matrixCoefficients)
|
|
41
|
+
? (0, color_1.getMatrixCoefficientsFromIndex)(matrixCoefficients)
|
|
37
42
|
: null,
|
|
38
43
|
transferCharacteristics: transferCharacteristics
|
|
39
|
-
? getTransferCharacteristicsFromIndex(transferCharacteristics)
|
|
44
|
+
? (0, color_1.getTransferCharacteristicsFromIndex)(transferCharacteristics)
|
|
40
45
|
: null,
|
|
41
|
-
primaries: colorPrimaries ? getPrimariesFromIndex(colorPrimaries) : null,
|
|
46
|
+
primaries: colorPrimaries ? (0, color_1.getPrimariesFromIndex)(colorPrimaries) : null,
|
|
42
47
|
fullRange: (_e = (_d = sps.vui_parameters) === null || _d === void 0 ? void 0 : _d.video_full_range_flag) !== null && _e !== void 0 ? _e : null,
|
|
43
48
|
};
|
|
44
49
|
};
|
|
50
|
+
exports.getVideoColorFromSps = getVideoColorFromSps;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getKeyFrameOrDeltaFromAvcInfo = void 0;
|
|
4
|
+
const getKeyFrameOrDeltaFromAvcInfo = (infos) => {
|
|
2
5
|
const keyOrDelta = infos.find((i) => i.type === 'keyframe' || i.type === 'delta-frame');
|
|
3
6
|
if (!keyOrDelta) {
|
|
4
7
|
throw new Error('expected avc to contain info about key or delta');
|
|
5
8
|
}
|
|
6
9
|
return keyOrDelta.type === 'keyframe' ? 'key' : 'delta';
|
|
7
10
|
};
|
|
11
|
+
exports.getKeyFrameOrDeltaFromAvcInfo = getKeyFrameOrDeltaFromAvcInfo;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// https://www.itu.int/rec/T-REC-H.264-202408-I/en
|
|
2
3
|
// Page 455
|
|
3
|
-
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.parseAvc = void 0;
|
|
6
|
+
const buffer_iterator_1 = require("../../iterator/buffer-iterator");
|
|
4
7
|
const Extended_SAR = 255;
|
|
5
8
|
const readVuiParameters = (iterator) => {
|
|
6
9
|
let sar_width = null;
|
|
@@ -183,7 +186,7 @@ const findEnd = (buffer) => {
|
|
|
183
186
|
return null;
|
|
184
187
|
};
|
|
185
188
|
const inspect = (buffer) => {
|
|
186
|
-
const iterator = getArrayBufferIterator(buffer, buffer.byteLength);
|
|
189
|
+
const iterator = (0, buffer_iterator_1.getArrayBufferIterator)(buffer, buffer.byteLength);
|
|
187
190
|
iterator.startReadingBits();
|
|
188
191
|
iterator.getBits(1);
|
|
189
192
|
iterator.getBits(2);
|
|
@@ -221,7 +224,7 @@ const inspect = (buffer) => {
|
|
|
221
224
|
return null;
|
|
222
225
|
};
|
|
223
226
|
// https://stackoverflow.com/questions/24884827/possible-locations-for-sequence-picture-parameter-sets-for-h-264-stream
|
|
224
|
-
|
|
227
|
+
const parseAvc = (buffer) => {
|
|
225
228
|
let zeroesInARow = 0;
|
|
226
229
|
const infos = [];
|
|
227
230
|
for (let i = 0; i < buffer.length; i++) {
|
|
@@ -246,3 +249,4 @@ export const parseAvc = (buffer) => {
|
|
|
246
249
|
}
|
|
247
250
|
return infos;
|
|
248
251
|
};
|
|
252
|
+
exports.parseAvc = parseAvc;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSpsAndPps = void 0;
|
|
4
|
+
const getSpsAndPps = (infos) => {
|
|
2
5
|
const avcProfile = infos.find((i) => i.type === 'avc-profile');
|
|
3
6
|
const ppsProfile = infos.find((i) => i.type === 'avc-pps');
|
|
4
7
|
if (!avcProfile || !ppsProfile) {
|
|
@@ -6,3 +9,4 @@ export const getSpsAndPps = (infos) => {
|
|
|
6
9
|
}
|
|
7
10
|
return { pps: ppsProfile, sps: avcProfile };
|
|
8
11
|
};
|
|
12
|
+
exports.getSpsAndPps = getSpsAndPps;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { BufferIterator } from '../../buffer-iterator';
|
|
1
|
+
import type { BufferIterator } from '../../iterator/buffer-iterator';
|
|
2
2
|
export declare const getBlockSize: (iterator: BufferIterator) => number | "uncommon-u16" | "uncommon-u8";
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getBlockSize = void 0;
|
|
4
|
+
const getBlockSize = (iterator) => {
|
|
2
5
|
const bits = iterator.getBits(4);
|
|
3
6
|
if (bits === 0b0000) {
|
|
4
7
|
throw new Error('Reserved block size');
|
|
@@ -20,3 +23,4 @@ export const getBlockSize = (iterator) => {
|
|
|
20
23
|
}
|
|
21
24
|
throw new Error('Invalid block size');
|
|
22
25
|
};
|
|
26
|
+
exports.getBlockSize = getBlockSize;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { BufferIterator } from '../../buffer-iterator';
|
|
2
|
-
export declare const getChannelCount: (iterator: BufferIterator) =>
|
|
1
|
+
import type { BufferIterator } from '../../iterator/buffer-iterator';
|
|
2
|
+
export declare const getChannelCount: (iterator: BufferIterator) => 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getChannelCount = void 0;
|
|
1
4
|
// https://www.rfc-editor.org/rfc/rfc9639.html#name-channels-bits
|
|
2
|
-
|
|
5
|
+
const getChannelCount = (iterator) => {
|
|
3
6
|
const bits = iterator.getBits(4);
|
|
4
7
|
if (bits === 0b0000) {
|
|
5
8
|
return 1;
|
|
@@ -30,3 +33,4 @@ export const getChannelCount = (iterator) => {
|
|
|
30
33
|
}
|
|
31
34
|
throw new Error(`Invalid channel count: ${bits.toString(2)}`);
|
|
32
35
|
};
|
|
36
|
+
exports.getChannelCount = getChannelCount;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDurationFromFlac = void 0;
|
|
4
|
+
const getDurationFromFlac = (parserState) => {
|
|
2
5
|
const structure = parserState.getFlacStructure();
|
|
3
6
|
const streaminfo = structure.boxes.find((b) => b.type === 'flac-streaminfo');
|
|
4
7
|
if (!streaminfo) {
|
|
@@ -6,3 +9,4 @@ export const getDurationFromFlac = (parserState) => {
|
|
|
6
9
|
}
|
|
7
10
|
return streaminfo.totalSamples / streaminfo.sampleRate;
|
|
8
11
|
};
|
|
12
|
+
exports.getDurationFromFlac = getDurationFromFlac;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMetadataFromFlac = void 0;
|
|
4
|
+
const getMetadataFromFlac = (structure) => {
|
|
2
5
|
const box = structure.boxes.find((b) => b.type === 'flac-vorbis-comment');
|
|
3
6
|
if (!box) {
|
|
4
7
|
return null;
|
|
5
8
|
}
|
|
6
9
|
return box.fields;
|
|
7
10
|
};
|
|
11
|
+
exports.getMetadataFromFlac = getMetadataFromFlac;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { BufferIterator } from '../../buffer-iterator';
|
|
1
|
+
import type { BufferIterator } from '../../iterator/buffer-iterator';
|
|
2
2
|
import type { ParserState } from '../../state/parser-state';
|
|
3
3
|
export declare const getSampleRate: (iterator: BufferIterator, state: ParserState) => number | "uncommon-u8" | "uncommon-u16" | "uncommon-u16-10";
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSampleRate = void 0;
|
|
1
4
|
// https://www.rfc-editor.org/rfc/rfc9639.html#name-sample-rate-bits
|
|
2
|
-
|
|
5
|
+
const getSampleRate = (iterator, state) => {
|
|
3
6
|
var _a, _b;
|
|
4
7
|
const mode = iterator.getBits(4);
|
|
5
8
|
if (mode === 0b0000) {
|
|
@@ -54,3 +57,4 @@ export const getSampleRate = (iterator, state) => {
|
|
|
54
57
|
}
|
|
55
58
|
throw new Error(`Invalid sample rate mode: ${mode.toString(2)}`);
|
|
56
59
|
};
|
|
60
|
+
exports.getSampleRate = getSampleRate;
|
|
@@ -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 { ParserState } from '../../state/parser-state';
|
|
4
4
|
export declare const parseFrameHeader: ({ iterator, state, }: {
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseFlacFrame = exports.parseFrameHeader = void 0;
|
|
4
|
+
const convert_audio_or_video_sample_1 = require("../../convert-audio-or-video-sample");
|
|
5
|
+
const emit_audio_sample_1 = require("../../emit-audio-sample");
|
|
6
|
+
const buffer_iterator_1 = require("../../iterator/buffer-iterator");
|
|
7
|
+
const get_block_size_1 = require("./get-block-size");
|
|
8
|
+
const get_channel_count_1 = require("./get-channel-count");
|
|
9
|
+
const get_sample_rate_1 = require("./get-sample-rate");
|
|
6
10
|
// https://www.rfc-editor.org/rfc/rfc9639.html#section-9.1.1
|
|
7
11
|
function calculateCRC8(data) {
|
|
8
12
|
const polynomial = 0x07; // x^8 + x^2 + x^1 + x^0
|
|
@@ -23,16 +27,16 @@ function calculateCRC8(data) {
|
|
|
23
27
|
}
|
|
24
28
|
return crc;
|
|
25
29
|
}
|
|
26
|
-
|
|
30
|
+
const parseFrameHeader = ({ iterator, state, }) => {
|
|
27
31
|
if (iterator.bytesRemaining() < 10) {
|
|
28
32
|
return null;
|
|
29
33
|
}
|
|
30
34
|
const startOffset = iterator.counter.getOffset();
|
|
31
35
|
iterator.discard(2); // sync code
|
|
32
36
|
iterator.startReadingBits();
|
|
33
|
-
const blockSizeBits = getBlockSize(iterator);
|
|
34
|
-
const sampleRateBits = getSampleRate(iterator, state);
|
|
35
|
-
getChannelCount(iterator); // channel count
|
|
37
|
+
const blockSizeBits = (0, get_block_size_1.getBlockSize)(iterator);
|
|
38
|
+
const sampleRateBits = (0, get_sample_rate_1.getSampleRate)(iterator, state);
|
|
39
|
+
(0, get_channel_count_1.getChannelCount)(iterator); // channel count
|
|
36
40
|
iterator.getBits(3); // bit depth
|
|
37
41
|
iterator.getBits(1);
|
|
38
42
|
const num = iterator.getFlacCodecNumber();
|
|
@@ -59,9 +63,10 @@ export const parseFrameHeader = ({ iterator, state, }) => {
|
|
|
59
63
|
}
|
|
60
64
|
return { num, blockSize, sampleRate };
|
|
61
65
|
};
|
|
66
|
+
exports.parseFrameHeader = parseFrameHeader;
|
|
62
67
|
const emitSample = async ({ state, data, offset, }) => {
|
|
63
|
-
const iterator = getArrayBufferIterator(data, null);
|
|
64
|
-
const parsed = parseFrameHeader({ iterator, state });
|
|
68
|
+
const iterator = (0, buffer_iterator_1.getArrayBufferIterator)(data, null);
|
|
69
|
+
const parsed = (0, exports.parseFrameHeader)({ iterator, state });
|
|
65
70
|
if (!parsed) {
|
|
66
71
|
throw new Error('Invalid CRC');
|
|
67
72
|
}
|
|
@@ -76,20 +81,24 @@ const emitSample = async ({ state, data, offset, }) => {
|
|
|
76
81
|
throw new Error('Cannot determine timestamp');
|
|
77
82
|
}
|
|
78
83
|
const timestamp = (num * streamInfo.maximumBlockSize) / streamInfo.sampleRate;
|
|
79
|
-
await
|
|
80
|
-
data,
|
|
81
|
-
duration,
|
|
82
|
-
cts: timestamp,
|
|
83
|
-
dts: timestamp,
|
|
84
|
-
timestamp,
|
|
85
|
-
type: 'key',
|
|
86
|
-
offset,
|
|
87
|
-
timescale: 1000000,
|
|
84
|
+
await (0, emit_audio_sample_1.emitAudioSample)({
|
|
88
85
|
trackId: 0,
|
|
89
|
-
|
|
86
|
+
audioSample: (0, convert_audio_or_video_sample_1.convertAudioOrVideoSampleToWebCodecsTimestamps)({
|
|
87
|
+
data,
|
|
88
|
+
duration,
|
|
89
|
+
cts: timestamp,
|
|
90
|
+
dts: timestamp,
|
|
91
|
+
timestamp,
|
|
92
|
+
type: 'key',
|
|
93
|
+
offset,
|
|
94
|
+
timescale: 1000000,
|
|
95
|
+
trackId: 0,
|
|
96
|
+
}, 1),
|
|
97
|
+
state,
|
|
98
|
+
});
|
|
90
99
|
iterator.destroy();
|
|
91
100
|
};
|
|
92
|
-
|
|
101
|
+
const parseFlacFrame = async ({ state, iterator, }) => {
|
|
93
102
|
var _a, _b;
|
|
94
103
|
const blockingBit = state.flac.getBlockingBitStrategy();
|
|
95
104
|
const offset = iterator.counter.getOffset();
|
|
@@ -148,7 +157,7 @@ export const parseFlacFrame = async ({ state, iterator, }) => {
|
|
|
148
157
|
continue;
|
|
149
158
|
}
|
|
150
159
|
iterator.counter.decrement(2);
|
|
151
|
-
const nextIsLegit = parseFrameHeader({ iterator, state });
|
|
160
|
+
const nextIsLegit = (0, exports.parseFrameHeader)({ iterator, state });
|
|
152
161
|
if (!nextIsLegit) {
|
|
153
162
|
iterator.discard(1);
|
|
154
163
|
continue;
|
|
@@ -162,3 +171,4 @@ export const parseFlacFrame = async ({ state, iterator, }) => {
|
|
|
162
171
|
}
|
|
163
172
|
return null;
|
|
164
173
|
};
|
|
174
|
+
exports.parseFlacFrame = parseFlacFrame;
|
|
@@ -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 { ParserState } from '../../state/parser-state';
|
|
4
4
|
export declare const parseFlac: ({ iterator, state, }: {
|