@remotion/media-parser 4.0.306 → 4.0.308

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.
@@ -1,9 +1,9 @@
1
1
  import type { MediaParserController } from '../../controller/media-parser-controller';
2
2
  import type { M3uState } from '../../state/m3u-state';
3
- import type { MediaParserVideoSample } from '../../webcodec-sample-types';
3
+ import type { MediaParserOnVideoSample, MediaParserVideoSample } from '../../webcodec-sample-types';
4
4
  export declare const considerSeekBasedOnChunk: ({ sample, parentController, childController, callback, m3uState, playlistUrl, subtractChunks, chunkIndex, }: {
5
5
  sample: MediaParserVideoSample;
6
- callback: (sample: MediaParserVideoSample) => void | Promise<void>;
6
+ callback: MediaParserOnVideoSample;
7
7
  parentController: MediaParserController;
8
8
  childController: MediaParserController;
9
9
  playlistUrl: string;
@@ -28,9 +28,12 @@ const parseWav = (state) => {
28
28
  if (type === 'LIST') {
29
29
  return (0, parse_list_1.parseList)({ state });
30
30
  }
31
- if (type === 'id3') {
31
+ if (type === 'id3' || type === 'ID3') {
32
32
  return (0, parse_id3_1.parseId3)({ state });
33
33
  }
34
+ if (type === '\u0000') {
35
+ return Promise.resolve(null);
36
+ }
34
37
  throw new Error(`Unknown WAV box type ${type}`);
35
38
  };
36
39
  exports.parseWav = parseWav;
@@ -1295,7 +1295,7 @@ var getArrayBufferIterator = (initialData, maxBytes) => {
1295
1295
  };
1296
1296
  const getSlice = (amount) => {
1297
1297
  const value = uintArray.slice(counter.getDiscardedOffset(), counter.getDiscardedOffset() + amount);
1298
- counter.increment(amount);
1298
+ counter.increment(value.length);
1299
1299
  return value;
1300
1300
  };
1301
1301
  const discard = (length) => {
@@ -15118,9 +15118,12 @@ var parseWav = (state) => {
15118
15118
  if (type === "LIST") {
15119
15119
  return parseList({ state });
15120
15120
  }
15121
- if (type === "id3") {
15121
+ if (type === "id3" || type === "ID3") {
15122
15122
  return parseId32({ state });
15123
15123
  }
15124
+ if (type === "\x00") {
15125
+ return Promise.resolve(null);
15126
+ }
15124
15127
  throw new Error(`Unknown WAV box type ${type}`);
15125
15128
  };
15126
15129
 
@@ -15625,6 +15628,7 @@ var parseLoop = async ({
15625
15628
  }
15626
15629
  }
15627
15630
  state.samplesObserved.setLastSampleObserved();
15631
+ await state.callbacks.callTracksDoneCallback();
15628
15632
  if (state.controller._internals.seekSignal.getSeek() !== null) {
15629
15633
  Log.verbose(state.logLevel, "Reached end of samples, but there is a pending seek. Trying to seek...");
15630
15634
  await workOnSeekRequest(getWorkOnSeekRequestOptions(state));
@@ -17007,6 +17011,7 @@ var callbacksState = ({
17007
17011
  }) => {
17008
17012
  const videoSampleCallbacks = {};
17009
17013
  const audioSampleCallbacks = {};
17014
+ const onTrackDoneCallback = {};
17010
17015
  const queuedAudioSamples = {};
17011
17016
  const queuedVideoSamples = {};
17012
17017
  const canSkipTracksState = makeCanSkipTracksState({
@@ -17041,7 +17046,8 @@ var callbacksState = ({
17041
17046
  if (seekSignal.getSeek() !== null) {
17042
17047
  Log.trace(logLevel, "Not emitting sample because seek is processing");
17043
17048
  } else {
17044
- await callback(audioSample);
17049
+ const trackDoneCallback = await callback(audioSample);
17050
+ onTrackDoneCallback[trackId] = trackDoneCallback ?? null;
17045
17051
  }
17046
17052
  }
17047
17053
  }
@@ -17062,7 +17068,8 @@ var callbacksState = ({
17062
17068
  if (seekSignal.getSeek() !== null) {
17063
17069
  Log.trace(logLevel, "Not emitting sample because seek is processing");
17064
17070
  } else {
17065
- await callback(videoSample);
17071
+ const trackDoneCallback = await callback(videoSample);
17072
+ onTrackDoneCallback[trackId] = trackDoneCallback ?? null;
17066
17073
  }
17067
17074
  }
17068
17075
  }
@@ -17098,7 +17105,14 @@ var callbacksState = ({
17098
17105
  audioSampleCallbacks,
17099
17106
  videoSampleCallbacks,
17100
17107
  hasAudioTrackHandlers,
17101
- hasVideoTrackHandlers
17108
+ hasVideoTrackHandlers,
17109
+ callTracksDoneCallback: async () => {
17110
+ for (const callback of Object.values(onTrackDoneCallback)) {
17111
+ if (callback) {
17112
+ await callback();
17113
+ }
17114
+ }
17115
+ }
17102
17116
  };
17103
17117
  };
17104
17118
 
@@ -17685,7 +17699,7 @@ var downloadAndParseMedia = async (options) => {
17685
17699
  return returnValue;
17686
17700
  };
17687
17701
  // src/version.ts
17688
- var VERSION = "4.0.306";
17702
+ var VERSION = "4.0.308";
17689
17703
 
17690
17704
  // src/index.ts
17691
17705
  var MediaParserInternals = {
@@ -2556,7 +2556,7 @@ var getArrayBufferIterator = (initialData, maxBytes) => {
2556
2556
  };
2557
2557
  const getSlice = (amount) => {
2558
2558
  const value = uintArray.slice(counter.getDiscardedOffset(), counter.getDiscardedOffset() + amount);
2559
- counter.increment(amount);
2559
+ counter.increment(value.length);
2560
2560
  return value;
2561
2561
  };
2562
2562
  const discard = (length) => {
@@ -14857,9 +14857,12 @@ var parseWav = (state) => {
14857
14857
  if (type === "LIST") {
14858
14858
  return parseList({ state });
14859
14859
  }
14860
- if (type === "id3") {
14860
+ if (type === "id3" || type === "ID3") {
14861
14861
  return parseId32({ state });
14862
14862
  }
14863
+ if (type === "\x00") {
14864
+ return Promise.resolve(null);
14865
+ }
14863
14866
  throw new Error(`Unknown WAV box type ${type}`);
14864
14867
  };
14865
14868
 
@@ -15753,6 +15756,7 @@ var parseLoop = async ({
15753
15756
  }
15754
15757
  }
15755
15758
  state.samplesObserved.setLastSampleObserved();
15759
+ await state.callbacks.callTracksDoneCallback();
15756
15760
  if (state.controller._internals.seekSignal.getSeek() !== null) {
15757
15761
  Log.verbose(state.logLevel, "Reached end of samples, but there is a pending seek. Trying to seek...");
15758
15762
  await workOnSeekRequest(getWorkOnSeekRequestOptions(state));
@@ -17135,6 +17139,7 @@ var callbacksState = ({
17135
17139
  }) => {
17136
17140
  const videoSampleCallbacks = {};
17137
17141
  const audioSampleCallbacks = {};
17142
+ const onTrackDoneCallback = {};
17138
17143
  const queuedAudioSamples = {};
17139
17144
  const queuedVideoSamples = {};
17140
17145
  const canSkipTracksState = makeCanSkipTracksState({
@@ -17169,7 +17174,8 @@ var callbacksState = ({
17169
17174
  if (seekSignal.getSeek() !== null) {
17170
17175
  Log.trace(logLevel, "Not emitting sample because seek is processing");
17171
17176
  } else {
17172
- await callback(audioSample);
17177
+ const trackDoneCallback = await callback(audioSample);
17178
+ onTrackDoneCallback[trackId] = trackDoneCallback ?? null;
17173
17179
  }
17174
17180
  }
17175
17181
  }
@@ -17190,7 +17196,8 @@ var callbacksState = ({
17190
17196
  if (seekSignal.getSeek() !== null) {
17191
17197
  Log.trace(logLevel, "Not emitting sample because seek is processing");
17192
17198
  } else {
17193
- await callback(videoSample);
17199
+ const trackDoneCallback = await callback(videoSample);
17200
+ onTrackDoneCallback[trackId] = trackDoneCallback ?? null;
17194
17201
  }
17195
17202
  }
17196
17203
  }
@@ -17226,7 +17233,14 @@ var callbacksState = ({
17226
17233
  audioSampleCallbacks,
17227
17234
  videoSampleCallbacks,
17228
17235
  hasAudioTrackHandlers,
17229
- hasVideoTrackHandlers
17236
+ hasVideoTrackHandlers,
17237
+ callTracksDoneCallback: async () => {
17238
+ for (const callback of Object.values(onTrackDoneCallback)) {
17239
+ if (callback) {
17240
+ await callback();
17241
+ }
17242
+ }
17243
+ }
17230
17244
  };
17231
17245
  };
17232
17246
 
@@ -2453,7 +2453,7 @@ var getArrayBufferIterator = (initialData, maxBytes) => {
2453
2453
  };
2454
2454
  const getSlice = (amount) => {
2455
2455
  const value = uintArray.slice(counter.getDiscardedOffset(), counter.getDiscardedOffset() + amount);
2456
- counter.increment(amount);
2456
+ counter.increment(value.length);
2457
2457
  return value;
2458
2458
  };
2459
2459
  const discard = (length) => {
@@ -14726,9 +14726,12 @@ var parseWav = (state) => {
14726
14726
  if (type === "LIST") {
14727
14727
  return parseList({ state });
14728
14728
  }
14729
- if (type === "id3") {
14729
+ if (type === "id3" || type === "ID3") {
14730
14730
  return parseId32({ state });
14731
14731
  }
14732
+ if (type === "\x00") {
14733
+ return Promise.resolve(null);
14734
+ }
14732
14735
  throw new Error(`Unknown WAV box type ${type}`);
14733
14736
  };
14734
14737
 
@@ -15622,6 +15625,7 @@ var parseLoop = async ({
15622
15625
  }
15623
15626
  }
15624
15627
  state.samplesObserved.setLastSampleObserved();
15628
+ await state.callbacks.callTracksDoneCallback();
15625
15629
  if (state.controller._internals.seekSignal.getSeek() !== null) {
15626
15630
  Log.verbose(state.logLevel, "Reached end of samples, but there is a pending seek. Trying to seek...");
15627
15631
  await workOnSeekRequest(getWorkOnSeekRequestOptions(state));
@@ -17004,6 +17008,7 @@ var callbacksState = ({
17004
17008
  }) => {
17005
17009
  const videoSampleCallbacks = {};
17006
17010
  const audioSampleCallbacks = {};
17011
+ const onTrackDoneCallback = {};
17007
17012
  const queuedAudioSamples = {};
17008
17013
  const queuedVideoSamples = {};
17009
17014
  const canSkipTracksState = makeCanSkipTracksState({
@@ -17038,7 +17043,8 @@ var callbacksState = ({
17038
17043
  if (seekSignal.getSeek() !== null) {
17039
17044
  Log.trace(logLevel, "Not emitting sample because seek is processing");
17040
17045
  } else {
17041
- await callback(audioSample);
17046
+ const trackDoneCallback = await callback(audioSample);
17047
+ onTrackDoneCallback[trackId] = trackDoneCallback ?? null;
17042
17048
  }
17043
17049
  }
17044
17050
  }
@@ -17059,7 +17065,8 @@ var callbacksState = ({
17059
17065
  if (seekSignal.getSeek() !== null) {
17060
17066
  Log.trace(logLevel, "Not emitting sample because seek is processing");
17061
17067
  } else {
17062
- await callback(videoSample);
17068
+ const trackDoneCallback = await callback(videoSample);
17069
+ onTrackDoneCallback[trackId] = trackDoneCallback ?? null;
17063
17070
  }
17064
17071
  }
17065
17072
  }
@@ -17095,7 +17102,14 @@ var callbacksState = ({
17095
17102
  audioSampleCallbacks,
17096
17103
  videoSampleCallbacks,
17097
17104
  hasAudioTrackHandlers,
17098
- hasVideoTrackHandlers
17105
+ hasVideoTrackHandlers,
17106
+ callTracksDoneCallback: async () => {
17107
+ for (const callback of Object.values(onTrackDoneCallback)) {
17108
+ if (callback) {
17109
+ await callback();
17110
+ }
17111
+ }
17112
+ }
17099
17113
  };
17100
17114
  };
17101
17115
 
package/dist/index.d.ts CHANGED
@@ -1051,6 +1051,7 @@ export declare const MediaParserInternals: {
1051
1051
  videoSampleCallbacks: Record<number, import("./webcodec-sample-types").MediaParserOnVideoSample>;
1052
1052
  hasAudioTrackHandlers: boolean;
1053
1053
  hasVideoTrackHandlers: boolean;
1054
+ callTracksDoneCallback: () => Promise<void>;
1054
1055
  };
1055
1056
  getInternalStats: () => import("./state/parser-state").InternalStats;
1056
1057
  getSkipBytes: () => number;
@@ -20,7 +20,7 @@ const getArrayBufferIterator = (initialData, maxBytes) => {
20
20
  };
21
21
  const getSlice = (amount) => {
22
22
  const value = uintArray.slice(counter.getDiscardedOffset(), counter.getDiscardedOffset() + amount);
23
- counter.increment(amount);
23
+ counter.increment(value.length);
24
24
  return value;
25
25
  };
26
26
  const discard = (length) => {
@@ -117,6 +117,7 @@ const parseLoop = async ({ state, throttledState, onError, }) => {
117
117
  }
118
118
  }
119
119
  state.samplesObserved.setLastSampleObserved();
120
+ await state.callbacks.callTracksDoneCallback();
120
121
  // After the last sample, you might queue a last seek again.
121
122
  if (state.controller._internals.seekSignal.getSeek() !== null) {
122
123
  log_1.Log.verbose(state.logLevel, 'Reached end of samples, but there is a pending seek. Trying to seek...');
@@ -319,6 +319,7 @@ export declare const makeParserState: ({ hasAudioTrackHandlers, hasVideoTrackHan
319
319
  videoSampleCallbacks: Record<number, import("../webcodec-sample-types").MediaParserOnVideoSample>;
320
320
  hasAudioTrackHandlers: boolean;
321
321
  hasVideoTrackHandlers: boolean;
322
+ callTracksDoneCallback: () => Promise<void>;
322
323
  };
323
324
  getInternalStats: () => InternalStats;
324
325
  getSkipBytes: () => number;
@@ -46,5 +46,6 @@ export declare const callbacksState: ({ controller, hasAudioTrackHandlers, hasVi
46
46
  videoSampleCallbacks: Record<number, MediaParserOnVideoSample>;
47
47
  hasAudioTrackHandlers: boolean;
48
48
  hasVideoTrackHandlers: boolean;
49
+ callTracksDoneCallback: () => Promise<void>;
49
50
  };
50
51
  export type CallbacksState = ReturnType<typeof callbacksState>;
@@ -9,6 +9,7 @@ const need_samples_for_fields_1 = require("./need-samples-for-fields");
9
9
  const callbacksState = ({ controller, hasAudioTrackHandlers, hasVideoTrackHandlers, fields, keyframes, emittedFields, samplesObserved, structure, src, seekSignal, logLevel, }) => {
10
10
  const videoSampleCallbacks = {};
11
11
  const audioSampleCallbacks = {};
12
+ const onTrackDoneCallback = {};
12
13
  const queuedAudioSamples = {};
13
14
  const queuedVideoSamples = {};
14
15
  const canSkipTracksState = (0, can_skip_tracks_1.makeCanSkipTracksState)({
@@ -43,7 +44,8 @@ const callbacksState = ({ controller, hasAudioTrackHandlers, hasVideoTrackHandle
43
44
  log_1.Log.trace(logLevel, 'Not emitting sample because seek is processing');
44
45
  }
45
46
  else {
46
- await callback(audioSample);
47
+ const trackDoneCallback = await callback(audioSample);
48
+ onTrackDoneCallback[trackId] = trackDoneCallback !== null && trackDoneCallback !== void 0 ? trackDoneCallback : null;
47
49
  }
48
50
  }
49
51
  }
@@ -63,7 +65,8 @@ const callbacksState = ({ controller, hasAudioTrackHandlers, hasVideoTrackHandle
63
65
  log_1.Log.trace(logLevel, 'Not emitting sample because seek is processing');
64
66
  }
65
67
  else {
66
- await callback(videoSample);
68
+ const trackDoneCallback = await callback(videoSample);
69
+ onTrackDoneCallback[trackId] = trackDoneCallback !== null && trackDoneCallback !== void 0 ? trackDoneCallback : null;
67
70
  }
68
71
  }
69
72
  }
@@ -101,6 +104,13 @@ const callbacksState = ({ controller, hasAudioTrackHandlers, hasVideoTrackHandle
101
104
  videoSampleCallbacks,
102
105
  hasAudioTrackHandlers,
103
106
  hasVideoTrackHandlers,
107
+ callTracksDoneCallback: async () => {
108
+ for (const callback of Object.values(onTrackDoneCallback)) {
109
+ if (callback) {
110
+ await callback();
111
+ }
112
+ }
113
+ },
104
114
  };
105
115
  };
106
116
  exports.callbacksState = callbacksState;
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "4.0.306";
1
+ export declare const VERSION = "4.0.308";
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.306';
5
+ exports.VERSION = '4.0.308';
@@ -1,7 +1,8 @@
1
1
  import type { MediaParserAudioTrack, MediaParserVideoTrack } from './get-tracks';
2
2
  import type { MediaParserContainer } from './options';
3
- export type MediaParserOnAudioSample = (sample: MediaParserAudioSample) => void | Promise<void>;
4
- export type MediaParserOnVideoSample = (sample: MediaParserVideoSample) => void | Promise<void>;
3
+ export type MediaParserOnAudioSample = (sample: MediaParserAudioSample) => void | Promise<void> | OnTrackDoneCallback | Promise<OnTrackDoneCallback>;
4
+ export type MediaParserOnVideoSample = (sample: MediaParserVideoSample) => void | Promise<void> | OnTrackDoneCallback | Promise<OnTrackDoneCallback>;
5
+ export type OnTrackDoneCallback = () => void | Promise<void>;
5
6
  export type MediaParserOnAudioTrackParams = {
6
7
  track: MediaParserAudioTrack;
7
8
  container: MediaParserContainer;
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.306",
6
+ "version": "4.0.308",
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/example-videos": "4.0.306",
14
- "@remotion/eslint-config-internal": "4.0.306"
13
+ "@remotion/example-videos": "4.0.308",
14
+ "@remotion/eslint-config-internal": "4.0.308"
15
15
  },
16
16
  "publishConfig": {
17
17
  "access": "public"
@@ -1,7 +0,0 @@
1
- import type { MediaParserOnVideoSample, MediaParserVideoSample } from '../webcodec-sample-types';
2
- export declare function deferSampleReleaseCallback(callback: MediaParserOnVideoSample): {
3
- addSample: (sample: MediaParserVideoSample) => Promise<void>;
4
- flush: () => Promise<void>;
5
- clear: () => void;
6
- };
7
- export type DeferredSampleRelease = ReturnType<typeof deferSampleReleaseCallback>;
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deferSampleReleaseCallback = deferSampleReleaseCallback;
4
- function deferSampleReleaseCallback(callback) {
5
- let hold = null;
6
- return {
7
- addSample: async (sample) => {
8
- if (hold) {
9
- await callback(hold);
10
- }
11
- hold = sample;
12
- },
13
- flush: async () => {
14
- if (hold) {
15
- await callback({ ...hold, isLast: true });
16
- hold = null;
17
- }
18
- },
19
- clear: () => {
20
- hold = null;
21
- },
22
- };
23
- }
@@ -1,9 +0,0 @@
1
- import type { MediaParserVideoSample } from '../../webcodec-sample-types';
2
- export type QueuedVideoSample = Omit<MediaParserVideoSample, 'cts' | 'dts' | 'timestamp'>;
3
- export declare const queuedBFramesState: () => {
4
- addFrame: (frame: QueuedVideoSample, maxFramesInBuffer: number) => void;
5
- flush: () => void;
6
- getReleasedFrame: () => QueuedVideoSample | null;
7
- hasReleasedFrames: () => boolean;
8
- clear: () => void;
9
- };
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.queuedBFramesState = void 0;
4
- const queuedBFramesState = () => {
5
- const queuedFrames = [];
6
- const releasedFrames = [];
7
- const sortFrames = () => {
8
- queuedFrames.sort((a, b) => {
9
- if (!a.avc || !b.avc || a.avc.poc === null || b.avc.poc === null) {
10
- throw new Error('Invalid frame');
11
- }
12
- return a.avc.poc - b.avc.poc;
13
- });
14
- };
15
- const flush = () => {
16
- sortFrames();
17
- releasedFrames.push(...queuedFrames);
18
- queuedFrames.length = 0;
19
- };
20
- return {
21
- addFrame: (frame, maxFramesInBuffer) => {
22
- if (frame.type === 'key') {
23
- flush();
24
- }
25
- queuedFrames.push(frame);
26
- if (queuedFrames.length > maxFramesInBuffer) {
27
- sortFrames();
28
- releasedFrames.push(queuedFrames.shift());
29
- }
30
- },
31
- flush,
32
- getReleasedFrame: () => {
33
- if (releasedFrames.length === 0) {
34
- return null;
35
- }
36
- return releasedFrames.shift();
37
- },
38
- hasReleasedFrames: () => {
39
- return releasedFrames.length > 0;
40
- },
41
- clear: () => {
42
- releasedFrames.length = 0;
43
- queuedFrames.length = 0;
44
- },
45
- };
46
- };
47
- exports.queuedBFramesState = queuedBFramesState;