@remotion/media-parser 4.0.312 → 4.0.314

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 (32) hide show
  1. package/dist/containers/iso-base-media/base-media-box.d.ts +3 -2
  2. package/dist/containers/iso-base-media/collect-sample-positions-from-moof-boxes.d.ts +3 -1
  3. package/dist/containers/iso-base-media/collect-sample-positions-from-moof-boxes.js +2 -1
  4. package/dist/containers/iso-base-media/find-track-to-seek.js +2 -0
  5. package/dist/containers/iso-base-media/get-keyframes.js +1 -0
  6. package/dist/containers/iso-base-media/get-sample-positions-from-track.d.ts +3 -1
  7. package/dist/containers/iso-base-media/get-sample-positions-from-track.js +2 -1
  8. package/dist/containers/iso-base-media/get-seeking-byte-from-fragmented-mp4.js +1 -0
  9. package/dist/containers/iso-base-media/moov/mvhd.d.ts +30 -0
  10. package/dist/containers/iso-base-media/moov/mvhd.js +65 -0
  11. package/dist/containers/iso-base-media/moov/trex.d.ts +16 -0
  12. package/dist/containers/iso-base-media/moov/trex.js +27 -0
  13. package/dist/containers/iso-base-media/process-box.js +10 -1
  14. package/dist/containers/iso-base-media/tkhd.d.ts +1 -1
  15. package/dist/containers/iso-base-media/traversal.d.ts +4 -1
  16. package/dist/containers/iso-base-media/traversal.js +18 -1
  17. package/dist/esm/index.mjs +102 -26
  18. package/dist/esm/worker-server-entry.mjs +101 -25
  19. package/dist/esm/worker-web-entry.mjs +101 -25
  20. package/dist/get-duration.js +1 -0
  21. package/dist/index.d.ts +2 -2
  22. package/dist/index.js +1 -1
  23. package/dist/iterator/buffer-iterator.d.ts +1 -1
  24. package/dist/iterator/buffer-manager.d.ts +1 -1
  25. package/dist/iterator/buffer-manager.js +19 -5
  26. package/dist/samples-from-moof.d.ts +3 -1
  27. package/dist/samples-from-moof.js +15 -12
  28. package/dist/state/iso-base-media/cached-sample-positions.js +1 -0
  29. package/dist/state/iso-base-media/lazy-mfra-load.js +1 -1
  30. package/dist/version.d.ts +1 -1
  31. package/dist/version.js +1 -1
  32. package/package.json +3 -3
@@ -2,15 +2,18 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getSamplesFromMoof = void 0;
4
4
  const traversal_1 = require("./containers/iso-base-media/traversal");
5
- const getSamplesFromTraf = (trafSegment, moofOffset) => {
6
- var _a, _b, _c, _d, _e, _f, _g;
5
+ const getSamplesFromTraf = (trafSegment, moofOffset, trexBoxes) => {
6
+ var _a, _b, _c, _d, _e, _f;
7
7
  if (trafSegment.type !== 'regular-box' || trafSegment.boxType !== 'traf') {
8
8
  throw new Error('Expected traf-box');
9
9
  }
10
10
  const tfhdBox = (0, traversal_1.getTfhdBox)(trafSegment);
11
- const defaultSampleDuration = (_a = tfhdBox === null || tfhdBox === void 0 ? void 0 : tfhdBox.defaultSampleDuration) !== null && _a !== void 0 ? _a : null;
12
- const defaultSampleSize = (_b = tfhdBox === null || tfhdBox === void 0 ? void 0 : tfhdBox.defaultSampleSize) !== null && _b !== void 0 ? _b : null;
13
- const defaultSampleFlags = (_c = tfhdBox === null || tfhdBox === void 0 ? void 0 : tfhdBox.defaultSampleFlags) !== null && _c !== void 0 ? _c : null;
11
+ const trexBox = (_a = trexBoxes.find((t) => t.trackId === (tfhdBox === null || tfhdBox === void 0 ? void 0 : tfhdBox.trackId))) !== null && _a !== void 0 ? _a : null;
12
+ // intentional || instead of ?? to allow for 0, doesn't make sense for duration or size
13
+ const defaultTrackSampleDuration = (tfhdBox === null || tfhdBox === void 0 ? void 0 : tfhdBox.defaultSampleDuration) || (trexBox === null || trexBox === void 0 ? void 0 : trexBox.defaultSampleDuration) || null;
14
+ const defaultTrackSampleSize = (tfhdBox === null || tfhdBox === void 0 ? void 0 : tfhdBox.defaultSampleSize) || (trexBox === null || trexBox === void 0 ? void 0 : trexBox.defaultSampleSize) || null;
15
+ // but flags may just be 0 :)
16
+ const defaultTrackSampleFlags = (_c = (_b = tfhdBox === null || tfhdBox === void 0 ? void 0 : tfhdBox.defaultSampleFlags) !== null && _b !== void 0 ? _b : trexBox === null || trexBox === void 0 ? void 0 : trexBox.defaultSampleFlags) !== null && _c !== void 0 ? _c : null;
14
17
  const tfdtBox = (0, traversal_1.getTfdtBox)(trafSegment);
15
18
  const trunBoxes = (0, traversal_1.getTrunBoxes)(trafSegment);
16
19
  let time = 0;
@@ -25,11 +28,11 @@ const getSamplesFromTraf = (trafSegment, moofOffset) => {
25
28
  }
26
29
  for (const sample of trunBox.samples) {
27
30
  i++;
28
- const duration = (_d = sample.sampleDuration) !== null && _d !== void 0 ? _d : defaultSampleDuration;
31
+ const duration = sample.sampleDuration || defaultTrackSampleDuration;
29
32
  if (duration === null) {
30
33
  throw new Error('Expected duration');
31
34
  }
32
- const size = (_e = sample.sampleSize) !== null && _e !== void 0 ? _e : defaultSampleSize;
35
+ const size = (_d = sample.sampleSize) !== null && _d !== void 0 ? _d : defaultTrackSampleSize;
33
36
  if (size === null) {
34
37
  throw new Error('Expected size');
35
38
  }
@@ -38,16 +41,16 @@ const getSamplesFromTraf = (trafSegment, moofOffset) => {
38
41
  ? sample.sampleFlags
39
42
  : isFirstSample && trunBox.firstSampleFlags !== null
40
43
  ? trunBox.firstSampleFlags
41
- : defaultSampleFlags;
44
+ : defaultTrackSampleFlags;
42
45
  if (sampleFlags === null) {
43
46
  throw new Error('Expected sample flags');
44
47
  }
45
48
  const keyframe = !((sampleFlags >> 16) & 0x1);
46
- const dts = time + ((_f = tfdtBox === null || tfdtBox === void 0 ? void 0 : tfdtBox.baseMediaDecodeTime) !== null && _f !== void 0 ? _f : 0);
49
+ const dts = time + ((_e = tfdtBox === null || tfdtBox === void 0 ? void 0 : tfdtBox.baseMediaDecodeTime) !== null && _e !== void 0 ? _e : 0);
47
50
  const samplePosition = {
48
51
  offset: offset + (moofOffset !== null && moofOffset !== void 0 ? moofOffset : 0) + (dataOffset !== null && dataOffset !== void 0 ? dataOffset : 0),
49
52
  decodingTimestamp: dts,
50
- timestamp: dts + ((_g = sample.sampleCompositionTimeOffset) !== null && _g !== void 0 ? _g : 0),
53
+ timestamp: dts + ((_f = sample.sampleCompositionTimeOffset) !== null && _f !== void 0 ? _f : 0),
51
54
  duration,
52
55
  isKeyframe: keyframe,
53
56
  size,
@@ -62,13 +65,13 @@ const getSamplesFromTraf = (trafSegment, moofOffset) => {
62
65
  }
63
66
  return samples;
64
67
  };
65
- const getSamplesFromMoof = ({ moofBox, trackId, }) => {
68
+ const getSamplesFromMoof = ({ moofBox, trackId, trexBoxes, }) => {
66
69
  const mapped = moofBox.trafBoxes.map((traf) => {
67
70
  const tfhdBox = (0, traversal_1.getTfhdBox)(traf);
68
71
  if (!tfhdBox || tfhdBox.trackId !== trackId) {
69
72
  return [];
70
73
  }
71
- return getSamplesFromTraf(traf, moofBox.offset);
74
+ return getSamplesFromTraf(traf, moofBox.offset, trexBoxes);
72
75
  });
73
76
  return mapped.flat(1);
74
77
  };
@@ -37,6 +37,7 @@ const calculateFlatSamples = ({ state, mediaSectionStart, }) => {
37
37
  trakBox,
38
38
  moofBoxes: relevantMoofBox ? [relevantMoofBox] : [],
39
39
  moofComplete,
40
+ trexBoxes: (0, traversal_1.getTrexBoxes)(moov),
40
41
  });
41
42
  return samplePositions.map((samplePosition) => {
42
43
  return {
@@ -19,7 +19,7 @@ const lazyMfraLoad = ({ contentLength, controller, readerInterface, src, logLeve
19
19
  logLevel,
20
20
  prefetchCache,
21
21
  }).then((boxes) => {
22
- log_1.Log.verbose(logLevel, 'Lazily found mfra atom.');
22
+ log_1.Log.verbose(logLevel, boxes ? 'Lazily found mfra atom.' : 'No mfra atom found.');
23
23
  result = boxes;
24
24
  return boxes;
25
25
  });
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "4.0.312";
1
+ export declare const VERSION = "4.0.314";
package/dist/version.js CHANGED
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
4
  // Automatically generated on publish
5
- exports.VERSION = '4.0.312';
5
+ exports.VERSION = '4.0.314';
package/package.json CHANGED
@@ -3,15 +3,15 @@
3
3
  "url": "https://github.com/remotion-dev/remotion/tree/main/packages/media-parser"
4
4
  },
5
5
  "name": "@remotion/media-parser",
6
- "version": "4.0.312",
6
+ "version": "4.0.314",
7
7
  "main": "dist/index.js",
8
8
  "sideEffects": false,
9
9
  "devDependencies": {
10
10
  "@types/wicg-file-system-access": "2023.10.5",
11
11
  "eslint": "9.19.0",
12
12
  "@types/bun": "1.2.8",
13
- "@remotion/eslint-config-internal": "4.0.312",
14
- "@remotion/example-videos": "4.0.312"
13
+ "@remotion/example-videos": "4.0.314",
14
+ "@remotion/eslint-config-internal": "4.0.314"
15
15
  },
16
16
  "publishConfig": {
17
17
  "access": "public"