@remotion/media-parser 4.0.249 → 4.0.251
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/add-avc-profile-to-track.js +2 -2
- package/dist/buffer-iterator.d.ts +3 -5
- package/dist/buffer-iterator.js +66 -50
- package/dist/containers/aac/parse-aac.d.ts +3 -0
- package/dist/containers/aac/parse-aac.js +83 -0
- package/dist/containers/aac/types.d.ts +4 -0
- package/dist/{boxes → containers}/avc/key.d.ts +1 -1
- package/dist/containers/flac/get-block-size.d.ts +2 -0
- package/dist/containers/flac/get-block-size.js +26 -0
- package/dist/containers/flac/get-channel-count.d.ts +2 -0
- package/dist/containers/flac/get-channel-count.js +36 -0
- package/dist/containers/flac/get-duration-from-flac.d.ts +2 -0
- package/dist/containers/flac/get-duration-from-flac.js +15 -0
- package/dist/containers/flac/get-metadata-from-flac.d.ts +2 -0
- package/dist/containers/flac/get-metadata-from-flac.js +11 -0
- package/dist/containers/flac/get-sample-rate.d.ts +3 -0
- package/dist/containers/flac/get-sample-rate.js +60 -0
- package/dist/containers/flac/parse-flac-frame.d.ts +15 -0
- package/dist/containers/flac/parse-flac-frame.js +175 -0
- package/dist/{boxes/riff/parse-box.d.ts → containers/flac/parse-flac.d.ts} +1 -3
- package/dist/containers/flac/parse-flac.js +54 -0
- package/dist/{boxes/mp3/parse-mpeg-header.d.ts → containers/flac/parse-header.d.ts} +4 -3
- package/dist/containers/flac/parse-header.js +10 -0
- package/dist/{boxes/mp3/parse-mp3.d.ts → containers/flac/parse-metadata.d.ts} +4 -4
- package/dist/containers/flac/parse-metadata.js +24 -0
- package/dist/{boxes/webm/parse-webm-header.d.ts → containers/flac/parse-streaminfo.d.ts} +2 -4
- package/dist/containers/flac/parse-streaminfo.js +53 -0
- package/dist/containers/flac/parse-unknown-block.d.ts +8 -0
- package/dist/containers/flac/parse-unknown-block.js +11 -0
- package/dist/containers/flac/types.d.ts +26 -0
- package/dist/containers/iso-base-media/base-media-box.d.ts +40 -0
- package/dist/containers/iso-base-media/get-children.d.ts +6 -0
- package/dist/containers/iso-base-media/get-children.js +21 -0
- package/dist/{boxes → containers}/iso-base-media/get-sample-positions-from-track.d.ts +1 -1
- package/dist/containers/iso-base-media/mdat/mdat.d.ts +2 -0
- package/dist/containers/iso-base-media/mdat/mdat.js +91 -0
- package/dist/containers/iso-base-media/moov/moov.d.ts +12 -0
- package/dist/containers/iso-base-media/moov/moov.js +17 -0
- package/dist/containers/iso-base-media/parse-boxes.d.ts +3 -0
- package/dist/containers/iso-base-media/parse-boxes.js +40 -0
- package/dist/containers/iso-base-media/process-box.d.ts +3 -0
- package/dist/{boxes → containers}/iso-base-media/process-box.js +49 -147
- package/dist/{boxes → containers}/iso-base-media/stsd/mebx.d.ts +1 -6
- package/dist/containers/iso-base-media/stsd/mebx.js +22 -0
- package/dist/{boxes → containers}/iso-base-media/stsd/samples.d.ts +6 -16
- package/dist/{boxes → containers}/iso-base-media/stsd/samples.js +26 -71
- package/dist/{boxes → containers}/iso-base-media/stsd/stsd.d.ts +1 -6
- package/dist/{boxes → containers}/iso-base-media/stsd/stsd.js +3 -6
- package/dist/containers/iso-base-media/trak/trak.d.ts +12 -0
- package/dist/containers/iso-base-media/trak/trak.js +17 -0
- package/dist/{boxes → containers}/iso-base-media/traversal.d.ts +2 -3
- package/dist/{boxes → containers}/iso-base-media/traversal.js +1 -12
- package/dist/containers/iso-base-media/void-box.js +2 -0
- package/dist/containers/mp3/get-tracks-from-mp3.d.ts +4 -0
- package/dist/{boxes → containers}/mp3/get-tracks-from-mp3.js +6 -6
- package/dist/containers/mp3/id3.d.ts +4 -0
- package/dist/{boxes → containers}/mp3/id3.js +8 -5
- package/dist/containers/mp3/parse-mp3.d.ts +3 -0
- package/dist/{boxes → containers}/mp3/parse-mp3.js +4 -20
- package/dist/containers/mp3/parse-mpeg-header.d.ts +4 -0
- package/dist/{boxes → containers}/mp3/parse-mpeg-header.js +2 -1
- package/dist/containers/riff/expect-riff-box.d.ts +7 -0
- package/dist/containers/riff/expect-riff-box.js +72 -0
- package/dist/containers/riff/get-duration.d.ts +3 -0
- package/dist/containers/riff/get-duration.js +33 -0
- package/dist/{boxes → containers}/riff/get-tracks-from-avi.d.ts +2 -3
- package/dist/{boxes → containers}/riff/get-tracks-from-avi.js +6 -10
- package/dist/containers/riff/parse-list-box.d.ts +6 -0
- package/dist/containers/riff/parse-list-box.js +29 -0
- package/dist/containers/riff/parse-movi.d.ts +11 -0
- package/dist/{boxes → containers}/riff/parse-movi.js +37 -57
- package/dist/containers/riff/parse-riff-body.d.ts +3 -0
- package/dist/containers/riff/parse-riff-body.js +22 -0
- package/dist/containers/riff/parse-riff-box.d.ts +7 -0
- package/dist/{boxes → containers}/riff/parse-riff-box.js +3 -10
- package/dist/containers/riff/parse-riff-header.d.ts +3 -0
- package/dist/containers/riff/parse-riff-header.js +23 -0
- package/dist/containers/riff/parse-riff.d.ts +3 -0
- package/dist/containers/riff/parse-riff.js +12 -0
- package/dist/containers/riff/parse-strf.d.ts +7 -0
- package/dist/{boxes → containers}/riff/parse-strf.js +4 -8
- package/dist/{boxes → containers}/riff/parse-strh.js +11 -0
- package/dist/containers/riff/parse-video-section.d.ts +2 -0
- package/dist/containers/riff/parse-video-section.js +19 -0
- package/dist/{boxes → containers}/riff/riff-box.d.ts +8 -14
- package/dist/containers/riff/riff-box.js +2 -0
- package/dist/{boxes → containers}/riff/traversal.d.ts +1 -3
- package/dist/{boxes → containers}/riff/traversal.js +1 -6
- package/dist/containers/transport-stream/boxes.js +2 -0
- package/dist/containers/transport-stream/get-tracks.d.ts +4 -0
- package/dist/{boxes → containers}/transport-stream/get-tracks.js +4 -3
- package/dist/containers/transport-stream/parse-packet.d.ts +5 -0
- package/dist/{boxes → containers}/transport-stream/parse-packet.js +4 -5
- package/dist/containers/transport-stream/parse-stream-packet.d.ts +9 -0
- package/dist/{boxes → containers}/transport-stream/parse-stream-packet.js +11 -12
- package/dist/containers/transport-stream/parse-transport-stream.d.ts +3 -0
- package/dist/{boxes → containers}/transport-stream/parse-transport-stream.js +8 -37
- package/dist/{boxes → containers}/transport-stream/process-stream-buffers.d.ts +1 -2
- package/dist/{boxes → containers}/transport-stream/process-stream-buffers.js +3 -3
- package/dist/containers/wav/get-duration-from-wav.d.ts +3 -0
- package/dist/containers/wav/get-duration-from-wav.js +29 -0
- package/dist/containers/wav/get-metadata-from-wav.d.ts +3 -0
- package/dist/containers/wav/get-metadata-from-wav.js +11 -0
- package/dist/containers/wav/parse-data.d.ts +5 -0
- package/dist/containers/wav/parse-data.js +25 -0
- package/dist/containers/wav/parse-fmt.d.ts +5 -0
- package/dist/containers/wav/parse-fmt.js +56 -0
- package/dist/containers/wav/parse-header.d.ts +5 -0
- package/dist/containers/wav/parse-header.js +17 -0
- package/dist/containers/wav/parse-id3.d.ts +5 -0
- package/dist/containers/wav/parse-id3.js +17 -0
- package/dist/containers/wav/parse-list.d.ts +5 -0
- package/dist/containers/wav/parse-list.js +32 -0
- package/dist/containers/wav/parse-video-section.d.ts +5 -0
- package/dist/containers/wav/parse-video-section.js +37 -0
- package/dist/containers/wav/parse-wav.d.ts +3 -0
- package/dist/containers/wav/parse-wav.js +36 -0
- package/dist/containers/wav/types.d.ts +30 -0
- package/dist/containers/wav/types.js +2 -0
- package/dist/{boxes → containers}/webm/parse-ebml.d.ts +1 -2
- package/dist/{boxes → containers}/webm/parse-ebml.js +6 -2
- package/dist/containers/webm/parse-webm-header.d.ts +3 -0
- package/dist/containers/webm/parse-webm-header.js +53 -0
- package/dist/containers/webm/segments.d.ts +9 -0
- package/dist/containers/webm/segments.js +80 -0
- package/dist/emit-available-info.d.ts +1 -3
- package/dist/emit-available-info.js +86 -76
- package/dist/errors.d.ts +1 -1
- package/dist/esm/from-node.mjs +8 -9
- package/dist/esm/index.mjs +4951 -4693
- package/dist/file-types/detect-file-type.d.ts +5 -1
- package/dist/file-types/detect-file-type.js +10 -3
- package/dist/file-types/index.js +3 -0
- package/dist/get-audio-codec.d.ts +4 -5
- package/dist/get-audio-codec.js +5 -5
- package/dist/get-container.d.ts +2 -2
- package/dist/get-container.js +10 -1
- package/dist/get-dimensions.d.ts +2 -3
- package/dist/get-dimensions.js +14 -10
- package/dist/get-duration.d.ts +5 -5
- package/dist/get-duration.js +29 -27
- package/dist/get-fields-from-callbacks.js +4 -0
- package/dist/get-fps.d.ts +1 -1
- package/dist/get-fps.js +12 -4
- package/dist/get-is-hdr.d.ts +2 -3
- package/dist/get-is-hdr.js +4 -4
- package/dist/get-keyframes.d.ts +1 -1
- package/dist/get-keyframes.js +4 -3
- package/dist/get-number-of-audio-channels.d.ts +3 -0
- package/dist/get-number-of-audio-channels.js +14 -0
- package/dist/get-sample-aspect-ratio.d.ts +8 -8
- package/dist/get-sample-aspect-ratio.js +1 -1
- package/dist/get-sample-positions-from-lpcm.d.ts +1 -1
- package/dist/get-sample-positions-from-lpcm.js +1 -1
- package/dist/get-sample-positions.d.ts +6 -6
- package/dist/get-sample-rate.d.ts +3 -0
- package/dist/get-sample-rate.js +14 -0
- package/dist/get-tracks.d.ts +9 -8
- package/dist/get-tracks.js +36 -22
- package/dist/get-video-codec.d.ts +3 -4
- package/dist/get-video-codec.js +6 -6
- package/dist/has-all-info.js +26 -15
- package/dist/index.d.ts +145 -41
- package/dist/index.js +8 -8
- package/dist/init-video.d.ts +7 -0
- package/dist/init-video.js +114 -0
- package/dist/is-audio-structure.d.ts +2 -0
- package/dist/is-audio-structure.js +31 -0
- package/dist/metadata/get-metadata.js +16 -1
- package/dist/metadata/metadata-from-iso.d.ts +2 -1
- package/dist/metadata/metadata-from-iso.js +1 -1
- package/dist/metadata/metadata-from-matroska.js +1 -1
- package/dist/metadata/metadata-from-riff.d.ts +1 -1
- package/dist/options.d.ts +64 -38
- package/dist/parse-media.js +125 -43
- package/dist/parse-result.d.ts +8 -61
- package/dist/perform-seek.d.ts +13 -0
- package/dist/perform-seek.js +29 -0
- package/dist/readers/from-node.js +7 -8
- package/dist/readers/reader.d.ts +1 -1
- package/dist/register-track.d.ts +3 -3
- package/dist/run-parse-iteration.d.ts +8 -0
- package/dist/run-parse-iteration.js +48 -0
- package/dist/samples-from-moof.js +1 -1
- package/dist/state/aac-state.d.ts +13 -0
- package/dist/state/aac-state.js +17 -0
- package/dist/state/can-skip-tracks.d.ts +8 -1
- package/dist/state/can-skip-tracks.js +42 -27
- package/dist/state/emitted-fields.js +4 -0
- package/dist/state/flac-state.d.ts +4 -0
- package/dist/state/flac-state.js +13 -0
- package/dist/state/has-tracks-section.d.ts +2 -1
- package/dist/state/has-tracks-section.js +4 -1
- package/dist/state/iso-base-media/cached-sample-positions.d.ts +15 -0
- package/dist/state/iso-base-media/cached-sample-positions.js +42 -0
- package/dist/state/iso-base-media/iso-state.d.ts +8 -0
- package/dist/state/iso-base-media/iso-state.js +15 -0
- package/dist/{may-skip-video-data → state}/may-skip-video-data.d.ts +1 -1
- package/dist/{may-skip-video-data → state}/may-skip-video-data.js +6 -2
- package/dist/{may-skip-video-data → state}/need-samples-for-fields.js +4 -0
- package/dist/state/parser-state.d.ts +131 -17
- package/dist/state/parser-state.js +18 -5
- package/dist/state/sample-callbacks.d.ts +6 -2
- package/dist/state/sample-callbacks.js +5 -2
- package/dist/state/slow-duration-fps.d.ts +2 -0
- package/dist/state/slow-duration-fps.js +18 -0
- package/dist/state/transport-stream.d.ts +8 -0
- package/dist/state/transport-stream.js +11 -0
- package/dist/state/video-section.d.ts +16 -0
- package/dist/state/video-section.js +37 -0
- package/dist/state/webm.d.ts +17 -2
- package/dist/state/webm.js +33 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/webcodec-sample-types.d.ts +3 -3
- package/package.json +3 -3
- package/test.json +663 -0
- package/dist/boxes/iso-base-media/get-children.d.ts +0 -14
- package/dist/boxes/iso-base-media/get-children.js +0 -39
- package/dist/boxes/iso-base-media/mdat/mdat.d.ts +0 -26
- package/dist/boxes/iso-base-media/mdat/mdat.js +0 -141
- package/dist/boxes/iso-base-media/moov/moov.d.ts +0 -19
- package/dist/boxes/iso-base-media/moov/moov.js +0 -27
- package/dist/boxes/iso-base-media/parse-boxes.d.ts +0 -15
- package/dist/boxes/iso-base-media/parse-boxes.js +0 -129
- package/dist/boxes/iso-base-media/parse-mdat-partially.d.ts +0 -12
- package/dist/boxes/iso-base-media/parse-mdat-partially.js +0 -33
- package/dist/boxes/iso-base-media/process-box.d.ts +0 -15
- package/dist/boxes/iso-base-media/stsd/mebx.js +0 -32
- package/dist/boxes/iso-base-media/trak/trak.d.ts +0 -19
- package/dist/boxes/iso-base-media/trak/trak.js +0 -27
- package/dist/boxes/mp3/get-tracks-from-mp3.d.ts +0 -4
- package/dist/boxes/mp3/id3-v2.d.ts +0 -0
- package/dist/boxes/mp3/id3-v2.js +0 -1
- package/dist/boxes/mp3/id3.d.ts +0 -8
- package/dist/boxes/riff/continue-after-riff-result.d.ts +0 -13
- package/dist/boxes/riff/continue-after-riff-result.js +0 -34
- package/dist/boxes/riff/expect-riff-box.d.ts +0 -19
- package/dist/boxes/riff/expect-riff-box.js +0 -50
- package/dist/boxes/riff/parse-box.js +0 -35
- package/dist/boxes/riff/parse-fmt-box.d.ts +0 -7
- package/dist/boxes/riff/parse-fmt-box.js +0 -33
- package/dist/boxes/riff/parse-list-box.d.ts +0 -10
- package/dist/boxes/riff/parse-list-box.js +0 -31
- package/dist/boxes/riff/parse-movi.d.ts +0 -17
- package/dist/boxes/riff/parse-riff-body.d.ts +0 -11
- package/dist/boxes/riff/parse-riff-body.js +0 -105
- package/dist/boxes/riff/parse-riff-box.d.ts +0 -12
- package/dist/boxes/riff/parse-strf.d.ts +0 -7
- package/dist/boxes/transport-stream/get-tracks.d.ts +0 -5
- package/dist/boxes/transport-stream/parse-packet.d.ts +0 -13
- package/dist/boxes/transport-stream/parse-stream-packet.d.ts +0 -15
- package/dist/boxes/transport-stream/parse-transport-stream.d.ts +0 -13
- package/dist/boxes/webm/parse-webm-header.js +0 -37
- package/dist/boxes/webm/segments/parse-children.d.ts +0 -23
- package/dist/boxes/webm/segments/parse-children.js +0 -144
- package/dist/boxes/webm/segments.d.ts +0 -15
- package/dist/boxes/webm/segments.js +0 -161
- package/dist/continue-mdat-routine.d.ts +0 -17
- package/dist/continue-mdat-routine.js +0 -92
- package/dist/parse-video.d.ts +0 -28
- package/dist/parse-video.js +0 -130
- /package/dist/{boxes/iso-base-media/base-type.js → containers/aac/types.js} +0 -0
- /package/dist/{boxes → containers}/avc/codec-string.d.ts +0 -0
- /package/dist/{boxes → containers}/avc/codec-string.js +0 -0
- /package/dist/{boxes → containers}/avc/color.d.ts +0 -0
- /package/dist/{boxes → containers}/avc/color.js +0 -0
- /package/dist/{boxes → containers}/avc/create-sps-pps-data.d.ts +0 -0
- /package/dist/{boxes → containers}/avc/create-sps-pps-data.js +0 -0
- /package/dist/{boxes → containers}/avc/interpret-sps.d.ts +0 -0
- /package/dist/{boxes → containers}/avc/interpret-sps.js +0 -0
- /package/dist/{boxes → containers}/avc/key.js +0 -0
- /package/dist/{boxes → containers}/avc/parse-avc.d.ts +0 -0
- /package/dist/{boxes → containers}/avc/parse-avc.js +0 -0
- /package/dist/{boxes → containers}/avc/sps-and-pps.d.ts +0 -0
- /package/dist/{boxes → containers}/avc/sps-and-pps.js +0 -0
- /package/dist/{boxes/iso-base-media/void-box.js → containers/flac/types.js} +0 -0
- /package/dist/{boxes/riff/riff-box.js → containers/iso-base-media/base-media-box.js} +0 -0
- /package/dist/{boxes → containers}/iso-base-media/base-type.d.ts +0 -0
- /package/dist/{boxes/transport-stream/boxes.js → containers/iso-base-media/base-type.js} +0 -0
- /package/dist/{boxes → containers}/iso-base-media/esds/decoder-specific-config.d.ts +0 -0
- /package/dist/{boxes → containers}/iso-base-media/esds/decoder-specific-config.js +0 -0
- /package/dist/{boxes → containers}/iso-base-media/esds/esds-descriptors.d.ts +0 -0
- /package/dist/{boxes → containers}/iso-base-media/esds/esds-descriptors.js +0 -0
- /package/dist/{boxes → containers}/iso-base-media/esds/esds.d.ts +0 -0
- /package/dist/{boxes → containers}/iso-base-media/esds/esds.js +0 -0
- /package/dist/{boxes → containers}/iso-base-media/ftyp.d.ts +0 -0
- /package/dist/{boxes → containers}/iso-base-media/ftyp.js +0 -0
- /package/dist/{boxes → containers}/iso-base-media/get-actual-number-of-channels.d.ts +0 -0
- /package/dist/{boxes → containers}/iso-base-media/get-actual-number-of-channels.js +0 -0
- /package/dist/{boxes → containers}/iso-base-media/get-keyframes.d.ts +0 -0
- /package/dist/{boxes → containers}/iso-base-media/get-keyframes.js +0 -0
- /package/dist/{boxes → containers}/iso-base-media/get-sample-positions-from-track.js +0 -0
- /package/dist/{boxes → containers}/iso-base-media/get-video-codec-from-iso-track.d.ts +0 -0
- /package/dist/{boxes → containers}/iso-base-media/get-video-codec-from-iso-track.js +0 -0
- /package/dist/{boxes → containers}/iso-base-media/make-track.d.ts +0 -0
- /package/dist/{boxes → containers}/iso-base-media/make-track.js +0 -0
- /package/dist/{boxes → containers}/iso-base-media/mdhd.d.ts +0 -0
- /package/dist/{boxes → containers}/iso-base-media/mdhd.js +0 -0
- /package/dist/{boxes → containers}/iso-base-media/meta/hdlr.d.ts +0 -0
- /package/dist/{boxes → containers}/iso-base-media/meta/hdlr.js +0 -0
- /package/dist/{boxes → containers}/iso-base-media/meta/ilst.d.ts +0 -0
- /package/dist/{boxes → containers}/iso-base-media/meta/ilst.js +0 -0
- /package/dist/{boxes → containers}/iso-base-media/mvhd.d.ts +0 -0
- /package/dist/{boxes → containers}/iso-base-media/mvhd.js +0 -0
- /package/dist/{boxes → containers}/iso-base-media/parse-icc-profile.d.ts +0 -0
- /package/dist/{boxes → containers}/iso-base-media/parse-icc-profile.js +0 -0
- /package/dist/{boxes → containers}/iso-base-media/stsd/av1c.d.ts +0 -0
- /package/dist/{boxes → containers}/iso-base-media/stsd/av1c.js +0 -0
- /package/dist/{boxes → containers}/iso-base-media/stsd/avcc.d.ts +0 -0
- /package/dist/{boxes → containers}/iso-base-media/stsd/avcc.js +0 -0
- /package/dist/{boxes → containers}/iso-base-media/stsd/colr.d.ts +0 -0
- /package/dist/{boxes → containers}/iso-base-media/stsd/colr.js +0 -0
- /package/dist/{boxes → containers}/iso-base-media/stsd/ctts.d.ts +0 -0
- /package/dist/{boxes → containers}/iso-base-media/stsd/ctts.js +0 -0
- /package/dist/{boxes → containers}/iso-base-media/stsd/hvcc.d.ts +0 -0
- /package/dist/{boxes → containers}/iso-base-media/stsd/hvcc.js +0 -0
- /package/dist/{boxes → containers}/iso-base-media/stsd/keys.d.ts +0 -0
- /package/dist/{boxes → containers}/iso-base-media/stsd/keys.js +0 -0
- /package/dist/{boxes → containers}/iso-base-media/stsd/pasp.d.ts +0 -0
- /package/dist/{boxes → containers}/iso-base-media/stsd/pasp.js +0 -0
- /package/dist/{boxes → containers}/iso-base-media/stsd/stco.d.ts +0 -0
- /package/dist/{boxes → containers}/iso-base-media/stsd/stco.js +0 -0
- /package/dist/{boxes → containers}/iso-base-media/stsd/stsc.d.ts +0 -0
- /package/dist/{boxes → containers}/iso-base-media/stsd/stsc.js +0 -0
- /package/dist/{boxes → containers}/iso-base-media/stsd/stss.d.ts +0 -0
- /package/dist/{boxes → containers}/iso-base-media/stsd/stss.js +0 -0
- /package/dist/{boxes → containers}/iso-base-media/stsd/stsz.d.ts +0 -0
- /package/dist/{boxes → containers}/iso-base-media/stsd/stsz.js +0 -0
- /package/dist/{boxes → containers}/iso-base-media/stsd/stts.d.ts +0 -0
- /package/dist/{boxes → containers}/iso-base-media/stsd/stts.js +0 -0
- /package/dist/{boxes → containers}/iso-base-media/tfdt.d.ts +0 -0
- /package/dist/{boxes → containers}/iso-base-media/tfdt.js +0 -0
- /package/dist/{boxes → containers}/iso-base-media/tfhd.d.ts +0 -0
- /package/dist/{boxes → containers}/iso-base-media/tfhd.js +0 -0
- /package/dist/{boxes → containers}/iso-base-media/tkhd.d.ts +0 -0
- /package/dist/{boxes → containers}/iso-base-media/tkhd.js +0 -0
- /package/dist/{boxes → containers}/iso-base-media/to-date.d.ts +0 -0
- /package/dist/{boxes → containers}/iso-base-media/to-date.js +0 -0
- /package/dist/{boxes → containers}/iso-base-media/trun.d.ts +0 -0
- /package/dist/{boxes → containers}/iso-base-media/trun.js +0 -0
- /package/dist/{boxes → containers}/iso-base-media/void-box.d.ts +0 -0
- /package/dist/{boxes → containers}/mp3/get-duration.d.ts +0 -0
- /package/dist/{boxes → containers}/mp3/get-duration.js +0 -0
- /package/dist/{boxes → containers}/mp3/get-frame-length.d.ts +0 -0
- /package/dist/{boxes → containers}/mp3/get-frame-length.js +0 -0
- /package/dist/{boxes → containers}/mp3/get-metadata-from-mp3.d.ts +0 -0
- /package/dist/{boxes → containers}/mp3/get-metadata-from-mp3.js +0 -0
- /package/dist/{boxes → containers}/mp3/id3-v1.d.ts +0 -0
- /package/dist/{boxes → containers}/mp3/id3-v1.js +0 -0
- /package/dist/{boxes → containers}/mp3/samples-per-mpeg-file.d.ts +0 -0
- /package/dist/{boxes → containers}/mp3/samples-per-mpeg-file.js +0 -0
- /package/dist/{boxes → containers}/riff/is-movi.d.ts +0 -0
- /package/dist/{boxes → containers}/riff/is-movi.js +0 -0
- /package/dist/{boxes → containers}/riff/parse-avih.d.ts +0 -0
- /package/dist/{boxes → containers}/riff/parse-avih.js +0 -0
- /package/dist/{boxes → containers}/riff/parse-isft.d.ts +0 -0
- /package/dist/{boxes → containers}/riff/parse-isft.js +0 -0
- /package/dist/{boxes → containers}/riff/parse-strh.d.ts +0 -0
- /package/dist/{boxes → containers}/riff/timescale.d.ts +0 -0
- /package/dist/{boxes → containers}/riff/timescale.js +0 -0
- /package/dist/{boxes → containers}/transport-stream/adts-header.d.ts +0 -0
- /package/dist/{boxes → containers}/transport-stream/adts-header.js +0 -0
- /package/dist/{boxes → containers}/transport-stream/boxes.d.ts +0 -0
- /package/dist/{boxes → containers}/transport-stream/discard-rest-of-packet.d.ts +0 -0
- /package/dist/{boxes → containers}/transport-stream/discard-rest-of-packet.js +0 -0
- /package/dist/{boxes → containers}/transport-stream/find-separator.d.ts +0 -0
- /package/dist/{boxes → containers}/transport-stream/find-separator.js +0 -0
- /package/dist/{boxes → containers}/transport-stream/handle-aac-packet.d.ts +0 -0
- /package/dist/{boxes → containers}/transport-stream/handle-aac-packet.js +0 -0
- /package/dist/{boxes → containers}/transport-stream/handle-avc-packet.d.ts +0 -0
- /package/dist/{boxes → containers}/transport-stream/handle-avc-packet.js +0 -0
- /package/dist/{boxes → containers}/transport-stream/next-pes-header-store.d.ts +0 -0
- /package/dist/{boxes → containers}/transport-stream/next-pes-header-store.js +0 -0
- /package/dist/{boxes → containers}/transport-stream/parse-pat.d.ts +0 -0
- /package/dist/{boxes → containers}/transport-stream/parse-pat.js +0 -0
- /package/dist/{boxes → containers}/transport-stream/parse-pes.d.ts +0 -0
- /package/dist/{boxes → containers}/transport-stream/parse-pes.js +0 -0
- /package/dist/{boxes → containers}/transport-stream/parse-pmt.d.ts +0 -0
- /package/dist/{boxes → containers}/transport-stream/parse-pmt.js +0 -0
- /package/dist/{boxes → containers}/transport-stream/traversal.d.ts +0 -0
- /package/dist/{boxes → containers}/transport-stream/traversal.js +0 -0
- /package/dist/{boxes → containers}/webm/allowed-partial-segments.d.ts +0 -0
- /package/dist/{boxes → containers}/webm/allowed-partial-segments.js +0 -0
- /package/dist/{boxes → containers}/webm/av1-codec-private.d.ts +0 -0
- /package/dist/{boxes → containers}/webm/av1-codec-private.js +0 -0
- /package/dist/{boxes → containers}/webm/color.d.ts +0 -0
- /package/dist/{boxes → containers}/webm/color.js +0 -0
- /package/dist/{boxes → containers}/webm/description.d.ts +0 -0
- /package/dist/{boxes → containers}/webm/description.js +0 -0
- /package/dist/{boxes → containers}/webm/get-ready-tracks.d.ts +0 -0
- /package/dist/{boxes → containers}/webm/get-ready-tracks.js +0 -0
- /package/dist/{boxes → containers}/webm/get-sample-from-block.d.ts +0 -0
- /package/dist/{boxes → containers}/webm/get-sample-from-block.js +0 -0
- /package/dist/{boxes → containers}/webm/make-track.d.ts +0 -0
- /package/dist/{boxes → containers}/webm/make-track.js +0 -0
- /package/dist/{boxes → containers}/webm/segments/all-segments.d.ts +0 -0
- /package/dist/{boxes → containers}/webm/segments/all-segments.js +0 -0
- /package/dist/{boxes → containers}/webm/segments/block-simple-block-flags.d.ts +0 -0
- /package/dist/{boxes → containers}/webm/segments/block-simple-block-flags.js +0 -0
- /package/dist/{boxes → containers}/webm/segments/track-entry.d.ts +0 -0
- /package/dist/{boxes → containers}/webm/segments/track-entry.js +0 -0
- /package/dist/{boxes → containers}/webm/traversal.d.ts +0 -0
- /package/dist/{boxes → containers}/webm/traversal.js +0 -0
- /package/dist/{may-skip-video-data → state}/need-samples-for-fields.d.ts +0 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseFlacFrame = exports.parseFrameHeader = void 0;
|
|
4
|
+
const buffer_iterator_1 = require("../../buffer-iterator");
|
|
5
|
+
const convert_audio_or_video_sample_1 = require("../../convert-audio-or-video-sample");
|
|
6
|
+
const get_block_size_1 = require("./get-block-size");
|
|
7
|
+
const get_channel_count_1 = require("./get-channel-count");
|
|
8
|
+
const get_sample_rate_1 = require("./get-sample-rate");
|
|
9
|
+
// https://www.rfc-editor.org/rfc/rfc9639.html#section-9.1.1
|
|
10
|
+
function calculateCRC8(data) {
|
|
11
|
+
const polynomial = 0x07; // x^8 + x^2 + x^1 + x^0
|
|
12
|
+
let crc = 0x00; // Initialize CRC to 0
|
|
13
|
+
for (const byte of data) {
|
|
14
|
+
crc ^= byte; // XOR byte into least significant byte of crc
|
|
15
|
+
for (let i = 0; i < 8; i++) {
|
|
16
|
+
// For each bit in the byte
|
|
17
|
+
if ((crc & 0x80) !== 0) {
|
|
18
|
+
// If the leftmost bit (MSB) is set
|
|
19
|
+
crc = (crc << 1) ^ polynomial; // Shift left and XOR with polynomial
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
crc <<= 1; // Just shift left
|
|
23
|
+
}
|
|
24
|
+
crc &= 0xff; // Ensure CRC remains 8-bit
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return crc;
|
|
28
|
+
}
|
|
29
|
+
const parseFrameHeader = ({ iterator, state, }) => {
|
|
30
|
+
if (iterator.bytesRemaining() < 10) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
const startOffset = iterator.counter.getOffset();
|
|
34
|
+
iterator.discard(2); // sync code
|
|
35
|
+
iterator.startReadingBits();
|
|
36
|
+
const blockSizeBits = (0, get_block_size_1.getBlockSize)(iterator);
|
|
37
|
+
const sampleRateBits = (0, get_sample_rate_1.getSampleRate)(iterator, state);
|
|
38
|
+
(0, get_channel_count_1.getChannelCount)(iterator); // channel count
|
|
39
|
+
iterator.getBits(3); // bit depth
|
|
40
|
+
iterator.getBits(1);
|
|
41
|
+
const num = iterator.getFlacCodecNumber();
|
|
42
|
+
const blockSize = blockSizeBits === 'uncommon-u16'
|
|
43
|
+
? iterator.getBits(16) + 1
|
|
44
|
+
: blockSizeBits === 'uncommon-u8'
|
|
45
|
+
? iterator.getBits(8) + 1
|
|
46
|
+
: blockSizeBits;
|
|
47
|
+
const sampleRate = sampleRateBits === 'uncommon-u16'
|
|
48
|
+
? iterator.getBits(16)
|
|
49
|
+
: sampleRateBits === 'uncommon-u16-10'
|
|
50
|
+
? iterator.getBits(16) * 10
|
|
51
|
+
: sampleRateBits === 'uncommon-u8'
|
|
52
|
+
? iterator.getBits(8)
|
|
53
|
+
: sampleRateBits;
|
|
54
|
+
iterator.stopReadingBits();
|
|
55
|
+
const size = iterator.counter.getOffset() - startOffset;
|
|
56
|
+
const crc = iterator.getUint8();
|
|
57
|
+
iterator.counter.decrement(size + 1);
|
|
58
|
+
const crcCalculated = calculateCRC8(iterator.getSlice(size));
|
|
59
|
+
iterator.counter.decrement(size);
|
|
60
|
+
if (crcCalculated !== crc) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
return { num, blockSize, sampleRate };
|
|
64
|
+
};
|
|
65
|
+
exports.parseFrameHeader = parseFrameHeader;
|
|
66
|
+
const emitSample = async ({ state, data, offset, }) => {
|
|
67
|
+
const iterator = (0, buffer_iterator_1.getArrayBufferIterator)(data, null);
|
|
68
|
+
const parsed = (0, exports.parseFrameHeader)({ iterator, state });
|
|
69
|
+
if (!parsed) {
|
|
70
|
+
throw new Error('Invalid CRC');
|
|
71
|
+
}
|
|
72
|
+
const { blockSize, num, sampleRate } = parsed;
|
|
73
|
+
const duration = blockSize / sampleRate;
|
|
74
|
+
const structure = state.structure.getStructure();
|
|
75
|
+
const streamInfo = structure.boxes.find((box) => box.type === 'flac-streaminfo');
|
|
76
|
+
if (!streamInfo) {
|
|
77
|
+
throw new Error('Stream info not found');
|
|
78
|
+
}
|
|
79
|
+
if (streamInfo.minimumBlockSize !== streamInfo.maximumBlockSize) {
|
|
80
|
+
throw new Error('Cannot determine timestamp');
|
|
81
|
+
}
|
|
82
|
+
const timestamp = (num * streamInfo.maximumBlockSize) / streamInfo.sampleRate;
|
|
83
|
+
await state.callbacks.onAudioSample(0, (0, convert_audio_or_video_sample_1.convertAudioOrVideoSampleToWebCodecsTimestamps)({
|
|
84
|
+
data,
|
|
85
|
+
duration,
|
|
86
|
+
cts: timestamp,
|
|
87
|
+
dts: timestamp,
|
|
88
|
+
timestamp,
|
|
89
|
+
type: 'key',
|
|
90
|
+
offset,
|
|
91
|
+
timescale: 1000000,
|
|
92
|
+
trackId: 0,
|
|
93
|
+
}, 1));
|
|
94
|
+
iterator.destroy();
|
|
95
|
+
};
|
|
96
|
+
const parseFlacFrame = async ({ state, iterator, }) => {
|
|
97
|
+
var _a, _b;
|
|
98
|
+
const blockingBit = state.flac.getBlockingBitStrategy();
|
|
99
|
+
const offset = iterator.counter.getOffset();
|
|
100
|
+
const { returnToCheckpoint } = iterator.startCheckpoint();
|
|
101
|
+
iterator.startReadingBits();
|
|
102
|
+
if (blockingBit === undefined) {
|
|
103
|
+
const bits = iterator.getBits(15);
|
|
104
|
+
if (bits !== 0b111111111111100) {
|
|
105
|
+
throw new Error('Invalid sync code');
|
|
106
|
+
}
|
|
107
|
+
state.flac.setBlockingBitStrategy(iterator.getBits(1));
|
|
108
|
+
}
|
|
109
|
+
else if (blockingBit === 1) {
|
|
110
|
+
const bits = iterator.getBits(16);
|
|
111
|
+
if (bits !== 0b1111111111111001) {
|
|
112
|
+
throw new Error('Blocking bit changed, it should not');
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
else if (blockingBit === 0) {
|
|
116
|
+
const bits = iterator.getBits(16);
|
|
117
|
+
if (bits !== 0b1111111111111000) {
|
|
118
|
+
throw new Error('Blocking bit changed, it should not');
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const setBlockingBit = state.flac.getBlockingBitStrategy();
|
|
122
|
+
if (setBlockingBit === undefined) {
|
|
123
|
+
throw new Error('Blocking bit should be set');
|
|
124
|
+
}
|
|
125
|
+
iterator.stopReadingBits();
|
|
126
|
+
const structure = state.structure.getStructure();
|
|
127
|
+
if (structure.type !== 'flac') {
|
|
128
|
+
throw new Error('Expected flac-structure');
|
|
129
|
+
}
|
|
130
|
+
const minimumFrameSize = (_b = (_a = structure.boxes.find((b) => b.type === 'flac-streaminfo')) === null || _a === void 0 ? void 0 : _a.minimumFrameSize) !== null && _b !== void 0 ? _b : null;
|
|
131
|
+
if (minimumFrameSize === null) {
|
|
132
|
+
throw new Error('Expected flac-streaminfo');
|
|
133
|
+
}
|
|
134
|
+
if (minimumFrameSize !== 0) {
|
|
135
|
+
iterator.getSlice(minimumFrameSize - 2);
|
|
136
|
+
}
|
|
137
|
+
while (true) {
|
|
138
|
+
if (!state.contentLength) {
|
|
139
|
+
throw new Error('Need content-length for FLAC to parse');
|
|
140
|
+
}
|
|
141
|
+
if (iterator.counter.getOffset() === state.contentLength) {
|
|
142
|
+
const size = iterator.counter.getOffset() - offset;
|
|
143
|
+
returnToCheckpoint();
|
|
144
|
+
const slice = iterator.getSlice(size);
|
|
145
|
+
await emitSample({ state, data: slice, offset });
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
if (iterator.bytesRemaining() === 0) {
|
|
149
|
+
returnToCheckpoint();
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
const nextByte = iterator.getUint8();
|
|
153
|
+
if (nextByte === 0xff) {
|
|
154
|
+
const nextBits = iterator.getUint8();
|
|
155
|
+
const expected = setBlockingBit === 1 ? 249 : 248;
|
|
156
|
+
if (nextBits !== expected) {
|
|
157
|
+
iterator.counter.decrement(1);
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
iterator.counter.decrement(2);
|
|
161
|
+
const nextIsLegit = (0, exports.parseFrameHeader)({ iterator, state });
|
|
162
|
+
if (!nextIsLegit) {
|
|
163
|
+
iterator.discard(1);
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
const size = iterator.counter.getOffset() - offset;
|
|
167
|
+
returnToCheckpoint();
|
|
168
|
+
const data = iterator.getSlice(size);
|
|
169
|
+
await emitSample({ state, data, offset });
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return { skipTo: null };
|
|
174
|
+
};
|
|
175
|
+
exports.parseFlacFrame = parseFlacFrame;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { BufferIterator } from '../../buffer-iterator';
|
|
2
|
-
import type { Options, ParseMediaFields } from '../../options';
|
|
3
2
|
import type { ParseResult } from '../../parse-result';
|
|
4
3
|
import type { ParserState } from '../../state/parser-state';
|
|
5
|
-
export declare const
|
|
4
|
+
export declare const parseFlac: ({ iterator, state, }: {
|
|
6
5
|
iterator: BufferIterator;
|
|
7
6
|
state: ParserState;
|
|
8
|
-
fields: Options<ParseMediaFields>;
|
|
9
7
|
}) => Promise<ParseResult>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseFlac = void 0;
|
|
4
|
+
const may_skip_video_data_1 = require("../../state/may-skip-video-data");
|
|
5
|
+
const parse_flac_frame_1 = require("./parse-flac-frame");
|
|
6
|
+
const parse_header_1 = require("./parse-header");
|
|
7
|
+
const parse_metadata_1 = require("./parse-metadata");
|
|
8
|
+
const parse_streaminfo_1 = require("./parse-streaminfo");
|
|
9
|
+
const parse_unknown_block_1 = require("./parse-unknown-block");
|
|
10
|
+
const flacTypes = {
|
|
11
|
+
streaminfo: 0,
|
|
12
|
+
vorbisComment: 4,
|
|
13
|
+
};
|
|
14
|
+
const parseFlac = ({ iterator, state, }) => {
|
|
15
|
+
const videoSectionState = state.videoSection.isInVideoSectionState(iterator);
|
|
16
|
+
if (videoSectionState === 'in-section') {
|
|
17
|
+
if ((0, may_skip_video_data_1.maySkipVideoData)({ state })) {
|
|
18
|
+
if (!state.contentLength) {
|
|
19
|
+
throw new Error('Need content-length for FLAC to parse');
|
|
20
|
+
}
|
|
21
|
+
return Promise.resolve({ skipTo: state.contentLength });
|
|
22
|
+
}
|
|
23
|
+
return (0, parse_flac_frame_1.parseFlacFrame)({ state, iterator });
|
|
24
|
+
}
|
|
25
|
+
const bytes = iterator.getByteString(4, true);
|
|
26
|
+
if (bytes === 'fLaC') {
|
|
27
|
+
return (0, parse_header_1.parseFlacHeader)({ state, iterator });
|
|
28
|
+
}
|
|
29
|
+
iterator.counter.decrement(4);
|
|
30
|
+
// https://www.rfc-editor.org/rfc/rfc9639.html#name-streaminfo
|
|
31
|
+
// section 8.1
|
|
32
|
+
iterator.startReadingBits();
|
|
33
|
+
const isLastMetadata = iterator.getBits(1);
|
|
34
|
+
const metaBlockType = iterator.getBits(7);
|
|
35
|
+
iterator.stopReadingBits();
|
|
36
|
+
const size = iterator.getUint24();
|
|
37
|
+
if (isLastMetadata) {
|
|
38
|
+
if (!state.contentLength) {
|
|
39
|
+
throw new Error('Need content-length for FLAC to parse');
|
|
40
|
+
}
|
|
41
|
+
state.videoSection.setVideoSection({
|
|
42
|
+
start: iterator.counter.getOffset() + size,
|
|
43
|
+
size: state.contentLength - iterator.counter.getOffset() - size,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
if (metaBlockType === flacTypes.streaminfo) {
|
|
47
|
+
return (0, parse_streaminfo_1.parseStreamInfo)({ iterator, state });
|
|
48
|
+
}
|
|
49
|
+
if (metaBlockType === flacTypes.vorbisComment) {
|
|
50
|
+
return (0, parse_metadata_1.parseVorbisComment)({ iterator, state, size });
|
|
51
|
+
}
|
|
52
|
+
return (0, parse_unknown_block_1.parseFlacUnkownBlock)({ iterator, state, size });
|
|
53
|
+
};
|
|
54
|
+
exports.parseFlac = parseFlac;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { BufferIterator } from '../../buffer-iterator';
|
|
2
|
+
import type { ParseResult } from '../../parse-result';
|
|
2
3
|
import type { ParserState } from '../../state/parser-state';
|
|
3
|
-
export declare const
|
|
4
|
-
iterator: BufferIterator;
|
|
4
|
+
export declare const parseFlacHeader: ({ state, }: {
|
|
5
5
|
state: ParserState;
|
|
6
|
-
|
|
6
|
+
iterator: BufferIterator;
|
|
7
|
+
}) => Promise<ParseResult>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseFlacHeader = void 0;
|
|
4
|
+
const parseFlacHeader = ({ state, }) => {
|
|
5
|
+
state.structure.getStructure().boxes.push({
|
|
6
|
+
type: 'flac-header',
|
|
7
|
+
});
|
|
8
|
+
return Promise.resolve({ skipTo: null });
|
|
9
|
+
};
|
|
10
|
+
exports.parseFlacHeader = parseFlacHeader;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { BufferIterator } from '../../buffer-iterator';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ParseResult } from '../../parse-result';
|
|
3
3
|
import type { ParserState } from '../../state/parser-state';
|
|
4
|
-
export declare const
|
|
5
|
-
iterator: BufferIterator;
|
|
6
|
-
structure: Mp3Structure;
|
|
4
|
+
export declare const parseVorbisComment: ({ state, iterator, size, }: {
|
|
7
5
|
state: ParserState;
|
|
6
|
+
iterator: BufferIterator;
|
|
7
|
+
size: number;
|
|
8
8
|
}) => Promise<ParseResult>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseVorbisComment = void 0;
|
|
4
|
+
const parseVorbisComment = ({ state, iterator, size, }) => {
|
|
5
|
+
const { expectNoMoreBytes } = iterator.startBox(size);
|
|
6
|
+
const box = {
|
|
7
|
+
type: 'flac-vorbis-comment',
|
|
8
|
+
fields: [],
|
|
9
|
+
};
|
|
10
|
+
const vendorLength = iterator.getUint32Le();
|
|
11
|
+
const vendorString = iterator.getByteString(vendorLength, true);
|
|
12
|
+
const numberOfFields = iterator.getUint32Le();
|
|
13
|
+
box.fields.push({ key: 'vendor', value: vendorString, trackId: null });
|
|
14
|
+
for (let i = 0; i < numberOfFields; i++) {
|
|
15
|
+
const fieldLength = iterator.getUint32Le();
|
|
16
|
+
const field = iterator.getByteString(fieldLength, true);
|
|
17
|
+
const [key, value] = field.split('=');
|
|
18
|
+
box.fields.push({ key: key.toLowerCase(), value, trackId: null });
|
|
19
|
+
}
|
|
20
|
+
state.structure.getStructure().boxes.push(box);
|
|
21
|
+
expectNoMoreBytes();
|
|
22
|
+
return Promise.resolve({ skipTo: null });
|
|
23
|
+
};
|
|
24
|
+
exports.parseVorbisComment = parseVorbisComment;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { BufferIterator } from '../../buffer-iterator';
|
|
2
|
-
import type { Options, ParseMediaFields } from '../../options';
|
|
3
2
|
import type { ParseResult } from '../../parse-result';
|
|
4
3
|
import type { ParserState } from '../../state/parser-state';
|
|
5
|
-
export declare const
|
|
6
|
-
|
|
4
|
+
export declare const parseStreamInfo: ({ iterator, state, }: {
|
|
5
|
+
iterator: BufferIterator;
|
|
7
6
|
state: ParserState;
|
|
8
|
-
fields: Options<ParseMediaFields>;
|
|
9
7
|
}) => Promise<ParseResult>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseStreamInfo = void 0;
|
|
4
|
+
const register_track_1 = require("../../register-track");
|
|
5
|
+
const parseStreamInfo = async ({ iterator, state, }) => {
|
|
6
|
+
const counter = iterator.counter.getOffset();
|
|
7
|
+
const minimumBlockSize = iterator.getUint16();
|
|
8
|
+
const maximumBlockSize = iterator.getUint16();
|
|
9
|
+
const minimumFrameSize = iterator.getUint24();
|
|
10
|
+
const maximumFrameSize = iterator.getUint24();
|
|
11
|
+
iterator.startReadingBits();
|
|
12
|
+
const sampleRate = iterator.getBits(20);
|
|
13
|
+
const channels = iterator.getBits(3) + 1;
|
|
14
|
+
const bitsPerSample = iterator.getBits(5);
|
|
15
|
+
const totalSamples = iterator.getBits(36);
|
|
16
|
+
iterator.getBits(128); // md5
|
|
17
|
+
iterator.stopReadingBits();
|
|
18
|
+
const counterNow = iterator.counter.getOffset();
|
|
19
|
+
const size = counterNow - counter;
|
|
20
|
+
iterator.counter.decrement(size);
|
|
21
|
+
const asUint8Array = iterator.getSlice(size);
|
|
22
|
+
const flacStreamInfo = {
|
|
23
|
+
type: 'flac-streaminfo',
|
|
24
|
+
bitsPerSample,
|
|
25
|
+
channels,
|
|
26
|
+
maximumBlockSize,
|
|
27
|
+
maximumFrameSize,
|
|
28
|
+
minimumBlockSize,
|
|
29
|
+
minimumFrameSize,
|
|
30
|
+
sampleRate,
|
|
31
|
+
totalSamples,
|
|
32
|
+
};
|
|
33
|
+
state.structure.getStructure().boxes.push(flacStreamInfo);
|
|
34
|
+
await (0, register_track_1.registerTrack)({
|
|
35
|
+
container: 'flac',
|
|
36
|
+
state,
|
|
37
|
+
track: {
|
|
38
|
+
codec: 'flac',
|
|
39
|
+
type: 'audio',
|
|
40
|
+
description: asUint8Array,
|
|
41
|
+
codecPrivate: asUint8Array,
|
|
42
|
+
codecWithoutConfig: 'flac',
|
|
43
|
+
numberOfChannels: channels,
|
|
44
|
+
sampleRate,
|
|
45
|
+
timescale: 1000000,
|
|
46
|
+
trackId: 0,
|
|
47
|
+
trakBox: null,
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
state.callbacks.tracks.setIsDone();
|
|
51
|
+
return Promise.resolve({ skipTo: null });
|
|
52
|
+
};
|
|
53
|
+
exports.parseStreamInfo = parseStreamInfo;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { BufferIterator } from '../../buffer-iterator';
|
|
2
|
+
import type { ParseResult } from '../../parse-result';
|
|
3
|
+
import type { ParserState } from '../../state/parser-state';
|
|
4
|
+
export declare const parseFlacUnkownBlock: ({ iterator, state, size, }: {
|
|
5
|
+
iterator: BufferIterator;
|
|
6
|
+
state: ParserState;
|
|
7
|
+
size: number;
|
|
8
|
+
}) => Promise<ParseResult>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseFlacUnkownBlock = void 0;
|
|
4
|
+
const parseFlacUnkownBlock = ({ iterator, state, size, }) => {
|
|
5
|
+
iterator.discard(size);
|
|
6
|
+
state.structure.getStructure().boxes.push({
|
|
7
|
+
type: 'flac-header',
|
|
8
|
+
});
|
|
9
|
+
return Promise.resolve({ skipTo: null });
|
|
10
|
+
};
|
|
11
|
+
exports.parseFlacUnkownBlock = parseFlacUnkownBlock;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { MetadataEntry } from '../../metadata/get-metadata';
|
|
2
|
+
export type FlacHeader = {
|
|
3
|
+
type: 'flac-header';
|
|
4
|
+
};
|
|
5
|
+
export type FlacStreamInfo = {
|
|
6
|
+
type: 'flac-streaminfo';
|
|
7
|
+
minimumBlockSize: number;
|
|
8
|
+
maximumBlockSize: number;
|
|
9
|
+
minimumFrameSize: number;
|
|
10
|
+
maximumFrameSize: number;
|
|
11
|
+
sampleRate: number;
|
|
12
|
+
channels: number;
|
|
13
|
+
bitsPerSample: number;
|
|
14
|
+
totalSamples: number;
|
|
15
|
+
};
|
|
16
|
+
export type FlacVorbisComment = {
|
|
17
|
+
type: 'flac-vorbis-comment';
|
|
18
|
+
fields: MetadataEntry[];
|
|
19
|
+
};
|
|
20
|
+
export type FlacUnknownBlock = {
|
|
21
|
+
type: 'flac-unknown-block';
|
|
22
|
+
};
|
|
23
|
+
export type FlacStructure = {
|
|
24
|
+
type: 'flac';
|
|
25
|
+
boxes: (FlacHeader | FlacStreamInfo | FlacUnknownBlock | FlacVorbisComment)[];
|
|
26
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { BaseBox } from './base-type';
|
|
2
|
+
import type { EsdsBox } from './esds/esds';
|
|
3
|
+
import type { FtypBox } from './ftyp';
|
|
4
|
+
import type { MdhdBox } from './mdhd';
|
|
5
|
+
import type { HdlrBox } from './meta/hdlr';
|
|
6
|
+
import type { IlstBox } from './meta/ilst';
|
|
7
|
+
import type { MoovBox } from './moov/moov';
|
|
8
|
+
import type { MvhdBox } from './mvhd';
|
|
9
|
+
import type { Av1CBox } from './stsd/av1c';
|
|
10
|
+
import type { AvccBox } from './stsd/avcc';
|
|
11
|
+
import type { ColorParameterBox } from './stsd/colr';
|
|
12
|
+
import type { CttsBox } from './stsd/ctts';
|
|
13
|
+
import type { HvccBox } from './stsd/hvcc';
|
|
14
|
+
import type { KeysBox } from './stsd/keys';
|
|
15
|
+
import type { MebxBox } from './stsd/mebx';
|
|
16
|
+
import type { PaspBox } from './stsd/pasp';
|
|
17
|
+
import type { StcoBox } from './stsd/stco';
|
|
18
|
+
import type { StscBox } from './stsd/stsc';
|
|
19
|
+
import type { StsdBox } from './stsd/stsd';
|
|
20
|
+
import type { StssBox } from './stsd/stss';
|
|
21
|
+
import type { StszBox } from './stsd/stsz';
|
|
22
|
+
import type { SttsBox } from './stsd/stts';
|
|
23
|
+
import type { TfdtBox } from './tfdt';
|
|
24
|
+
import type { TfhdBox } from './tfhd';
|
|
25
|
+
import type { TkhdBox } from './tkhd';
|
|
26
|
+
import type { TrakBox } from './trak/trak';
|
|
27
|
+
import type { TrunBox } from './trun';
|
|
28
|
+
import type { VoidBox } from './void-box';
|
|
29
|
+
export interface RegularBox extends BaseBox {
|
|
30
|
+
boxType: string;
|
|
31
|
+
boxSize: number;
|
|
32
|
+
children: IsoBaseMediaBox[];
|
|
33
|
+
offset: number;
|
|
34
|
+
type: 'regular-box';
|
|
35
|
+
}
|
|
36
|
+
export type BoxAndNext = {
|
|
37
|
+
box: IsoBaseMediaBox | null;
|
|
38
|
+
skipTo: number | null;
|
|
39
|
+
};
|
|
40
|
+
export type IsoBaseMediaBox = RegularBox | FtypBox | MvhdBox | TkhdBox | StsdBox | MebxBox | KeysBox | MoovBox | TrakBox | SttsBox | MdhdBox | IlstBox | EsdsBox | StszBox | StcoBox | StscBox | AvccBox | HvccBox | VoidBox | StssBox | PaspBox | CttsBox | Av1CBox | TrunBox | HdlrBox | ColorParameterBox | TfdtBox | TfhdBox;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getIsoBaseMediaChildren = void 0;
|
|
4
|
+
const process_box_1 = require("./process-box");
|
|
5
|
+
const getIsoBaseMediaChildren = async ({ state, size, }) => {
|
|
6
|
+
const boxes = [];
|
|
7
|
+
const { iterator } = state;
|
|
8
|
+
const initial = iterator.counter.getOffset();
|
|
9
|
+
while (iterator.counter.getOffset() < size + initial) {
|
|
10
|
+
const parsed = await (0, process_box_1.processBox)(state);
|
|
11
|
+
if (!parsed.box) {
|
|
12
|
+
throw new Error('Expected box');
|
|
13
|
+
}
|
|
14
|
+
boxes.push(parsed.box);
|
|
15
|
+
}
|
|
16
|
+
if (iterator.counter.getOffset() > size + initial) {
|
|
17
|
+
throw new Error(`read too many bytes - size: ${size}, read: ${iterator.counter.getOffset() - initial}. initial offset: ${initial}`);
|
|
18
|
+
}
|
|
19
|
+
return boxes;
|
|
20
|
+
};
|
|
21
|
+
exports.getIsoBaseMediaChildren = getIsoBaseMediaChildren;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { SamplePosition } from '../../get-sample-positions';
|
|
2
|
-
import type { IsoBaseMediaBox } from '
|
|
2
|
+
import type { IsoBaseMediaBox } from './base-media-box';
|
|
3
3
|
import type { TrakBox } from './trak/trak';
|
|
4
4
|
export declare const getSamplePositionsFromTrack: (trakBox: TrakBox, moofBox: IsoBaseMediaBox | null) => SamplePosition[];
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseMdatSection = void 0;
|
|
4
|
+
const convert_audio_or_video_sample_1 = require("../../../convert-audio-or-video-sample");
|
|
5
|
+
const get_tracks_1 = require("../../../get-tracks");
|
|
6
|
+
const cached_sample_positions_1 = require("../../../state/iso-base-media/cached-sample-positions");
|
|
7
|
+
const may_skip_video_data_1 = require("../../../state/may-skip-video-data");
|
|
8
|
+
const parseMdatSection = async (state) => {
|
|
9
|
+
const videoSection = state.videoSection.getVideoSection();
|
|
10
|
+
// don't need mdat at all, can skip
|
|
11
|
+
if ((0, may_skip_video_data_1.maySkipVideoData)({ state })) {
|
|
12
|
+
return videoSection.size + videoSection.start;
|
|
13
|
+
}
|
|
14
|
+
const alreadyHas = (0, get_tracks_1.getHasTracks)(state);
|
|
15
|
+
if (!alreadyHas) {
|
|
16
|
+
// Will first read the end and then return
|
|
17
|
+
if (state.supportsContentRange) {
|
|
18
|
+
state.iso.setShouldReturnToVideoSectionAfterEnd(true);
|
|
19
|
+
return videoSection.size + videoSection.start;
|
|
20
|
+
}
|
|
21
|
+
throw new Error('Source does not support reading partially, but metadata is at the end of the file. This would require buffering the entire file in memory, leading to a leak. Remotion does not currently support this scenario, make sure to pass a source that supports Content-Range.');
|
|
22
|
+
}
|
|
23
|
+
if (!state.iso.flatSamples.getSamples()) {
|
|
24
|
+
state.iso.flatSamples.setSamples((0, cached_sample_positions_1.calculateFlatSamples)(state));
|
|
25
|
+
}
|
|
26
|
+
const flatSamples = state.iso.flatSamples.getSamples();
|
|
27
|
+
const { iterator } = state;
|
|
28
|
+
const samplesWithIndex = flatSamples.find((sample) => {
|
|
29
|
+
return sample.samplePosition.offset === iterator.counter.getOffset();
|
|
30
|
+
});
|
|
31
|
+
if (!samplesWithIndex) {
|
|
32
|
+
// There are various reasons why in mdat we find weird stuff:
|
|
33
|
+
// - iphonevideo.hevc has a fake hoov atom which is not mapped
|
|
34
|
+
// - corrupted.mp4 has a corrupt table
|
|
35
|
+
const nextSample_ = flatSamples
|
|
36
|
+
.filter((s) => s.samplePosition.offset > iterator.counter.getOffset())
|
|
37
|
+
.sort((a, b) => a.samplePosition.offset - b.samplePosition.offset)[0];
|
|
38
|
+
if (nextSample_) {
|
|
39
|
+
iterator.discard(nextSample_.samplePosition.offset - iterator.counter.getOffset());
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
// guess we reached the end!
|
|
43
|
+
// iphonevideo.mov has extra padding here, so let's make sure to jump ahead
|
|
44
|
+
return videoSection.size + videoSection.start;
|
|
45
|
+
}
|
|
46
|
+
if (iterator.bytesRemaining() < samplesWithIndex.samplePosition.size) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
const bytes = iterator.getSlice(samplesWithIndex.samplePosition.size);
|
|
50
|
+
const { cts, dts, duration, isKeyframe, offset } = samplesWithIndex.samplePosition;
|
|
51
|
+
if (samplesWithIndex.track.type === 'audio') {
|
|
52
|
+
await state.callbacks.onAudioSample(samplesWithIndex.track.trackId, (0, convert_audio_or_video_sample_1.convertAudioOrVideoSampleToWebCodecsTimestamps)({
|
|
53
|
+
data: bytes,
|
|
54
|
+
timestamp: cts,
|
|
55
|
+
duration,
|
|
56
|
+
cts,
|
|
57
|
+
dts,
|
|
58
|
+
trackId: samplesWithIndex.track.trackId,
|
|
59
|
+
type: isKeyframe ? 'key' : 'delta',
|
|
60
|
+
offset,
|
|
61
|
+
timescale: samplesWithIndex.track.timescale,
|
|
62
|
+
}, samplesWithIndex.track.timescale));
|
|
63
|
+
}
|
|
64
|
+
if (samplesWithIndex.track.type === 'video') {
|
|
65
|
+
// https://remotion-assets.s3.eu-central-1.amazonaws.com/example-videos/sei_checkpoint.mp4
|
|
66
|
+
// Position in file 0x0001aba615
|
|
67
|
+
// https://github.com/remotion-dev/remotion/issues/4680
|
|
68
|
+
// In Chrome, we may not treat recovery points as keyframes
|
|
69
|
+
// otherwise "a keyframe is required after flushing"
|
|
70
|
+
const nalUnitType = bytes[4] & 0b00011111;
|
|
71
|
+
let isRecoveryPoint = false;
|
|
72
|
+
// SEI (Supplemental enhancement information)
|
|
73
|
+
if (nalUnitType === 6) {
|
|
74
|
+
const seiType = bytes[5];
|
|
75
|
+
isRecoveryPoint = seiType === 6;
|
|
76
|
+
}
|
|
77
|
+
await state.callbacks.onVideoSample(samplesWithIndex.track.trackId, (0, convert_audio_or_video_sample_1.convertAudioOrVideoSampleToWebCodecsTimestamps)({
|
|
78
|
+
data: bytes,
|
|
79
|
+
timestamp: cts,
|
|
80
|
+
duration,
|
|
81
|
+
cts,
|
|
82
|
+
dts,
|
|
83
|
+
trackId: samplesWithIndex.track.trackId,
|
|
84
|
+
type: isKeyframe && !isRecoveryPoint ? 'key' : 'delta',
|
|
85
|
+
offset,
|
|
86
|
+
timescale: samplesWithIndex.track.timescale,
|
|
87
|
+
}, samplesWithIndex.track.timescale));
|
|
88
|
+
}
|
|
89
|
+
return null;
|
|
90
|
+
};
|
|
91
|
+
exports.parseMdatSection = parseMdatSection;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AnySegment } from '../../../parse-result';
|
|
2
|
+
import type { ParserState } from '../../../state/parser-state';
|
|
3
|
+
import type { BaseBox } from '../base-type';
|
|
4
|
+
export interface MoovBox extends BaseBox {
|
|
5
|
+
type: 'moov-box';
|
|
6
|
+
children: AnySegment[];
|
|
7
|
+
}
|
|
8
|
+
export declare const parseMoov: ({ offset, size, state, }: {
|
|
9
|
+
offset: number;
|
|
10
|
+
size: number;
|
|
11
|
+
state: ParserState;
|
|
12
|
+
}) => Promise<MoovBox>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseMoov = void 0;
|
|
4
|
+
const get_children_1 = require("../get-children");
|
|
5
|
+
const parseMoov = async ({ offset, size, state, }) => {
|
|
6
|
+
const children = await (0, get_children_1.getIsoBaseMediaChildren)({
|
|
7
|
+
state,
|
|
8
|
+
size: size - 8,
|
|
9
|
+
});
|
|
10
|
+
return {
|
|
11
|
+
offset,
|
|
12
|
+
boxSize: size,
|
|
13
|
+
type: 'moov-box',
|
|
14
|
+
children,
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
exports.parseMoov = parseMoov;
|