@remotion/media-parser 4.0.242 → 4.0.243

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.
@@ -2,13 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.convertAudioOrVideoSampleToWebCodecsTimestamps = void 0;
4
4
  const convertAudioOrVideoSampleToWebCodecsTimestamps = (sample, timescale) => {
5
- var _a;
6
5
  const { cts, dts, timestamp } = sample;
7
6
  return {
8
7
  cts: (cts * 1000000) / timescale,
9
8
  dts: (dts * 1000000) / timescale,
10
9
  timestamp: (timestamp * 1000000) / timescale,
11
- duration: (((_a = sample.duration) !== null && _a !== void 0 ? _a : 0) * 1000000) / timescale,
10
+ duration: sample.duration === undefined
11
+ ? undefined
12
+ : (sample.duration * 1000000) / timescale,
12
13
  data: sample.data,
13
14
  trackId: sample.trackId,
14
15
  type: sample.type,
@@ -83,6 +83,8 @@ const createMatroskaMedia = async ({ writer, onBytesProgress, onMillisecondsProg
83
83
  // In Safari, samples can arrive out of order, e.g public/bigbuckbunny.mp4
84
84
  // Therefore, only updating track number progress if it is a keyframe
85
85
  // to allow for timestamps to be lower than the previous one
86
+ var _a, _b;
87
+ progressTracker.setPossibleLowestTimestamp(Math.min(chunk.timestamp, (_a = chunk.cts) !== null && _a !== void 0 ? _a : Infinity, (_b = chunk.dts) !== null && _b !== void 0 ? _b : Infinity));
86
88
  const smallestProgress = progressTracker.getSmallestProgress();
87
89
  if (!currentCluster.shouldMakeNewCluster({
88
90
  newT: smallestProgress,
@@ -54,10 +54,10 @@ const makeProgressTracker = () => {
54
54
  waitForProgress: () => {
55
55
  const { promise, resolve } = (0, with_resolvers_1.withResolvers)();
56
56
  const on = () => {
57
- eventEmitter.removeEventListener('processed', on);
57
+ eventEmitter.removeEventListener('progress', on);
58
58
  resolve();
59
59
  };
60
- eventEmitter.addEventListener('processed', on);
60
+ eventEmitter.addEventListener('progress', on);
61
61
  return promise;
62
62
  },
63
63
  getStartingTimestamp,
@@ -1367,7 +1367,7 @@ var createIsoBaseMediaFtyp = ({
1367
1367
  };
1368
1368
 
1369
1369
  // src/version.ts
1370
- var VERSION = "4.0.242";
1370
+ var VERSION = "4.0.243";
1371
1371
 
1372
1372
  // src/create/iso-base-media/create-ilst.ts
1373
1373
  var createIlst = (items) => {
@@ -3230,6 +3230,7 @@ var createMatroskaMedia = async ({
3230
3230
  chunk,
3231
3231
  isVideo
3232
3232
  }) => {
3233
+ progressTracker.setPossibleLowestTimestamp(Math.min(chunk.timestamp, chunk.cts ?? Infinity, chunk.dts ?? Infinity));
3233
3234
  const smallestProgress = progressTracker.getSmallestProgress();
3234
3235
  if (!currentCluster.shouldMakeNewCluster({
3235
3236
  newT: smallestProgress,
@@ -3403,10 +3404,10 @@ var makeProgressTracker = () => {
3403
3404
  waitForProgress: () => {
3404
3405
  const { promise, resolve } = withResolvers();
3405
3406
  const on = () => {
3406
- eventEmitter.removeEventListener("processed", on);
3407
+ eventEmitter.removeEventListener("progress", on);
3407
3408
  resolve();
3408
3409
  };
3409
- eventEmitter.addEventListener("processed", on);
3410
+ eventEmitter.addEventListener("progress", on);
3410
3411
  return promise;
3411
3412
  },
3412
3413
  getStartingTimestamp,
@@ -4488,7 +4489,8 @@ var isRiffAvi2 = (data) => {
4488
4489
  return false;
4489
4490
  }
4490
4491
  const fileType = data.subarray(8, 12);
4491
- return new TextDecoder().decode(fileType) === "AVI ";
4492
+ const aviPattern = new Uint8Array([65, 86, 73, 32]);
4493
+ return matchesPattern(aviPattern)(fileType);
4492
4494
  };
4493
4495
  var isRiffWave = (data) => {
4494
4496
  const riffPattern = new Uint8Array([82, 73, 70, 70]);
@@ -4496,7 +4498,8 @@ var isRiffWave = (data) => {
4496
4498
  return false;
4497
4499
  }
4498
4500
  const fileType = data.subarray(8, 12);
4499
- return new TextDecoder().decode(fileType) === "WAVE";
4501
+ const wavePattern = new Uint8Array([87, 65, 86, 69]);
4502
+ return matchesPattern(wavePattern)(fileType);
4500
4503
  };
4501
4504
  var isWebm = (data) => {
4502
4505
  return matchesPattern(webmPattern)(data.subarray(0, 4));
@@ -7217,7 +7220,7 @@ var convertAudioOrVideoSampleToWebCodecsTimestamps = (sample, timescale2) => {
7217
7220
  cts: cts * 1e6 / timescale2,
7218
7221
  dts: dts * 1e6 / timescale2,
7219
7222
  timestamp: timestamp * 1e6 / timescale2,
7220
- duration: (sample.duration ?? 0) * 1e6 / timescale2,
7223
+ duration: sample.duration === undefined ? undefined : sample.duration * 1e6 / timescale2,
7221
7224
  data: sample.data,
7222
7225
  trackId: sample.trackId,
7223
7226
  type: sample.type,
@@ -11907,10 +11910,12 @@ var sampleCallback = ({
11907
11910
  if (typeof samplesForTrack[trackId] === "undefined") {
11908
11911
  samplesForTrack[trackId] = 0;
11909
11912
  }
11910
- samplesForTrack[trackId]++;
11911
11913
  const callback = audioSampleCallbacks[trackId];
11912
- if (callback) {
11913
- await callback(audioSample);
11914
+ if (audioSample.data.length > 0) {
11915
+ samplesForTrack[trackId]++;
11916
+ if (callback) {
11917
+ await callback(audioSample);
11918
+ }
11914
11919
  }
11915
11920
  },
11916
11921
  getSamplesForTrack: (trackId) => {
@@ -11923,10 +11928,12 @@ var sampleCallback = ({
11923
11928
  if (typeof samplesForTrack[trackId] === "undefined") {
11924
11929
  samplesForTrack[trackId] = 0;
11925
11930
  }
11926
- samplesForTrack[trackId]++;
11927
- const callback = videoSampleCallbacks[trackId];
11928
- if (callback && videoSample.data.length > 0) {
11929
- await callback(videoSample);
11931
+ if (videoSample.data.length > 0) {
11932
+ samplesForTrack[trackId]++;
11933
+ const callback = videoSampleCallbacks[trackId];
11934
+ if (callback) {
11935
+ await callback(videoSample);
11936
+ }
11930
11937
  }
11931
11938
  if (needsToIterateOverSamples({
11932
11939
  fields,
@@ -14,7 +14,8 @@ const isRiffAvi = (data) => {
14
14
  return false;
15
15
  }
16
16
  const fileType = data.subarray(8, 12);
17
- return new TextDecoder().decode(fileType) === 'AVI ';
17
+ const aviPattern = new Uint8Array([0x41, 0x56, 0x49, 0x20]);
18
+ return (0, exports.matchesPattern)(aviPattern)(fileType);
18
19
  };
19
20
  exports.isRiffAvi = isRiffAvi;
20
21
  const isRiffWave = (data) => {
@@ -23,7 +24,8 @@ const isRiffWave = (data) => {
23
24
  return false;
24
25
  }
25
26
  const fileType = data.subarray(8, 12);
26
- return new TextDecoder().decode(fileType) === 'WAVE';
27
+ const wavePattern = new Uint8Array([0x57, 0x41, 0x56, 0x45]);
28
+ return (0, exports.matchesPattern)(wavePattern)(fileType);
27
29
  };
28
30
  exports.isRiffWave = isRiffWave;
29
31
  const isWebm = (data) => {
@@ -36,10 +36,13 @@ const sampleCallback = ({ signal, hasAudioTrackHandlers, hasVideoTrackHandlers,
36
36
  if (typeof samplesForTrack[trackId] === 'undefined') {
37
37
  samplesForTrack[trackId] = 0;
38
38
  }
39
- samplesForTrack[trackId]++;
40
39
  const callback = audioSampleCallbacks[trackId];
41
- if (callback) {
42
- await callback(audioSample);
40
+ if (audioSample.data.length > 0) {
41
+ samplesForTrack[trackId]++;
42
+ // If we emit samples with data length 0, Chrome will fail
43
+ if (callback) {
44
+ await callback(audioSample);
45
+ }
43
46
  }
44
47
  },
45
48
  getSamplesForTrack: (trackId) => {
@@ -53,11 +56,13 @@ const sampleCallback = ({ signal, hasAudioTrackHandlers, hasVideoTrackHandlers,
53
56
  if (typeof samplesForTrack[trackId] === 'undefined') {
54
57
  samplesForTrack[trackId] = 0;
55
58
  }
56
- samplesForTrack[trackId]++;
57
- const callback = videoSampleCallbacks[trackId];
58
- // If we emit samples with data 0, Chrome will fail
59
- if (callback && videoSample.data.length > 0) {
60
- await callback(videoSample);
59
+ if (videoSample.data.length > 0) {
60
+ samplesForTrack[trackId]++;
61
+ const callback = videoSampleCallbacks[trackId];
62
+ // If we emit samples with data 0, Chrome will fail
63
+ if (callback) {
64
+ await callback(videoSample);
65
+ }
61
66
  }
62
67
  if ((0, need_samples_for_fields_1.needsToIterateOverSamples)({
63
68
  fields,
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "4.0.242";
1
+ export declare const VERSION = "4.0.243";
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.242';
5
+ exports.VERSION = '4.0.243';
package/package.json CHANGED
@@ -3,14 +3,14 @@
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.242",
6
+ "version": "4.0.243",
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.14.0",
12
- "@remotion/example-videos": "4.0.242",
13
- "@remotion/eslint-config-internal": "4.0.242"
12
+ "@remotion/example-videos": "4.0.243",
13
+ "@remotion/eslint-config-internal": "4.0.243"
14
14
  },
15
15
  "publishConfig": {
16
16
  "access": "public"