@remotion/media-parser 4.0.292 → 4.0.294

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.
Files changed (42) hide show
  1. package/dist/containers/iso-base-media/are-samples-complete.d.ts +6 -0
  2. package/dist/containers/iso-base-media/are-samples-complete.js +11 -0
  3. package/dist/containers/iso-base-media/collect-sample-positions-from-moof-boxes.d.ts +2 -3
  4. package/dist/containers/iso-base-media/collect-sample-positions-from-moof-boxes.js +1 -3
  5. package/dist/containers/iso-base-media/find-track-to-seek.js +9 -2
  6. package/dist/containers/iso-base-media/get-keyframes.js +6 -2
  7. package/dist/containers/iso-base-media/get-sample-positions-from-track.d.ts +2 -3
  8. package/dist/containers/iso-base-media/get-sample-positions-from-track.js +4 -4
  9. package/dist/containers/iso-base-media/get-seeking-byte-from-fragmented-mp4.js +6 -1
  10. package/dist/containers/iso-base-media/mdat/mdat.js +18 -1
  11. package/dist/containers/iso-base-media/process-box.js +7 -7
  12. package/dist/containers/iso-base-media/seeking-hints.js +1 -1
  13. package/dist/containers/iso-base-media/traversal.d.ts +2 -1
  14. package/dist/containers/iso-base-media/traversal.js +8 -4
  15. package/dist/emit-available-info.js +26 -26
  16. package/dist/esm/index.mjs +160 -88
  17. package/dist/esm/node.mjs +7 -4
  18. package/dist/esm/universal.mjs +29 -37
  19. package/dist/esm/web.mjs +22 -33
  20. package/dist/esm/worker-server-entry.mjs +166 -91
  21. package/dist/esm/worker-web-entry.mjs +159 -87
  22. package/dist/get-duration.js +15 -3
  23. package/dist/has-all-info.js +2 -1
  24. package/dist/index.d.ts +1 -1
  25. package/dist/readers/fetch/get-body-and-reader.js +3 -1
  26. package/dist/readers/from-node.js +7 -3
  27. package/dist/readers/from-web-file.js +20 -32
  28. package/dist/readers/reader.d.ts +1 -1
  29. package/dist/seek-backwards.js +1 -0
  30. package/dist/seek-forwards.js +1 -0
  31. package/dist/state/iso-base-media/cached-sample-positions.d.ts +5 -2
  32. package/dist/state/iso-base-media/cached-sample-positions.js +17 -7
  33. package/dist/state/iso-base-media/iso-state.d.ts +1 -1
  34. package/dist/state/iso-base-media/last-moof-box.d.ts +2 -0
  35. package/dist/state/iso-base-media/last-moof-box.js +21 -0
  36. package/dist/state/iso-base-media/precomputed-moof.d.ts +1 -0
  37. package/dist/state/iso-base-media/precomputed-moof.js +1 -0
  38. package/dist/state/parser-state.d.ts +1 -1
  39. package/dist/state/parser-state.js +2 -1
  40. package/dist/version.d.ts +1 -1
  41. package/dist/version.js +1 -1
  42. package/package.json +3 -3
@@ -0,0 +1,6 @@
1
+ import type { MoofBox } from '../../state/iso-base-media/precomputed-moof';
2
+ import type { TfraBox } from './mfra/tfra';
3
+ export declare const areSamplesComplete: ({ moofBoxes, tfraBoxes, }: {
4
+ moofBoxes: MoofBox[];
5
+ tfraBoxes: TfraBox[];
6
+ }) => boolean;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.areSamplesComplete = void 0;
4
+ const areSamplesComplete = ({ moofBoxes, tfraBoxes, }) => {
5
+ if (moofBoxes.length === 0) {
6
+ return true;
7
+ }
8
+ return (tfraBoxes.length > 0 &&
9
+ tfraBoxes.every((t) => t.entries.length === moofBoxes.length));
10
+ };
11
+ exports.areSamplesComplete = areSamplesComplete;
@@ -1,10 +1,9 @@
1
1
  import type { MoofBox } from '../../state/iso-base-media/precomputed-moof';
2
- import type { TfraBox } from './mfra/tfra';
3
2
  import type { TkhdBox } from './tkhd';
4
- export declare const collectSamplePositionsFromMoofBoxes: ({ moofBoxes, tfraBoxes, tkhdBox, }: {
3
+ export declare const collectSamplePositionsFromMoofBoxes: ({ moofBoxes, tkhdBox, isComplete, }: {
5
4
  moofBoxes: MoofBox[];
6
- tfraBoxes: TfraBox[];
7
5
  tkhdBox: TkhdBox;
6
+ isComplete: boolean;
8
7
  }) => {
9
8
  samplePositions: {
10
9
  isLastFragment: boolean;
@@ -2,9 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.collectSamplePositionsFromMoofBoxes = void 0;
4
4
  const samples_from_moof_1 = require("../../samples-from-moof");
5
- const collectSamplePositionsFromMoofBoxes = ({ moofBoxes, tfraBoxes, tkhdBox, }) => {
6
- const isComplete = tfraBoxes.length > 0 &&
7
- tfraBoxes.every((t) => t.entries.length === moofBoxes.length);
5
+ const collectSamplePositionsFromMoofBoxes = ({ moofBoxes, tkhdBox, isComplete, }) => {
8
6
  const samplePositions = moofBoxes.map((m, index) => {
9
7
  const isLastFragment = index === moofBoxes.length - 1 && isComplete;
10
8
  return {
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.findTrackToSeek = exports.findAnyTrackWithSamplePositions = void 0;
4
+ const are_samples_complete_1 = require("./are-samples-complete");
4
5
  const get_sample_positions_from_track_1 = require("./get-sample-positions-from-track");
5
6
  const traversal_1 = require("./traversal");
6
7
  const findAnyTrackWithSamplePositions = (allTracks, struc) => {
@@ -9,7 +10,10 @@ const findAnyTrackWithSamplePositions = (allTracks, struc) => {
9
10
  const { samplePositions } = (0, get_sample_positions_from_track_1.getSamplePositionsFromTrack)({
10
11
  trakBox: track.trakBox,
11
12
  moofBoxes: (0, traversal_1.getMoofBoxes)(struc.boxes),
12
- tfraBoxes: (0, traversal_1.getTfraBoxes)(struc),
13
+ moofComplete: (0, are_samples_complete_1.areSamplesComplete)({
14
+ moofBoxes: (0, traversal_1.getMoofBoxes)(struc.boxes),
15
+ tfraBoxes: (0, traversal_1.getTfraBoxes)(struc.boxes),
16
+ }),
13
17
  });
14
18
  if (samplePositions.length === 0) {
15
19
  continue;
@@ -29,7 +33,10 @@ const findTrackToSeek = (allTracks, structure) => {
29
33
  const { samplePositions } = (0, get_sample_positions_from_track_1.getSamplePositionsFromTrack)({
30
34
  trakBox: firstVideoTrack.trakBox,
31
35
  moofBoxes: (0, traversal_1.getMoofBoxes)(struc.boxes),
32
- tfraBoxes: (0, traversal_1.getTfraBoxes)(struc),
36
+ moofComplete: (0, are_samples_complete_1.areSamplesComplete)({
37
+ moofBoxes: (0, traversal_1.getMoofBoxes)(struc.boxes),
38
+ tfraBoxes: (0, traversal_1.getTfraBoxes)(struc.boxes),
39
+ }),
33
40
  });
34
41
  if (samplePositions.length === 0) {
35
42
  return (0, exports.findAnyTrackWithSamplePositions)(allTracks, struc);
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getKeyframesFromIsoBaseMedia = void 0;
4
4
  const get_tracks_1 = require("../../get-tracks");
5
+ const are_samples_complete_1 = require("./are-samples-complete");
5
6
  const get_sample_positions_from_track_1 = require("./get-sample-positions-from-track");
6
7
  const traversal_1 = require("./traversal");
7
8
  const getKeyframesFromIsoBaseMedia = (state) => {
@@ -13,13 +14,16 @@ const getKeyframesFromIsoBaseMedia = (state) => {
13
14
  });
14
15
  const structure = state.structure.getIsoStructure();
15
16
  const moofBoxes = (0, traversal_1.getMoofBoxes)(structure.boxes);
16
- const tfraBoxes = (0, traversal_1.getTfraBoxes)(structure);
17
+ const tfraBoxes = (0, traversal_1.getTfraBoxes)(structure.boxes);
17
18
  const allSamples = videoTracks.map((t) => {
18
19
  const { timescale: ts } = t;
19
20
  const { samplePositions, isComplete } = (0, get_sample_positions_from_track_1.getSamplePositionsFromTrack)({
20
21
  trakBox: t.trakBox,
21
22
  moofBoxes,
22
- tfraBoxes,
23
+ moofComplete: (0, are_samples_complete_1.areSamplesComplete)({
24
+ moofBoxes,
25
+ tfraBoxes,
26
+ }),
23
27
  });
24
28
  if (!isComplete) {
25
29
  return [];
@@ -1,11 +1,10 @@
1
1
  import type { SamplePosition } from '../../get-sample-positions';
2
2
  import type { MoofBox } from '../../state/iso-base-media/precomputed-moof';
3
- import type { TfraBox } from './mfra/tfra';
4
3
  import type { TrakBox } from './trak/trak';
5
- export declare const getSamplePositionsFromTrack: ({ trakBox, moofBoxes, tfraBoxes, }: {
4
+ export declare const getSamplePositionsFromTrack: ({ trakBox, moofBoxes, moofComplete, }: {
6
5
  trakBox: TrakBox;
7
6
  moofBoxes: MoofBox[];
8
- tfraBoxes: TfraBox[];
7
+ moofComplete: boolean;
9
8
  }) => {
10
9
  samplePositions: SamplePosition[];
11
10
  isComplete: boolean;
@@ -4,20 +4,20 @@ exports.getSamplePositionsFromTrack = void 0;
4
4
  const collect_sample_positions_from_moof_boxes_1 = require("./collect-sample-positions-from-moof-boxes");
5
5
  const collect_sample_positions_from_trak_1 = require("./collect-sample-positions-from-trak");
6
6
  const traversal_1 = require("./traversal");
7
- const getSamplePositionsFromTrack = ({ trakBox, moofBoxes, tfraBoxes, }) => {
7
+ const getSamplePositionsFromTrack = ({ trakBox, moofBoxes, moofComplete, }) => {
8
8
  const tkhdBox = (0, traversal_1.getTkhdBox)(trakBox);
9
9
  if (!tkhdBox) {
10
10
  throw new Error('Expected tkhd box in trak box');
11
11
  }
12
12
  if (moofBoxes.length > 0) {
13
- const { isComplete, samplePositions } = (0, collect_sample_positions_from_moof_boxes_1.collectSamplePositionsFromMoofBoxes)({
13
+ const { samplePositions } = (0, collect_sample_positions_from_moof_boxes_1.collectSamplePositionsFromMoofBoxes)({
14
14
  moofBoxes,
15
- tfraBoxes,
16
15
  tkhdBox,
16
+ isComplete: moofComplete,
17
17
  });
18
18
  return {
19
19
  samplePositions: samplePositions.map((s) => s.samples).flat(1),
20
- isComplete,
20
+ isComplete: moofComplete,
21
21
  };
22
22
  }
23
23
  return {
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getSeekingByteFromFragmentedMp4 = void 0;
4
4
  const log_1 = require("../../log");
5
5
  const video_section_1 = require("../../state/video-section");
6
+ const are_samples_complete_1 = require("./are-samples-complete");
6
7
  const collect_sample_positions_from_moof_boxes_1 = require("./collect-sample-positions-from-moof-boxes");
7
8
  const find_keyframe_before_time_1 = require("./find-keyframe-before-time");
8
9
  const get_sample_position_bounds_1 = require("./get-sample-position-bounds");
@@ -19,10 +20,14 @@ const getSeekingByteFromFragmentedMp4 = async ({ info, time, logLevel, currentPo
19
20
  if (!tkhdBox) {
20
21
  throw new Error('Expected tkhd box in trak box');
21
22
  }
22
- const { samplePositions: samplePositionsArray } = (0, collect_sample_positions_from_moof_boxes_1.collectSamplePositionsFromMoofBoxes)({
23
+ const isComplete = (0, are_samples_complete_1.areSamplesComplete)({
23
24
  moofBoxes: info.moofBoxes,
24
25
  tfraBoxes: info.tfraBoxes,
26
+ });
27
+ const { samplePositions: samplePositionsArray } = (0, collect_sample_positions_from_moof_boxes_1.collectSamplePositionsFromMoofBoxes)({
28
+ moofBoxes: info.moofBoxes,
25
29
  tkhdBox,
30
+ isComplete,
26
31
  });
27
32
  log_1.Log.trace(logLevel, 'Fragmented MP4 - Checking if we have seeking info for this time range');
28
33
  for (const positions of samplePositionsArray) {
@@ -3,8 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseMdatSection = void 0;
4
4
  const convert_audio_or_video_sample_1 = require("../../../convert-audio-or-video-sample");
5
5
  const get_tracks_1 = require("../../../get-tracks");
6
+ const log_1 = require("../../../log");
6
7
  const skip_1 = require("../../../skip");
7
8
  const cached_sample_positions_1 = require("../../../state/iso-base-media/cached-sample-positions");
9
+ const last_moof_box_1 = require("../../../state/iso-base-media/last-moof-box");
8
10
  const may_skip_video_data_1 = require("../../../state/may-skip-video-data");
9
11
  const video_section_1 = require("../../../state/video-section");
10
12
  const get_moov_atom_1 = require("../get-moov-atom");
@@ -21,6 +23,14 @@ const parseMdatSection = async (state) => {
21
23
  const endOfMdat = mediaSection.size + mediaSection.start;
22
24
  // don't need mdat at all, can skip
23
25
  if ((0, may_skip_video_data_1.maySkipVideoData)({ state })) {
26
+ const mfra = state.iso.mfra.getIfAlreadyLoaded();
27
+ if (mfra) {
28
+ const lastMoof = (0, last_moof_box_1.getLastMoofBox)(mfra);
29
+ if (lastMoof && lastMoof > endOfMdat) {
30
+ log_1.Log.verbose(state.logLevel, 'Skipping to last moof', lastMoof, 'end of mdat', endOfMdat);
31
+ return (0, skip_1.makeSkip)(lastMoof);
32
+ }
33
+ }
24
34
  return (0, skip_1.makeSkip)(endOfMdat);
25
35
  }
26
36
  const alreadyHasMoov = (0, get_tracks_1.getHasTracks)(state, true);
@@ -38,7 +48,10 @@ const parseMdatSection = async (state) => {
38
48
  return (0, exports.parseMdatSection)(state);
39
49
  }
40
50
  if (!state.iso.flatSamples.getSamples(mediaSection.start)) {
41
- const flattedSamples = (0, cached_sample_positions_1.calculateFlatSamples)(state);
51
+ const flattedSamples = (0, cached_sample_positions_1.calculateFlatSamples)({
52
+ state,
53
+ mediaSectionStart: mediaSection.start,
54
+ });
42
55
  const calcedJumpMarks = (0, calculate_jump_marks_1.calculateJumpMarks)(flattedSamples, endOfMdat);
43
56
  state.iso.flatSamples.setJumpMarks(mediaSection.start, calcedJumpMarks);
44
57
  state.iso.flatSamples.setSamples(mediaSection.start, flattedSamples.flat(1));
@@ -62,12 +75,15 @@ const parseMdatSection = async (state) => {
62
75
  }
63
76
  // guess we reached the end!
64
77
  // iphonevideo.mov has extra padding here, so let's make sure to jump ahead
78
+ log_1.Log.verbose(state.logLevel, 'Could not find sample at offset', iterator.counter.getOffset(), 'skipping to end of mdat');
65
79
  return (0, skip_1.makeSkip)(endOfMdat);
66
80
  }
67
81
  // Corrupt file: Sample is beyond the end of the file. Don't process it.
68
82
  if (samplesWithIndex.samplePosition.offset +
69
83
  samplesWithIndex.samplePosition.size >
70
84
  state.contentLength) {
85
+ log_1.Log.verbose(state.logLevel, "Sample is beyond the end of the file. Don't process it.", samplesWithIndex.samplePosition.offset +
86
+ samplesWithIndex.samplePosition.size, endOfMdat);
71
87
  return (0, skip_1.makeSkip)(endOfMdat);
72
88
  }
73
89
  // Need to fetch more data
@@ -128,6 +144,7 @@ const parseMdatSection = async (state) => {
128
144
  }
129
145
  const jump = jumpMarks.find((j) => j.afterSampleWithOffset === offset);
130
146
  if (jump) {
147
+ log_1.Log.verbose(state.logLevel, 'Found jump mark', jump.jumpToOffset, 'skipping to jump mark');
131
148
  return (0, skip_1.makeSkip)(jump.jumpToOffset);
132
149
  }
133
150
  return null;
@@ -81,13 +81,13 @@ const processBox = async ({ iterator, logLevel, onlyIfMoovAtomExpected, onlyIfMd
81
81
  if (boxType === 'ftyp') {
82
82
  return {
83
83
  type: 'box',
84
- box: await (0, ftyp_1.parseFtyp)({ iterator, size: boxSize, offset: fileOffset }),
84
+ box: (0, ftyp_1.parseFtyp)({ iterator, size: boxSize, offset: fileOffset }),
85
85
  };
86
86
  }
87
87
  if (boxType === 'colr') {
88
88
  return {
89
89
  type: 'box',
90
- box: await (0, colr_1.parseColorParameterBox)({
90
+ box: (0, colr_1.parseColorParameterBox)({
91
91
  iterator,
92
92
  size: boxSize,
93
93
  }),
@@ -96,25 +96,25 @@ const processBox = async ({ iterator, logLevel, onlyIfMoovAtomExpected, onlyIfMd
96
96
  if (boxType === 'mvhd') {
97
97
  return {
98
98
  type: 'box',
99
- box: await (0, mvhd_1.parseMvhd)({ iterator, offset: fileOffset, size: boxSize }),
99
+ box: (0, mvhd_1.parseMvhd)({ iterator, offset: fileOffset, size: boxSize }),
100
100
  };
101
101
  }
102
102
  if (boxType === 'tkhd') {
103
103
  return {
104
104
  type: 'box',
105
- box: await (0, tkhd_1.parseTkhd)({ iterator, offset: fileOffset, size: boxSize }),
105
+ box: (0, tkhd_1.parseTkhd)({ iterator, offset: fileOffset, size: boxSize }),
106
106
  };
107
107
  }
108
108
  if (boxType === 'trun') {
109
109
  return {
110
110
  type: 'box',
111
- box: await (0, trun_1.parseTrun)({ iterator, offset: fileOffset, size: boxSize }),
111
+ box: (0, trun_1.parseTrun)({ iterator, offset: fileOffset, size: boxSize }),
112
112
  };
113
113
  }
114
114
  if (boxType === 'tfdt') {
115
115
  return {
116
116
  type: 'box',
117
- box: await (0, tfdt_1.parseTfdt)({ iterator, size: boxSize, offset: fileOffset }),
117
+ box: (0, tfdt_1.parseTfdt)({ iterator, size: boxSize, offset: fileOffset }),
118
118
  };
119
119
  }
120
120
  if (boxType === 'stsd') {
@@ -365,7 +365,7 @@ const processBox = async ({ iterator, logLevel, onlyIfMoovAtomExpected, onlyIfMd
365
365
  };
366
366
  }
367
367
  if (boxType === 'moof') {
368
- (_b = onlyIfMoovAtomExpected === null || onlyIfMoovAtomExpected === void 0 ? void 0 : onlyIfMoovAtomExpected.isoState) === null || _b === void 0 ? void 0 : _b.mfra.triggerLoad();
368
+ await ((_b = onlyIfMoovAtomExpected === null || onlyIfMoovAtomExpected === void 0 ? void 0 : onlyIfMoovAtomExpected.isoState) === null || _b === void 0 ? void 0 : _b.mfra.triggerLoad());
369
369
  }
370
370
  if (boxType === 'mdia' ||
371
371
  boxType === 'minf' ||
@@ -18,7 +18,7 @@ const getSeekingHintsFromMp4 = ({ structureState, isoState, mp4HeaderSegment, me
18
18
  ]);
19
19
  const tfraBoxes = (0, precomputed_tfra_1.deduplicateTfraBoxesByOffset)([
20
20
  ...isoState.tfra.getTfraBoxes(),
21
- ...(0, traversal_1.getTfraBoxes)(structure),
21
+ ...(0, traversal_1.getTfraBoxes)(structure.boxes),
22
22
  ]);
23
23
  if (!moovAtom) {
24
24
  return null;
@@ -46,4 +46,5 @@ export declare const getStssBox: (trakBox: TrakBox) => StssBox | null;
46
46
  export declare const getTfdtBox: (segment: IsoBaseMediaBox) => TfdtBox | null;
47
47
  export declare const getTfhdBox: (segment: IsoBaseMediaBox) => TfhdBox | null;
48
48
  export declare const getTrunBoxes: (segment: IsoBaseMediaBox) => TrunBox[];
49
- export declare const getTfraBoxes: (structure: IsoBaseMediaStructure) => TfraBox[];
49
+ export declare const getTfraBoxesFromMfraBoxChildren: (mfraBoxChildren: IsoBaseMediaBox[]) => TfraBox[];
50
+ export declare const getTfraBoxes: (structure: IsoBaseMediaBox[]) => TfraBox[];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getTfraBoxes = exports.getTrunBoxes = exports.getTfhdBox = exports.getTfdtBox = exports.getStssBox = exports.getStscBox = exports.getStszBox = exports.getCttsBox = exports.getSttsBox = exports.getStcoBox = exports.getVideoDescriptors = exports.getStsdBox = exports.getStblBox = exports.getMdhdBox = exports.getMdiaBox = exports.getTkhdBox = exports.getTraks = exports.getMvhdBox = exports.getMoofBoxes = exports.getMoovBoxFromState = exports.getMoovFromFromIsoStructure = exports.getFtypBox = void 0;
3
+ exports.getTfraBoxes = exports.getTfraBoxesFromMfraBoxChildren = exports.getTrunBoxes = exports.getTfhdBox = exports.getTfdtBox = exports.getStssBox = exports.getStscBox = exports.getStszBox = exports.getCttsBox = exports.getSttsBox = exports.getStcoBox = exports.getVideoDescriptors = exports.getStsdBox = exports.getStblBox = exports.getMdhdBox = exports.getMdiaBox = exports.getTkhdBox = exports.getTraks = exports.getMvhdBox = exports.getMoofBoxes = exports.getMoovBoxFromState = exports.getMoovFromFromIsoStructure = exports.getFtypBox = void 0;
4
4
  const precomputed_moof_1 = require("../../state/iso-base-media/precomputed-moof");
5
5
  const getFtypBox = (segments) => {
6
6
  const ftypBox = segments.find((s) => s.type === 'ftyp-box');
@@ -198,12 +198,16 @@ const getTrunBoxes = (segment) => {
198
198
  return trunBoxes;
199
199
  };
200
200
  exports.getTrunBoxes = getTrunBoxes;
201
+ const getTfraBoxesFromMfraBoxChildren = (mfraBoxChildren) => {
202
+ const tfraBoxes = mfraBoxChildren.filter((b) => b.type === 'tfra-box');
203
+ return tfraBoxes;
204
+ };
205
+ exports.getTfraBoxesFromMfraBoxChildren = getTfraBoxesFromMfraBoxChildren;
201
206
  const getTfraBoxes = (structure) => {
202
- const mfraBox = structure.boxes.find((b) => b.type === 'regular-box' && b.boxType === 'mfra');
207
+ const mfraBox = structure.find((b) => b.type === 'regular-box' && b.boxType === 'mfra');
203
208
  if (!mfraBox) {
204
209
  return [];
205
210
  }
206
- const tfraBoxes = mfraBox.children.filter((b) => b.type === 'tfra-box');
207
- return tfraBoxes;
211
+ return (0, exports.getTfraBoxesFromMfraBoxChildren)(mfraBox.children);
208
212
  };
209
213
  exports.getTfraBoxes = getTfraBoxes;
@@ -17,7 +17,7 @@ const get_video_codec_1 = require("./get-video-codec");
17
17
  const get_metadata_1 = require("./metadata/get-metadata");
18
18
  const work_on_seek_request_1 = require("./work-on-seek-request");
19
19
  const emitAvailableInfo = async ({ hasInfo, state, }) => {
20
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5;
20
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6;
21
21
  const keys = Object.keys(hasInfo);
22
22
  const { emittedFields, fieldsInReturnValue, returnValue, name, callbackFunctions, } = state;
23
23
  for (const key of keys) {
@@ -83,8 +83,8 @@ const emitAvailableInfo = async ({ hasInfo, state, }) => {
83
83
  // must be handled after fps
84
84
  if (key === 'slowFps') {
85
85
  if (hasInfo.slowFps && !emittedFields.slowFps) {
86
- const slowFps = state.samplesObserved.getFps();
87
- await ((_g = callbackFunctions.onSlowFps) === null || _g === void 0 ? void 0 : _g.call(callbackFunctions, slowFps));
86
+ const slowFps = (_g = (0, get_fps_1.getFps)(state)) !== null && _g !== void 0 ? _g : state.samplesObserved.getFps();
87
+ await ((_h = callbackFunctions.onSlowFps) === null || _h === void 0 ? void 0 : _h.call(callbackFunctions, slowFps));
88
88
  if (fieldsInReturnValue.slowFps) {
89
89
  returnValue.slowFps = slowFps;
90
90
  }
@@ -101,7 +101,7 @@ const emitAvailableInfo = async ({ hasInfo, state, }) => {
101
101
  height: dimensionsQueried.height,
102
102
  width: dimensionsQueried.width,
103
103
  };
104
- await ((_h = callbackFunctions.onDimensions) === null || _h === void 0 ? void 0 : _h.call(callbackFunctions, dimensions));
104
+ await ((_j = callbackFunctions.onDimensions) === null || _j === void 0 ? void 0 : _j.call(callbackFunctions, dimensions));
105
105
  if (fieldsInReturnValue.dimensions) {
106
106
  returnValue.dimensions = dimensions;
107
107
  }
@@ -118,7 +118,7 @@ const emitAvailableInfo = async ({ hasInfo, state, }) => {
118
118
  height: dimensionsQueried.unrotatedHeight,
119
119
  width: dimensionsQueried.unrotatedWidth,
120
120
  };
121
- await ((_j = callbackFunctions.onUnrotatedDimensions) === null || _j === void 0 ? void 0 : _j.call(callbackFunctions, unrotatedDimensions));
121
+ await ((_k = callbackFunctions.onUnrotatedDimensions) === null || _k === void 0 ? void 0 : _k.call(callbackFunctions, unrotatedDimensions));
122
122
  if (fieldsInReturnValue.unrotatedDimensions) {
123
123
  returnValue.unrotatedDimensions = unrotatedDimensions;
124
124
  }
@@ -129,8 +129,8 @@ const emitAvailableInfo = async ({ hasInfo, state, }) => {
129
129
  if (key === 'rotation') {
130
130
  if (hasInfo.rotation && !emittedFields.rotation) {
131
131
  const dimensionsQueried = (0, get_dimensions_1.getDimensions)(state);
132
- const rotation = (_k = dimensionsQueried === null || dimensionsQueried === void 0 ? void 0 : dimensionsQueried.rotation) !== null && _k !== void 0 ? _k : 0;
133
- await ((_l = callbackFunctions.onRotation) === null || _l === void 0 ? void 0 : _l.call(callbackFunctions, rotation));
132
+ const rotation = (_l = dimensionsQueried === null || dimensionsQueried === void 0 ? void 0 : dimensionsQueried.rotation) !== null && _l !== void 0 ? _l : 0;
133
+ await ((_m = callbackFunctions.onRotation) === null || _m === void 0 ? void 0 : _m.call(callbackFunctions, rotation));
134
134
  if (fieldsInReturnValue.rotation) {
135
135
  returnValue.rotation = rotation;
136
136
  }
@@ -141,7 +141,7 @@ const emitAvailableInfo = async ({ hasInfo, state, }) => {
141
141
  if (key === 'videoCodec') {
142
142
  if (!emittedFields.videoCodec && hasInfo.videoCodec) {
143
143
  const videoCodec = (0, get_video_codec_1.getVideoCodec)(state);
144
- await ((_m = callbackFunctions.onVideoCodec) === null || _m === void 0 ? void 0 : _m.call(callbackFunctions, videoCodec));
144
+ await ((_o = callbackFunctions.onVideoCodec) === null || _o === void 0 ? void 0 : _o.call(callbackFunctions, videoCodec));
145
145
  if (fieldsInReturnValue.videoCodec) {
146
146
  returnValue.videoCodec = videoCodec;
147
147
  }
@@ -152,7 +152,7 @@ const emitAvailableInfo = async ({ hasInfo, state, }) => {
152
152
  if (key === 'audioCodec') {
153
153
  if (!emittedFields.audioCodec && hasInfo.audioCodec) {
154
154
  const audioCodec = (0, get_audio_codec_1.getAudioCodec)(state);
155
- await ((_o = callbackFunctions.onAudioCodec) === null || _o === void 0 ? void 0 : _o.call(callbackFunctions, audioCodec));
155
+ await ((_p = callbackFunctions.onAudioCodec) === null || _p === void 0 ? void 0 : _p.call(callbackFunctions, audioCodec));
156
156
  if (fieldsInReturnValue.audioCodec) {
157
157
  returnValue.audioCodec = audioCodec;
158
158
  }
@@ -163,7 +163,7 @@ const emitAvailableInfo = async ({ hasInfo, state, }) => {
163
163
  if (key === 'tracks') {
164
164
  if (!emittedFields.tracks && hasInfo.tracks) {
165
165
  const { videoTracks, audioTracks } = (0, get_tracks_1.getTracks)(state, true);
166
- await ((_p = callbackFunctions.onTracks) === null || _p === void 0 ? void 0 : _p.call(callbackFunctions, { videoTracks, audioTracks }));
166
+ await ((_q = callbackFunctions.onTracks) === null || _q === void 0 ? void 0 : _q.call(callbackFunctions, { videoTracks, audioTracks }));
167
167
  if (fieldsInReturnValue.tracks) {
168
168
  returnValue.tracks = { videoTracks, audioTracks };
169
169
  }
@@ -184,7 +184,7 @@ const emitAvailableInfo = async ({ hasInfo, state, }) => {
184
184
  }
185
185
  if (key === 'size') {
186
186
  if (!emittedFields.size && hasInfo.size) {
187
- await ((_q = callbackFunctions.onSize) === null || _q === void 0 ? void 0 : _q.call(callbackFunctions, state.contentLength));
187
+ await ((_r = callbackFunctions.onSize) === null || _r === void 0 ? void 0 : _r.call(callbackFunctions, state.contentLength));
188
188
  if (fieldsInReturnValue.size) {
189
189
  returnValue.size = state.contentLength;
190
190
  }
@@ -194,7 +194,7 @@ const emitAvailableInfo = async ({ hasInfo, state, }) => {
194
194
  }
195
195
  if (key === 'mimeType') {
196
196
  if (!emittedFields.mimeType && hasInfo.mimeType) {
197
- await ((_r = callbackFunctions.onMimeType) === null || _r === void 0 ? void 0 : _r.call(callbackFunctions, state.mimeType));
197
+ await ((_s = callbackFunctions.onMimeType) === null || _s === void 0 ? void 0 : _s.call(callbackFunctions, state.mimeType));
198
198
  if (fieldsInReturnValue.mimeType) {
199
199
  returnValue.mimeType = state.mimeType;
200
200
  }
@@ -204,7 +204,7 @@ const emitAvailableInfo = async ({ hasInfo, state, }) => {
204
204
  }
205
205
  if (key === 'name') {
206
206
  if (!emittedFields.name && hasInfo.name) {
207
- await ((_s = callbackFunctions.onName) === null || _s === void 0 ? void 0 : _s.call(callbackFunctions, name));
207
+ await ((_t = callbackFunctions.onName) === null || _t === void 0 ? void 0 : _t.call(callbackFunctions, name));
208
208
  if (fieldsInReturnValue.name) {
209
209
  returnValue.name = name;
210
210
  }
@@ -215,7 +215,7 @@ const emitAvailableInfo = async ({ hasInfo, state, }) => {
215
215
  if (key === 'isHdr') {
216
216
  if (!returnValue.isHdr && hasInfo.isHdr) {
217
217
  const isHdr = (0, get_is_hdr_1.getIsHdr)(state);
218
- await ((_t = callbackFunctions.onIsHdr) === null || _t === void 0 ? void 0 : _t.call(callbackFunctions, isHdr));
218
+ await ((_u = callbackFunctions.onIsHdr) === null || _u === void 0 ? void 0 : _u.call(callbackFunctions, isHdr));
219
219
  if (fieldsInReturnValue.isHdr) {
220
220
  returnValue.isHdr = isHdr;
221
221
  }
@@ -226,7 +226,7 @@ const emitAvailableInfo = async ({ hasInfo, state, }) => {
226
226
  if (key === 'container') {
227
227
  if (!returnValue.container && hasInfo.container) {
228
228
  const container = (0, get_container_1.getContainer)(state.structure.getStructure());
229
- await ((_u = callbackFunctions.onContainer) === null || _u === void 0 ? void 0 : _u.call(callbackFunctions, container));
229
+ await ((_v = callbackFunctions.onContainer) === null || _v === void 0 ? void 0 : _v.call(callbackFunctions, container));
230
230
  if (fieldsInReturnValue.container) {
231
231
  returnValue.container = container;
232
232
  }
@@ -237,7 +237,7 @@ const emitAvailableInfo = async ({ hasInfo, state, }) => {
237
237
  if (key === 'metadata') {
238
238
  if (!emittedFields.metadata && hasInfo.metadata) {
239
239
  const metadata = (0, get_metadata_1.getMetadata)(state);
240
- await ((_v = callbackFunctions.onMetadata) === null || _v === void 0 ? void 0 : _v.call(callbackFunctions, metadata));
240
+ await ((_w = callbackFunctions.onMetadata) === null || _w === void 0 ? void 0 : _w.call(callbackFunctions, metadata));
241
241
  if (fieldsInReturnValue.metadata) {
242
242
  returnValue.metadata = metadata;
243
243
  }
@@ -248,7 +248,7 @@ const emitAvailableInfo = async ({ hasInfo, state, }) => {
248
248
  if (key === 'location') {
249
249
  if (!emittedFields.location && hasInfo.location) {
250
250
  const location = (0, get_location_1.getLocation)(state);
251
- await ((_w = callbackFunctions.onLocation) === null || _w === void 0 ? void 0 : _w.call(callbackFunctions, location));
251
+ await ((_x = callbackFunctions.onLocation) === null || _x === void 0 ? void 0 : _x.call(callbackFunctions, location));
252
252
  if (fieldsInReturnValue.location) {
253
253
  returnValue.location = location;
254
254
  }
@@ -258,7 +258,7 @@ const emitAvailableInfo = async ({ hasInfo, state, }) => {
258
258
  }
259
259
  if (key === 'slowKeyframes') {
260
260
  if (!emittedFields.slowKeyframes && hasInfo.slowKeyframes) {
261
- await ((_x = callbackFunctions.onSlowKeyframes) === null || _x === void 0 ? void 0 : _x.call(callbackFunctions, state.keyframes.getKeyframes()));
261
+ await ((_y = callbackFunctions.onSlowKeyframes) === null || _y === void 0 ? void 0 : _y.call(callbackFunctions, state.keyframes.getKeyframes()));
262
262
  if (fieldsInReturnValue.slowKeyframes) {
263
263
  returnValue.slowKeyframes = state.keyframes.getKeyframes();
264
264
  }
@@ -268,7 +268,7 @@ const emitAvailableInfo = async ({ hasInfo, state, }) => {
268
268
  }
269
269
  if (key === 'slowNumberOfFrames') {
270
270
  if (!emittedFields.slowNumberOfFrames && hasInfo.slowNumberOfFrames) {
271
- await ((_y = callbackFunctions.onSlowNumberOfFrames) === null || _y === void 0 ? void 0 : _y.call(callbackFunctions, state.samplesObserved.getSlowNumberOfFrames()));
271
+ await ((_z = callbackFunctions.onSlowNumberOfFrames) === null || _z === void 0 ? void 0 : _z.call(callbackFunctions, state.samplesObserved.getSlowNumberOfFrames()));
272
272
  if (fieldsInReturnValue.slowNumberOfFrames) {
273
273
  returnValue.slowNumberOfFrames =
274
274
  state.samplesObserved.getSlowNumberOfFrames();
@@ -279,7 +279,7 @@ const emitAvailableInfo = async ({ hasInfo, state, }) => {
279
279
  }
280
280
  if (key === 'slowAudioBitrate') {
281
281
  if (!emittedFields.slowAudioBitrate && hasInfo.slowAudioBitrate) {
282
- await ((_z = callbackFunctions.onSlowAudioBitrate) === null || _z === void 0 ? void 0 : _z.call(callbackFunctions, state.samplesObserved.getAudioBitrate()));
282
+ await ((_0 = callbackFunctions.onSlowAudioBitrate) === null || _0 === void 0 ? void 0 : _0.call(callbackFunctions, state.samplesObserved.getAudioBitrate()));
283
283
  if (fieldsInReturnValue.slowAudioBitrate) {
284
284
  returnValue.slowAudioBitrate =
285
285
  state.samplesObserved.getAudioBitrate();
@@ -290,7 +290,7 @@ const emitAvailableInfo = async ({ hasInfo, state, }) => {
290
290
  }
291
291
  if (key === 'slowVideoBitrate') {
292
292
  if (!emittedFields.slowVideoBitrate && hasInfo.slowVideoBitrate) {
293
- await ((_0 = callbackFunctions.onSlowVideoBitrate) === null || _0 === void 0 ? void 0 : _0.call(callbackFunctions, state.samplesObserved.getVideoBitrate()));
293
+ await ((_1 = callbackFunctions.onSlowVideoBitrate) === null || _1 === void 0 ? void 0 : _1.call(callbackFunctions, state.samplesObserved.getVideoBitrate()));
294
294
  if (fieldsInReturnValue.slowVideoBitrate) {
295
295
  returnValue.slowVideoBitrate =
296
296
  state.samplesObserved.getVideoBitrate();
@@ -301,7 +301,7 @@ const emitAvailableInfo = async ({ hasInfo, state, }) => {
301
301
  }
302
302
  if (key === 'keyframes') {
303
303
  if (!emittedFields.keyframes && hasInfo.keyframes) {
304
- await ((_1 = callbackFunctions.onKeyframes) === null || _1 === void 0 ? void 0 : _1.call(callbackFunctions, (0, get_keyframes_1.getKeyframes)(state)));
304
+ await ((_2 = callbackFunctions.onKeyframes) === null || _2 === void 0 ? void 0 : _2.call(callbackFunctions, (0, get_keyframes_1.getKeyframes)(state)));
305
305
  if (fieldsInReturnValue.keyframes) {
306
306
  returnValue.keyframes = (0, get_keyframes_1.getKeyframes)(state);
307
307
  }
@@ -311,7 +311,7 @@ const emitAvailableInfo = async ({ hasInfo, state, }) => {
311
311
  }
312
312
  if (key === 'images') {
313
313
  if (!emittedFields.images && hasInfo.images) {
314
- await ((_2 = callbackFunctions.onImages) === null || _2 === void 0 ? void 0 : _2.call(callbackFunctions, state.images.images));
314
+ await ((_3 = callbackFunctions.onImages) === null || _3 === void 0 ? void 0 : _3.call(callbackFunctions, state.images.images));
315
315
  if (fieldsInReturnValue.images) {
316
316
  returnValue.images = state.images.images;
317
317
  }
@@ -322,7 +322,7 @@ const emitAvailableInfo = async ({ hasInfo, state, }) => {
322
322
  if (key === 'sampleRate') {
323
323
  if (!emittedFields.sampleRate && hasInfo.sampleRate) {
324
324
  const sampleRate = (0, get_sample_rate_1.getSampleRate)(state);
325
- await ((_3 = callbackFunctions.onSampleRate) === null || _3 === void 0 ? void 0 : _3.call(callbackFunctions, sampleRate));
325
+ await ((_4 = callbackFunctions.onSampleRate) === null || _4 === void 0 ? void 0 : _4.call(callbackFunctions, sampleRate));
326
326
  if (fieldsInReturnValue.sampleRate) {
327
327
  returnValue.sampleRate = sampleRate;
328
328
  }
@@ -334,7 +334,7 @@ const emitAvailableInfo = async ({ hasInfo, state, }) => {
334
334
  if (!emittedFields.numberOfAudioChannels &&
335
335
  hasInfo.numberOfAudioChannels) {
336
336
  const numberOfAudioChannels = (0, get_number_of_audio_channels_1.getNumberOfAudioChannels)(state);
337
- await ((_4 = callbackFunctions.onNumberOfAudioChannels) === null || _4 === void 0 ? void 0 : _4.call(callbackFunctions, numberOfAudioChannels));
337
+ await ((_5 = callbackFunctions.onNumberOfAudioChannels) === null || _5 === void 0 ? void 0 : _5.call(callbackFunctions, numberOfAudioChannels));
338
338
  if (fieldsInReturnValue.numberOfAudioChannels) {
339
339
  returnValue.numberOfAudioChannels = numberOfAudioChannels;
340
340
  }
@@ -349,7 +349,7 @@ const emitAvailableInfo = async ({ hasInfo, state, }) => {
349
349
  originalSrc: state.src,
350
350
  readerInterface: state.readerInterface,
351
351
  });
352
- await ((_5 = callbackFunctions.onM3uStreams) === null || _5 === void 0 ? void 0 : _5.call(callbackFunctions, streams));
352
+ await ((_6 = callbackFunctions.onM3uStreams) === null || _6 === void 0 ? void 0 : _6.call(callbackFunctions, streams));
353
353
  if (fieldsInReturnValue.m3uStreams) {
354
354
  returnValue.m3uStreams = streams;
355
355
  }