@remotion/media-parser 4.0.226 → 4.0.227

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.
@@ -45,7 +45,6 @@ const parseMdat = async ({ data, size, fileOffset, existingBoxes, options, signa
45
45
  });
46
46
  })
47
47
  .flat(1);
48
- // eslint-disable-next-line no-constant-condition
49
48
  while (true) {
50
49
  if (signal && signal.aborted) {
51
50
  break;
@@ -38,6 +38,7 @@ const getChildren = async ({ boxType, iterator, bytesRemainingInBox, options, li
38
38
  boxType === 'traf' ||
39
39
  boxType === 'stsb';
40
40
  if (parseChildren) {
41
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
41
42
  const parsed = await (0, exports.parseBoxes)({
42
43
  iterator,
43
44
  maxBytes: bytesRemainingInBox,
@@ -1,2 +1,2 @@
1
- export declare const measureEBMLVarInt: (value: number) => 2 | 1 | 5 | 3 | 6 | 4;
1
+ export declare const measureEBMLVarInt: (value: number) => 2 | 1 | 4 | 3 | 5 | 6;
2
2
  export declare const getVariableInt: (value: number, minWidth: number | null) => Uint8Array;
@@ -30,7 +30,7 @@ const getSampleFromBlock = (ebml, parserContext, offset) => {
30
30
  if (!codec) {
31
31
  throw new Error(`Could not find codec for track ${trackNumber}`);
32
32
  }
33
- const remainingNow = ebml.value.length - (iterator.counter.getOffset() - 0);
33
+ const remainingNow = ebml.value.length - iterator.counter.getOffset();
34
34
  if (codec.startsWith('V_')) {
35
35
  const partialVideoSample = {
36
36
  data: iterator.getSlice(remainingNow),
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.combineUint8Arrays = exports.padMatroskaBytes = exports.makeMatroskaBytes = exports.matroskaToHex = exports.webmPattern = void 0;
4
4
  exports.serializeUint16 = serializeUint16;
5
+ /* eslint-disable @typescript-eslint/no-use-before-define */
5
6
  const ebml_1 = require("./ebml");
6
7
  const all_segments_1 = require("./segments/all-segments");
7
8
  exports.webmPattern = new Uint8Array([0x1a, 0x45, 0xdf, 0xa3]);
@@ -77,13 +77,13 @@ const parseEbml = async (iterator, parserContext) => {
77
77
  if (hasInMap.type === 'children') {
78
78
  const children = [];
79
79
  const startOffset = iterator.counter.getOffset();
80
- // eslint-disable-next-line no-constant-condition
81
80
  while (true) {
82
81
  if (size === 0) {
83
82
  break;
84
83
  }
85
84
  const offset = iterator.counter.getOffset();
86
85
  const value = await (0, exports.parseEbml)(iterator, parserContext);
86
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
87
87
  const remapped = await (0, exports.postprocessEbml)({
88
88
  offset,
89
89
  ebml: value,
@@ -51,6 +51,7 @@ const continueParsingfunction = ({ result, iterator, children, wrap, parserConte
51
51
  segments: wrap ? [wrap(children)] : children,
52
52
  };
53
53
  }
54
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
54
55
  return (0, exports.expectChildren)({
55
56
  iterator,
56
57
  length: length - (iterator.counter.getOffset() - offset),
@@ -13,6 +13,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
13
13
  var _OffsetCounter_offset, _OffsetCounter_discardedBytes;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.getArrayBufferIterator = exports.OffsetCounter = void 0;
16
+ /* eslint-disable @typescript-eslint/no-use-before-define */
16
17
  const make_header_1 = require("./boxes/webm/make-header");
17
18
  const all_segments_1 = require("./boxes/webm/segments/all-segments");
18
19
  class OffsetCounter {
@@ -85,6 +85,10 @@ const createMedia = async (writer) => {
85
85
  currentCluster = await (0, cluster_1.makeCluster)(w, smallestProgress);
86
86
  return { cluster: currentCluster, isNew: true, smallestProgress };
87
87
  };
88
+ const updateDuration = async (newDuration) => {
89
+ const blocks = (0, make_duration_with_padding_1.makeDurationWithPadding)(newDuration);
90
+ await w.updateDataAt(durationOffset, blocks.bytes);
91
+ };
88
92
  const addSample = async (chunk, trackNumber, isVideo) => {
89
93
  var _a;
90
94
  trackNumberProgresses[trackNumber] = chunk.timestamp;
@@ -105,10 +109,6 @@ const createMedia = async (writer) => {
105
109
  });
106
110
  }
107
111
  };
108
- const updateDuration = async (newDuration) => {
109
- const blocks = (0, make_duration_with_padding_1.makeDurationWithPadding)(newDuration);
110
- await w.updateDataAt(durationOffset, blocks.bytes);
111
- };
112
112
  const addTrack = async (track) => {
113
113
  currentTracks.push(track);
114
114
  const newTracks = (0, matroska_trackentry_1.makeMatroskaTracks)(currentTracks);
@@ -1888,6 +1888,10 @@ var createMedia = async (writer) => {
1888
1888
  currentCluster = await makeCluster(w, smallestProgress);
1889
1889
  return { cluster: currentCluster, isNew: true, smallestProgress };
1890
1890
  };
1891
+ const updateDuration = async (newDuration) => {
1892
+ const blocks = makeDurationWithPadding(newDuration);
1893
+ await w.updateDataAt(durationOffset, blocks.bytes);
1894
+ };
1891
1895
  const addSample = async (chunk, trackNumber2, isVideo) => {
1892
1896
  trackNumberProgresses[trackNumber2] = chunk.timestamp;
1893
1897
  const { cluster, isNew, smallestProgress } = await getClusterOrMakeNew({
@@ -1906,10 +1910,6 @@ var createMedia = async (writer) => {
1906
1910
  });
1907
1911
  }
1908
1912
  };
1909
- const updateDuration = async (newDuration) => {
1910
- const blocks = makeDurationWithPadding(newDuration);
1911
- await w.updateDataAt(durationOffset, blocks.bytes);
1912
- };
1913
1913
  const addTrack = async (track) => {
1914
1914
  currentTracks.push(track);
1915
1915
  const newTracks = makeMatroskaTracks(currentTracks);
@@ -2194,16 +2194,31 @@ var getFps = (segments) => {
2194
2194
  var hasFps = (boxes) => {
2195
2195
  try {
2196
2196
  return getFps(boxes) !== null;
2197
- } catch (err) {
2197
+ } catch {
2198
2198
  return false;
2199
2199
  }
2200
2200
  };
2201
2201
 
2202
2202
  // src/get-audio-codec.ts
2203
+ var getAudioCodec = (boxes, parserState) => {
2204
+ const tracks2 = getTracks(boxes, parserState);
2205
+ const allTracks = tracks2.audioTracks.length + tracks2.otherTracks.length + tracks2.videoTracks.length;
2206
+ if (allTracks === 0) {
2207
+ throw new Error("No tracks yet");
2208
+ }
2209
+ const audioTrack = tracks2.audioTracks[0];
2210
+ if (!audioTrack) {
2211
+ return null;
2212
+ }
2213
+ if (audioTrack.type === "audio") {
2214
+ return audioTrack.codecWithoutConfig;
2215
+ }
2216
+ return null;
2217
+ };
2203
2218
  var hasAudioCodec = (boxes, state) => {
2204
2219
  try {
2205
2220
  return getAudioCodec(boxes, state) !== null;
2206
- } catch (e) {
2221
+ } catch {
2207
2222
  return false;
2208
2223
  }
2209
2224
  };
@@ -2342,21 +2357,6 @@ var getAudioCodecFromTrack = (track) => {
2342
2357
  }
2343
2358
  return getAudioCodecFromAudioCodecInfo(audioSample);
2344
2359
  };
2345
- var getAudioCodec = (boxes, parserState) => {
2346
- const tracks2 = getTracks(boxes, parserState);
2347
- const allTracks = tracks2.audioTracks.length + tracks2.otherTracks.length + tracks2.videoTracks.length;
2348
- if (allTracks === 0) {
2349
- throw new Error("No tracks yet");
2350
- }
2351
- const audioTrack = tracks2.audioTracks[0];
2352
- if (!audioTrack) {
2353
- return null;
2354
- }
2355
- if (audioTrack.type === "audio") {
2356
- return audioTrack.codecWithoutConfig;
2357
- }
2358
- return null;
2359
- };
2360
2360
 
2361
2361
  // src/get-sample-aspect-ratio.ts
2362
2362
  function gcd(a, b) {
@@ -2982,68 +2982,6 @@ var parseAv1PrivateData = (data, colrAtom) => {
2982
2982
  };
2983
2983
 
2984
2984
  // src/get-video-codec.ts
2985
- var hasVideoCodec = (boxes) => {
2986
- try {
2987
- return getVideoCodec(boxes) !== null;
2988
- } catch (e) {
2989
- return false;
2990
- }
2991
- };
2992
- var getVideoPrivateData = (trakBox) => {
2993
- const videoSample = getStsdVideoConfig(trakBox);
2994
- const avccBox = getAvccBox(trakBox);
2995
- const hvccBox = getHvccBox(trakBox);
2996
- const av1cBox = getAv1CBox(trakBox);
2997
- if (!videoSample) {
2998
- return null;
2999
- }
3000
- if (avccBox) {
3001
- return avccBox.privateData;
3002
- }
3003
- if (hvccBox) {
3004
- return hvccBox.privateData;
3005
- }
3006
- if (av1cBox) {
3007
- return av1cBox.privateData;
3008
- }
3009
- return null;
3010
- };
3011
- var getIsoBmColrConfig = (trakBox) => {
3012
- const videoSample = getStsdVideoConfig(trakBox);
3013
- if (!videoSample) {
3014
- return null;
3015
- }
3016
- const colrAtom = getColrBox(videoSample);
3017
- if (!colrAtom) {
3018
- return null;
3019
- }
3020
- return {
3021
- fullRange: colrAtom.fullRangeFlag,
3022
- matrixCoefficients: colrAtom.matrixIndex === 1 ? "bt709" : colrAtom.matrixIndex === 5 ? "bt470bg" : colrAtom.matrixIndex === 6 ? "smpte170m" : null,
3023
- primaries: colrAtom.primaries === 1 ? "bt709" : colrAtom.primaries === 5 ? "bt470bg" : colrAtom.primaries === 6 ? "smpte170m" : null,
3024
- transferCharacteristics: colrAtom.transfer === 1 ? "bt709" : colrAtom.transfer === 6 ? "smpte170m" : colrAtom.transfer === 13 ? "iec61966-2-1" : null
3025
- };
3026
- };
3027
- var getVideoCodecString = (trakBox) => {
3028
- const videoSample = getStsdVideoConfig(trakBox);
3029
- const avccBox = getAvccBox(trakBox);
3030
- const hvccBox = getHvccBox(trakBox);
3031
- const av1cBox = getAv1CBox(trakBox);
3032
- if (!videoSample) {
3033
- return null;
3034
- }
3035
- if (avccBox) {
3036
- return `${videoSample.format}.${avccBox.configurationString}`;
3037
- }
3038
- if (hvccBox) {
3039
- return `${videoSample.format}.${hvccBox.configurationString}`;
3040
- }
3041
- if (av1cBox) {
3042
- const colrAtom = getColrBox(videoSample);
3043
- return parseAv1PrivateData(av1cBox.privateData, colrAtom);
3044
- }
3045
- return videoSample.format;
3046
- };
3047
2985
  var getVideoCodecFromIsoTrak = (trakBox) => {
3048
2986
  const stsdBox = getStsdBox(trakBox);
3049
2987
  if (stsdBox && stsdBox.type === "stsd-box") {
@@ -3126,6 +3064,68 @@ var getVideoCodec = (boxes) => {
3126
3064
  }
3127
3065
  return null;
3128
3066
  };
3067
+ var hasVideoCodec = (boxes) => {
3068
+ try {
3069
+ return getVideoCodec(boxes) !== null;
3070
+ } catch {
3071
+ return false;
3072
+ }
3073
+ };
3074
+ var getVideoPrivateData = (trakBox) => {
3075
+ const videoSample = getStsdVideoConfig(trakBox);
3076
+ const avccBox = getAvccBox(trakBox);
3077
+ const hvccBox = getHvccBox(trakBox);
3078
+ const av1cBox = getAv1CBox(trakBox);
3079
+ if (!videoSample) {
3080
+ return null;
3081
+ }
3082
+ if (avccBox) {
3083
+ return avccBox.privateData;
3084
+ }
3085
+ if (hvccBox) {
3086
+ return hvccBox.privateData;
3087
+ }
3088
+ if (av1cBox) {
3089
+ return av1cBox.privateData;
3090
+ }
3091
+ return null;
3092
+ };
3093
+ var getIsoBmColrConfig = (trakBox) => {
3094
+ const videoSample = getStsdVideoConfig(trakBox);
3095
+ if (!videoSample) {
3096
+ return null;
3097
+ }
3098
+ const colrAtom = getColrBox(videoSample);
3099
+ if (!colrAtom) {
3100
+ return null;
3101
+ }
3102
+ return {
3103
+ fullRange: colrAtom.fullRangeFlag,
3104
+ matrixCoefficients: colrAtom.matrixIndex === 1 ? "bt709" : colrAtom.matrixIndex === 5 ? "bt470bg" : colrAtom.matrixIndex === 6 ? "smpte170m" : null,
3105
+ primaries: colrAtom.primaries === 1 ? "bt709" : colrAtom.primaries === 5 ? "bt470bg" : colrAtom.primaries === 6 ? "smpte170m" : null,
3106
+ transferCharacteristics: colrAtom.transfer === 1 ? "bt709" : colrAtom.transfer === 6 ? "smpte170m" : colrAtom.transfer === 13 ? "iec61966-2-1" : null
3107
+ };
3108
+ };
3109
+ var getVideoCodecString = (trakBox) => {
3110
+ const videoSample = getStsdVideoConfig(trakBox);
3111
+ const avccBox = getAvccBox(trakBox);
3112
+ const hvccBox = getHvccBox(trakBox);
3113
+ const av1cBox = getAv1CBox(trakBox);
3114
+ if (!videoSample) {
3115
+ return null;
3116
+ }
3117
+ if (avccBox) {
3118
+ return `${videoSample.format}.${avccBox.configurationString}`;
3119
+ }
3120
+ if (hvccBox) {
3121
+ return `${videoSample.format}.${hvccBox.configurationString}`;
3122
+ }
3123
+ if (av1cBox) {
3124
+ const colrAtom = getColrBox(videoSample);
3125
+ return parseAv1PrivateData(av1cBox.privateData, colrAtom);
3126
+ }
3127
+ return videoSample.format;
3128
+ };
3129
3129
 
3130
3130
  // src/boxes/iso-base-media/make-track.ts
3131
3131
  var makeBaseMediaTrack = (trakBox) => {
@@ -3673,7 +3673,7 @@ var getContainer = (segments) => {
3673
3673
  var hasContainer = (boxes) => {
3674
3674
  try {
3675
3675
  return getContainer(boxes) !== null;
3676
- } catch (e) {
3676
+ } catch {
3677
3677
  return false;
3678
3678
  }
3679
3679
  };
@@ -3696,7 +3696,7 @@ var getDimensions = (boxes, state) => {
3696
3696
  var hasDimensions = (boxes, state) => {
3697
3697
  try {
3698
3698
  return getDimensions(boxes, state) !== null;
3699
- } catch (err) {
3699
+ } catch {
3700
3700
  return false;
3701
3701
  }
3702
3702
  };
@@ -3929,7 +3929,7 @@ var hasDuration = (boxes, parserState) => {
3929
3929
  try {
3930
3930
  const duration2 = getDuration(boxes, parserState);
3931
3931
  return getDuration(boxes, parserState) !== null && duration2 !== 0;
3932
- } catch (err) {
3932
+ } catch {
3933
3933
  return false;
3934
3934
  }
3935
3935
  };
@@ -6094,7 +6094,7 @@ var getSampleFromBlock = (ebml, parserContext, offset) => {
6094
6094
  if (!codec) {
6095
6095
  throw new Error(`Could not find codec for track ${trackNumber2}`);
6096
6096
  }
6097
- const remainingNow = ebml.value.length - (iterator.counter.getOffset() - 0);
6097
+ const remainingNow = ebml.value.length - iterator.counter.getOffset();
6098
6098
  if (codec.startsWith("V_")) {
6099
6099
  const partialVideoSample = {
6100
6100
  data: iterator.getSlice(remainingNow),
@@ -30,7 +30,7 @@ var createContent = async () => {
30
30
  save: async () => {
31
31
  try {
32
32
  await writable.close();
33
- } catch (err) {
33
+ } catch {
34
34
  }
35
35
  const newHandle = await directoryHandle.getFileHandle(filename, {
36
36
  create: true
@@ -3,6 +3,7 @@ import type { TrakBox } from './boxes/iso-base-media/trak/trak';
3
3
  import { type MediaParserAudioCodec } from './get-tracks';
4
4
  import type { AnySegment } from './parse-result';
5
5
  import type { ParserState } from './parser-state';
6
+ export declare const getAudioCodec: (boxes: AnySegment[], parserState: ParserState) => MediaParserAudioCodec | null;
6
7
  export declare const hasAudioCodec: (boxes: AnySegment[], state: ParserState) => boolean;
7
8
  type AudioCodecInfo = {
8
9
  format: string;
@@ -19,5 +20,4 @@ export declare const getAudioCodecStringFromTrak: (trak: TrakBox) => {
19
20
  description: Uint8Array | undefined;
20
21
  };
21
22
  export declare const getAudioCodecFromTrack: (track: TrakBox) => MediaParserAudioCodec;
22
- export declare const getAudioCodec: (boxes: AnySegment[], parserState: ParserState) => MediaParserAudioCodec | null;
23
23
  export {};
@@ -1,14 +1,32 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAudioCodec = exports.getAudioCodecFromTrack = exports.getAudioCodecStringFromTrak = exports.getAudioCodecFromIso = exports.getAudioCodecFromTrak = exports.getSampleRate = exports.getNumberOfChannelsFromTrak = exports.hasAudioCodec = void 0;
3
+ exports.getAudioCodecFromTrack = exports.getAudioCodecStringFromTrak = exports.getAudioCodecFromIso = exports.getAudioCodecFromTrak = exports.getSampleRate = exports.getNumberOfChannelsFromTrak = exports.hasAudioCodec = exports.getAudioCodec = void 0;
4
4
  const traversal_1 = require("./boxes/iso-base-media/traversal");
5
5
  const get_fps_1 = require("./get-fps");
6
6
  const get_tracks_1 = require("./get-tracks");
7
+ const getAudioCodec = (boxes, parserState) => {
8
+ const tracks = (0, get_tracks_1.getTracks)(boxes, parserState);
9
+ const allTracks = tracks.audioTracks.length +
10
+ tracks.otherTracks.length +
11
+ tracks.videoTracks.length;
12
+ if (allTracks === 0) {
13
+ throw new Error('No tracks yet');
14
+ }
15
+ const audioTrack = tracks.audioTracks[0];
16
+ if (!audioTrack) {
17
+ return null;
18
+ }
19
+ if (audioTrack.type === 'audio') {
20
+ return audioTrack.codecWithoutConfig;
21
+ }
22
+ return null;
23
+ };
24
+ exports.getAudioCodec = getAudioCodec;
7
25
  const hasAudioCodec = (boxes, state) => {
8
26
  try {
9
27
  return (0, exports.getAudioCodec)(boxes, state) !== null;
10
28
  }
11
- catch (e) {
29
+ catch (_a) {
12
30
  return false;
13
31
  }
14
32
  };
@@ -166,21 +184,3 @@ const getAudioCodecFromTrack = (track) => {
166
184
  return getAudioCodecFromAudioCodecInfo(audioSample);
167
185
  };
168
186
  exports.getAudioCodecFromTrack = getAudioCodecFromTrack;
169
- const getAudioCodec = (boxes, parserState) => {
170
- const tracks = (0, get_tracks_1.getTracks)(boxes, parserState);
171
- const allTracks = tracks.audioTracks.length +
172
- tracks.otherTracks.length +
173
- tracks.videoTracks.length;
174
- if (allTracks === 0) {
175
- throw new Error('No tracks yet');
176
- }
177
- const audioTrack = tracks.audioTracks[0];
178
- if (!audioTrack) {
179
- return null;
180
- }
181
- if (audioTrack.type === 'audio') {
182
- return audioTrack.codecWithoutConfig;
183
- }
184
- return null;
185
- };
186
- exports.getAudioCodec = getAudioCodec;
@@ -19,7 +19,7 @@ const hasContainer = (boxes) => {
19
19
  try {
20
20
  return (0, exports.getContainer)(boxes) !== null;
21
21
  }
22
- catch (e) {
22
+ catch (_a) {
23
23
  return false;
24
24
  }
25
25
  };
@@ -23,7 +23,7 @@ const hasDimensions = (boxes, state) => {
23
23
  try {
24
24
  return (0, exports.getDimensions)(boxes, state) !== null;
25
25
  }
26
- catch (err) {
26
+ catch (_a) {
27
27
  return false;
28
28
  }
29
29
  };
@@ -69,7 +69,7 @@ const hasDuration = (boxes, parserState) => {
69
69
  const duration = (0, exports.getDuration)(boxes, parserState);
70
70
  return (0, exports.getDuration)(boxes, parserState) !== null && duration !== 0;
71
71
  }
72
- catch (err) {
72
+ catch (_a) {
73
73
  return false;
74
74
  }
75
75
  };
package/dist/get-fps.js CHANGED
@@ -72,7 +72,7 @@ const hasFps = (boxes) => {
72
72
  try {
73
73
  return (0, exports.getFps)(boxes) !== null;
74
74
  }
75
- catch (err) {
75
+ catch (_a) {
76
76
  return false;
77
77
  }
78
78
  };
@@ -1,9 +1,9 @@
1
1
  import type { TrakBox } from './boxes/iso-base-media/trak/trak';
2
2
  import type { MediaParserVideoCodec, VideoTrackColorParams } from './get-tracks';
3
3
  import type { AnySegment } from './parse-result';
4
+ export declare const getVideoCodecFromIsoTrak: (trakBox: TrakBox) => "h264" | "av1" | "h265" | "prores";
5
+ export declare const getVideoCodec: (boxes: AnySegment[]) => MediaParserVideoCodec | null;
4
6
  export declare const hasVideoCodec: (boxes: AnySegment[]) => boolean;
5
7
  export declare const getVideoPrivateData: (trakBox: TrakBox) => Uint8Array | null;
6
8
  export declare const getIsoBmColrConfig: (trakBox: TrakBox) => VideoTrackColorParams | null;
7
9
  export declare const getVideoCodecString: (trakBox: TrakBox) => string | null;
8
- export declare const getVideoCodecFromIsoTrak: (trakBox: TrakBox) => "h264" | "av1" | "h265" | "prores";
9
- export declare const getVideoCodec: (boxes: AnySegment[]) => MediaParserVideoCodec | null;
@@ -1,96 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getVideoCodec = exports.getVideoCodecFromIsoTrak = exports.getVideoCodecString = exports.getIsoBmColrConfig = exports.getVideoPrivateData = exports.hasVideoCodec = void 0;
3
+ exports.getVideoCodecString = exports.getIsoBmColrConfig = exports.getVideoPrivateData = exports.hasVideoCodec = exports.getVideoCodec = exports.getVideoCodecFromIsoTrak = void 0;
4
4
  const traversal_1 = require("./boxes/iso-base-media/traversal");
5
5
  const av1_codec_private_1 = require("./boxes/webm/av1-codec-private");
6
6
  const get_fps_1 = require("./get-fps");
7
7
  const get_sample_aspect_ratio_1 = require("./get-sample-aspect-ratio");
8
- const hasVideoCodec = (boxes) => {
9
- try {
10
- return (0, exports.getVideoCodec)(boxes) !== null;
11
- }
12
- catch (e) {
13
- return false;
14
- }
15
- };
16
- exports.hasVideoCodec = hasVideoCodec;
17
- const getVideoPrivateData = (trakBox) => {
18
- const videoSample = (0, get_sample_aspect_ratio_1.getStsdVideoConfig)(trakBox);
19
- const avccBox = (0, get_sample_aspect_ratio_1.getAvccBox)(trakBox);
20
- const hvccBox = (0, get_sample_aspect_ratio_1.getHvccBox)(trakBox);
21
- const av1cBox = (0, get_sample_aspect_ratio_1.getAv1CBox)(trakBox);
22
- if (!videoSample) {
23
- return null;
24
- }
25
- if (avccBox) {
26
- return avccBox.privateData;
27
- }
28
- if (hvccBox) {
29
- return hvccBox.privateData;
30
- }
31
- if (av1cBox) {
32
- return av1cBox.privateData;
33
- }
34
- return null;
35
- };
36
- exports.getVideoPrivateData = getVideoPrivateData;
37
- const getIsoBmColrConfig = (trakBox) => {
38
- const videoSample = (0, get_sample_aspect_ratio_1.getStsdVideoConfig)(trakBox);
39
- if (!videoSample) {
40
- return null;
41
- }
42
- const colrAtom = (0, get_sample_aspect_ratio_1.getColrBox)(videoSample);
43
- if (!colrAtom) {
44
- return null;
45
- }
46
- // https://github.com/bbc/qtff-parameter-editor
47
- return {
48
- fullRange: colrAtom.fullRangeFlag,
49
- matrixCoefficients: colrAtom.matrixIndex === 1
50
- ? 'bt709'
51
- : colrAtom.matrixIndex === 5
52
- ? 'bt470bg'
53
- : colrAtom.matrixIndex === 6
54
- ? 'smpte170m'
55
- : null,
56
- primaries: colrAtom.primaries === 1
57
- ? 'bt709'
58
- : colrAtom.primaries === 5
59
- ? 'bt470bg'
60
- : colrAtom.primaries === 6
61
- ? 'smpte170m'
62
- : null,
63
- transferCharacteristics: colrAtom.transfer === 1
64
- ? 'bt709'
65
- : colrAtom.transfer === 6
66
- ? 'smpte170m'
67
- : colrAtom.transfer === 13
68
- ? 'iec61966-2-1'
69
- : null,
70
- };
71
- };
72
- exports.getIsoBmColrConfig = getIsoBmColrConfig;
73
- const getVideoCodecString = (trakBox) => {
74
- const videoSample = (0, get_sample_aspect_ratio_1.getStsdVideoConfig)(trakBox);
75
- const avccBox = (0, get_sample_aspect_ratio_1.getAvccBox)(trakBox);
76
- const hvccBox = (0, get_sample_aspect_ratio_1.getHvccBox)(trakBox);
77
- const av1cBox = (0, get_sample_aspect_ratio_1.getAv1CBox)(trakBox);
78
- if (!videoSample) {
79
- return null;
80
- }
81
- if (avccBox) {
82
- return `${videoSample.format}.${avccBox.configurationString}`;
83
- }
84
- if (hvccBox) {
85
- return `${videoSample.format}.${hvccBox.configurationString}`;
86
- }
87
- if (av1cBox) {
88
- const colrAtom = (0, get_sample_aspect_ratio_1.getColrBox)(videoSample);
89
- return (0, av1_codec_private_1.parseAv1PrivateData)(av1cBox.privateData, colrAtom);
90
- }
91
- return videoSample.format;
92
- };
93
- exports.getVideoCodecString = getVideoCodecString;
94
8
  const getVideoCodecFromIsoTrak = (trakBox) => {
95
9
  const stsdBox = (0, traversal_1.getStsdBox)(trakBox);
96
10
  if (stsdBox && stsdBox.type === 'stsd-box') {
@@ -183,3 +97,89 @@ const getVideoCodec = (boxes) => {
183
97
  return null;
184
98
  };
185
99
  exports.getVideoCodec = getVideoCodec;
100
+ const hasVideoCodec = (boxes) => {
101
+ try {
102
+ return (0, exports.getVideoCodec)(boxes) !== null;
103
+ }
104
+ catch (_a) {
105
+ return false;
106
+ }
107
+ };
108
+ exports.hasVideoCodec = hasVideoCodec;
109
+ const getVideoPrivateData = (trakBox) => {
110
+ const videoSample = (0, get_sample_aspect_ratio_1.getStsdVideoConfig)(trakBox);
111
+ const avccBox = (0, get_sample_aspect_ratio_1.getAvccBox)(trakBox);
112
+ const hvccBox = (0, get_sample_aspect_ratio_1.getHvccBox)(trakBox);
113
+ const av1cBox = (0, get_sample_aspect_ratio_1.getAv1CBox)(trakBox);
114
+ if (!videoSample) {
115
+ return null;
116
+ }
117
+ if (avccBox) {
118
+ return avccBox.privateData;
119
+ }
120
+ if (hvccBox) {
121
+ return hvccBox.privateData;
122
+ }
123
+ if (av1cBox) {
124
+ return av1cBox.privateData;
125
+ }
126
+ return null;
127
+ };
128
+ exports.getVideoPrivateData = getVideoPrivateData;
129
+ const getIsoBmColrConfig = (trakBox) => {
130
+ const videoSample = (0, get_sample_aspect_ratio_1.getStsdVideoConfig)(trakBox);
131
+ if (!videoSample) {
132
+ return null;
133
+ }
134
+ const colrAtom = (0, get_sample_aspect_ratio_1.getColrBox)(videoSample);
135
+ if (!colrAtom) {
136
+ return null;
137
+ }
138
+ // https://github.com/bbc/qtff-parameter-editor
139
+ return {
140
+ fullRange: colrAtom.fullRangeFlag,
141
+ matrixCoefficients: colrAtom.matrixIndex === 1
142
+ ? 'bt709'
143
+ : colrAtom.matrixIndex === 5
144
+ ? 'bt470bg'
145
+ : colrAtom.matrixIndex === 6
146
+ ? 'smpte170m'
147
+ : null,
148
+ primaries: colrAtom.primaries === 1
149
+ ? 'bt709'
150
+ : colrAtom.primaries === 5
151
+ ? 'bt470bg'
152
+ : colrAtom.primaries === 6
153
+ ? 'smpte170m'
154
+ : null,
155
+ transferCharacteristics: colrAtom.transfer === 1
156
+ ? 'bt709'
157
+ : colrAtom.transfer === 6
158
+ ? 'smpte170m'
159
+ : colrAtom.transfer === 13
160
+ ? 'iec61966-2-1'
161
+ : null,
162
+ };
163
+ };
164
+ exports.getIsoBmColrConfig = getIsoBmColrConfig;
165
+ const getVideoCodecString = (trakBox) => {
166
+ const videoSample = (0, get_sample_aspect_ratio_1.getStsdVideoConfig)(trakBox);
167
+ const avccBox = (0, get_sample_aspect_ratio_1.getAvccBox)(trakBox);
168
+ const hvccBox = (0, get_sample_aspect_ratio_1.getHvccBox)(trakBox);
169
+ const av1cBox = (0, get_sample_aspect_ratio_1.getAv1CBox)(trakBox);
170
+ if (!videoSample) {
171
+ return null;
172
+ }
173
+ if (avccBox) {
174
+ return `${videoSample.format}.${avccBox.configurationString}`;
175
+ }
176
+ if (hvccBox) {
177
+ return `${videoSample.format}.${hvccBox.configurationString}`;
178
+ }
179
+ if (av1cBox) {
180
+ const colrAtom = (0, get_sample_aspect_ratio_1.getColrBox)(videoSample);
181
+ return (0, av1_codec_private_1.parseAv1PrivateData)(av1cBox.privateData, colrAtom);
182
+ }
183
+ return videoSample.format;
184
+ };
185
+ exports.getVideoCodecString = getVideoCodecString;
@@ -37,7 +37,6 @@ const parseMedia = async ({ src, fields, reader: readerInterface = from_fetch_1.
37
37
  if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
38
38
  throw new Error('Aborted');
39
39
  }
40
- // eslint-disable-next-line no-constant-condition
41
40
  while (true) {
42
41
  const result = await currentReader.reader.read();
43
42
  if (iterator) {
@@ -33,7 +33,7 @@ const createContent = async () => {
33
33
  try {
34
34
  await writable.close();
35
35
  }
36
- catch (err) {
36
+ catch (_a) {
37
37
  // Ignore, could already be closed
38
38
  }
39
39
  const newHandle = await directoryHandle.getFileHandle(filename, {
@@ -0,0 +1,7 @@
1
+ import {remotionFlatConfig} from '@remotion/eslint-config-internal';
2
+
3
+ const config = remotionFlatConfig({react: false});
4
+
5
+ export default {
6
+ ...config,
7
+ };
package/package.json CHANGED
@@ -3,12 +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.226",
6
+ "version": "4.0.227",
7
7
  "main": "dist/index.js",
8
8
  "sideEffects": false,
9
9
  "devDependencies": {
10
10
  "@types/wicg-file-system-access": "2023.10.5",
11
- "@remotion/renderer": "4.0.226"
11
+ "eslint": "9.14.0",
12
+ "@remotion/renderer": "4.0.227",
13
+ "@remotion/eslint-config-internal": "4.0.227"
12
14
  },
13
15
  "publishConfig": {
14
16
  "access": "public"
@@ -87,9 +89,8 @@
87
89
  "description": "A pure JavaScript library for parsing video files",
88
90
  "scripts": {
89
91
  "formatting": "prettier src --check",
90
- "lint": "eslint src --ext ts,tsx",
92
+ "lint": "eslint src",
91
93
  "test": "bun test src/test",
92
- "watch": "tsc -w",
93
- "make": "bun --env-file=../.env.bundle bundle.ts"
94
+ "make": "tsc -d && bun --env-file=../.env.bundle bundle.ts"
94
95
  }
95
96
  }